Gateway & AP – Set-Up Guide
Configuring Ubiquiti Version 7.1.66

This chapter describes how to configure Ubiquiti (with or without using the USG), version equal to or greater than 7.1.66.
Before proceeding further with the configuration, you need to configure HSNM with a domain and a gateway as described in Adding a New Gateway.

Prerequisites

The prerequisites required for configuration are:

  • Ubiquiti controller version> = 7.1.66 installed on PC / Mac connected to the private LAN or to the USG (Ubiquiti Security Gateway) LAN in the case you use it.
  • AP UniFi connected to the same LAN network private LAN network or to the USG (Ubiquiti Security Gateway) LAN (in the case you use it).
  • HSNM version >= 7.0.142
  • Ability to port forward (refer to “Radius Profile” below) the Radius responses to the UniFi controller.
  • Optional: if you want to use HTTPS login, your LAN/Internet gateway must allow you to enter a static DNS route (in our case, 192.168.1.1 is a MikroTik router).
  • If you don’t need to use HTTPS but only HTTP, you can stop at Step 8 of the “Downloading the Configuration Files” chapter, and you won’t need any particular gateway.
  • If you want to use HTTPS login, your LAN/Internet gateway must allow you to enter a static DNS for the FQDN used to reach the Ubiquiti controller (in our case 192.168.1.1 is a MikroTik router).
    In case you use USG (Ubiquiti Security Gateway) the static DNS must be added inside USG
  • HSNM gateway configured with Ubiquiti hardware type.

When you set the Secret Radius in your HSNM do not exceeds 12 digits code and do not use symbols, otherwise UniFi will not send it correctly.

Step 1

Now inside HSNM, select your Gateway, click the dropdown menu, and choose Edit.

Step 2

Expand the General Data session.

Step 3

In the Hardware Type field, choose Ubiquiti UniFi Controller.

Wireless Network

Step 1

Login to your UniFi controller and click the Settings icon on the bottom left.
On the left menu, select WiFI and click Create New WiFi Network. Configure with:

  • Name–Edit the name of your network

Step 2

In the Advanced Configuration session, select Manual.

Step 3

In the WiFi Type, tick Guest Hotspot

Step 4

Once completed, click Add WiFi Network at the bottom right.

Radius Profile

Step 1

On the left menu, select Profiles and scroll down till RADIUS.

Step 2

Click Create New RADIUS Profile.
In the Radius Profile header, enter the details as follows:

  • Name–Edit the name for your profile
  • Enabled Wired–Tick Enable
  • Enabled Wireless–Tick Enable
  • Authentication Servers–Edit the Port and insert the Secret
  • Enable Accounting–Tick Enable
  • RADIUS Accounting Server–Edit the Port and insert the Secret
  • Enable Interim Update–Tick Enable (see note above)

In the IP Address fields enter the public IPs of the Radius server of your HSNM Radius and its relevant Secret.
In order to add the Secret you need to get it from your HSNM as described in the Radius Secret paragraph.

Troubleshoot: Interim Update

Caution: it will use the value you edit here and not the value you enter in the Product Policy. This value must be equal to or lower than the value entered in the products you set up for the users.

Caution: Ubiquiti UniFi Controller does not support or has errors in accounting radius. The data is correct only if the system is able to reach the UniFi controller (normally with NAT or VPN rules) and compensate directly for failings. If not possible, we recommend you to use this type of gateway only to authenticate users. You cannot parametrize the user data rate in the Products, you can define it only in the controller.

Guest Hotspot

Now, you need to set up the guest hotspot.

Step 1

From the Settings menu on the left, under profile, edit the default Guest Hotspot profile.
Enter the details as follows:

  • Authentication Type–Select Radius
  • Radius profile – Specify the already created Radius profile
  • Radius authentication –Select CHAP
  • Disconnect Requests – Enable and select port 3799
  • Guest landing page ON
  • Advanced Manual
  • Landing page – Select Redirect to the original URL
  •  HTTPS Redirection – Flag it if you need to user HTTPS
  • Redirect Using Hostname – Flag it if your need HTTPS Login
  • Secure Portal – Flag it if you need HTTPS login

Ignore any update message about portal customization.

Step 2

Click the Apply Change button to save the entries.

Configuring the Walled Garden

Now you need to configure the Walled Garden.

Step 1

From the Settings menu, select Guest Hotspot.

Step 2

Scroll down to Allowed Authorization Access Access

Step 3

Add one by one the IP address or domains you need for social login, payments, etc.

Step 4

Click Apply Changes to save the entries.

To know the accurate and relevant Walled Garden, you need to add one by one, access your HSNM platform and click the contextual dropdown menu of your gateway. Then select Download Walled Garden to get a .txt file with your accurate walled garden list as shown Figure Download Walled Garden.

Bandwidth Profile (Option)

Now you have the ability to limit the bandwidth assigned to the guests, by creating a Bandwidth Profile.

Step 1

From the Settings menu, select Profiles.

Step 2

Scroll down to Bandwidth Profile and click Create New Bandwidth Profile.

Step 3

Configure with Name, Bandwidth Limit (Download), Bandwidth Limit (Upload)

Step 4

Upon completion of the above steps, click the Apply Changes to save.

Downloading the Configuration Files

Step 1

From the context menu of the gateway, press Download Gateway Config Files to download the configuration zip file.

Step 2

Once the zip file is unpacked, you will find the following files:

  • authorize.html
  • index.html

Step 3

The files must be edited in the Ubiquiti Themes folder. The paths vary depending on the SO where the Ubiquiti Controller is installed:

  • Windows: C:\Users\<username>\Ubiquiti UniFi\data\sites\default\app-unifi-hotspot-
    portal
  • MAC: ~/Library/Application Support/UniFi/data/sites/default/app-unifi-hotspot-portal
  • Linux: /usr/lib/unifi/data/sites/default/app-unifi-hotspot-portal
  • For some Linux installations path will be: /opt/unifi/data/sites/default/app-unifi-hotspot-portal
  • CloudKey: /srv/unifi/data/sites/default/app-unifi-hotspot-portal

you don’t need to edit the MAC address of the gateway in your &DEVICE%.

Step 4

In your firewall, configure the port forward to accept disconnection requests from your HSNM (the same as in the “Radius Authentication and Access Control” paragraph and prerequisites).

You need to create the rule must with the following characteristics:

  1. enable it
  2. limit it to the public IP of your HSNM (optional but we suggest it for security reasons)
  3. the port must be the same set up in the “Guest Hotspot” paragraph and chosen in the prerequisites
  4. address it to the LAN IP address of the UniFi controller
  5. select the UDP protocol

Step 6

For Ubiquiti-type gateways, you need to enable these settings for the reasons listed below:

  • Force disconnections: if enabled, connections that have not received updates from the gateway for the ‘Interim Update’ time defined in the Product Policy plus the Timeout for Idle’ value are automatically closed.
  • Send disconnections requests to the gateway: in addition to forcing disconnections, it also sends a radius disconnection request to the gateway. Some types of gateways (e.g. Ubiquiti) may not send the stop to the radius and consider the device always active. If enabled, the gateway has to be reachable for the UDP port indicated in the “Guest Hotspot” paragraph.
  • Port for disconnection requests: port used by the gateway to accept disconnection requests. It is usually the 3799 but can vary depending on the type of gateway. It is the same one configured in the “Guest Hotspot” paragraph and opened in the firewall at the beginning of Step 5 in the “Downloading the Configuration Files” paragraph.
  • Check consumption by users: If the gateway does not support all the necessary radius attributes and the appliance is able to send disconnection requests (points listed above), it periodically checks the consumption of the logged-in users and if time/traffic limits are reached or at expiration, disconnects the user.

Configuring the Network

Step 1

From the Settings menu on the left, scroll down to Networks and enter the default one.
In the Gateway IP/Subnet enter the IP address of your LAN/Internet gateway and your LAN network.

If you are using the USG and it is rightly adopted from the Ubiquiti UniFi Controller, In the Gateway IP/Subnet the IP address will be automatically filled with the LAN IP set on your USG, and you can skip the below steps

Step 2

Scroll down to Advanced Configuration and select Manual (only if you are NOT using USG)

Step 3

Disable the internal DHCP by selecting None in the DHCP Mode (only if you are NOT using the USG).

HTTPS Fullchain

In case you need to configure the access over HTTPS, you need to follow the steps below:

Step 1

Decide which FQDN to dedicate to the UniFi controller (e.g. unifi.yourdomainhsnetworkmanager.com)

Step 2

Purchase a valid certificate (in our case wildcard certificate .*yourdomainhsnetworkmanager.com)

Step 3

Make sure that you have the complete chain (cert, intermediate, root) of your own certificate because the UniFi controller requires it. If you already have the full chain, then skip to the HTTPS keystore section otherwise continue in this section.

Step 4

Purchase a valid certificate (in our case wildcard certificate *.yourdomain.com)

Step 5

If the full chain is not available, you can use the following online utility: https://tools.keycdn.com/ssl to trace the correct concatenation.

In our test we initially had the CRT and CA-intermediate and not the root. (You can deduct it that in the form we have pasted only 2 —–BEGIN CERTIFICATE—– —–END CERTIFICATE—–). 
After a small search we went back to the missing root certificate (in the previous box identified by ISSUER CN):

and the root certificate in our case, is available at the issuer’s official website:
https://knowledge.digicert.com/generalinformation/INFO4033.html#links.

Beware, this may vary depending on the issuer you choose for the certificate.

Once we have the entire chain available, repeat the verification on the site https://tools.keycdn.com/ssl to make sure that the complete chain is now correct.
(This time the —–BEGIN CERTIFICATE—– —–END CERTIFICATE—– should be 3)
We should be in this final situation:

With a text or client editor, we put certificate-intermediate-root into a single file, in the order in which we tested it in the online tool.
In our case, we will name the final file as fullcert.crt

HTTPS Keystore

Step 1

Install the following software https://keystore-explorer.org/downloads.html

Step 2

Create a new JKS-type keystore

Step 3

Click on Tools > Import Key Pair

Step 4

Select the certificate format (in our case we used PKCS #8)

Step 5

Select the key and the concatenated fullcert you created earlier

Step 6

Uncheck Encrypted Private Key if you don’t have any type of passphrase set for the certificate, or type the Decryption Password of your certificate

Step 7

Click Import and choose UniFi as alias

Step 8

Set as password aircontrolenterprise and as key pair and re-insert it for confirmation

Step 9

Click on File > Save as

Step 10

Set the keystore password aircontrolenterprise

Step 11

Upload the new file created in the UniFi folder by replacing the existing “keystore” file.
The path of the file depends on the SO version where the UniFi controller is installed.

Step 12

Restart ace.jar or the controller directly in the case, for example, it is installed in a WINDOWS environment.

Step 13

If you are NOT using the USG, you have to configure in your gateway the static DNS route (prerequisites) of the FQDN chosen towards the LAN IP of your UniFi Controller (in our case unifi..com – 192.168.1.90)
If you are using the USG, If you are using the USG, you have to configure in your USG the static DNS entry (prerequisites) for the FQDN chosen towards the LAN IP of your UniFi Controller(e.g. unifi.yourdomain.com – 192.168.1.90).
For further details on how to perform that, read the paragraph “HTTPS Welcome Portal”.

Step 14

At this time, we can invoke the controller via browser (your gateway IP in a pc/mac in the same network with the first DNS) with the newly configured FDQN. In case the installation of the certificate is successful, you will reach the portal in HTTPS.

If you are using the USG and you have not yet created the static DNS entry for the FQDN on USG, you can, in any case, invoke the controller via the FQDN. Simply change the hosts file, on the PC where you would connect, in order to point the USG IP to the valid FQDN (used for the certificate):

C:\Windows\system32>notepad c:\Windows\System32\drivers\etc\hosts

Save the change and through CMD, test the real changes of the host file with the command:

    Ping execution unifi.valid-certificate-FQDN.com [IPCONFIG] with 32 bytes of data
    Reply from IPCONFIG: byte=32 time=1ms TTL=62
    Reply from IPCONFIG: byte=32 time<1ms TTL=62

If you do not get this point with the certificate correctly installed, you will need to check all the previous steps described in the current “HTTPS Keystore” paragraph.

HTTPS Welcome Portal

Step 1

From the Settings menu on the left, under Profiles, edit the default Guest Hotspot and on Redirection, be sure the following options are selected:

  • HTTPS Redirection – Flag it
  • Redirect Using Hostname – Flag it
  • Secure Portal – Flag it

Step 2

On textbox, set the same FQDN you tested in the “HTTPS Keystore” paragraph or a valid entry for the certificate you have configured

Step 3

Click the Apply Change button to save the entries.

Note         ONLY If you are using the USG, now you have to follow the other following steps to set a static DNS entry for the FDQN used to reach the UniFi Controller

Step 4

Now you need to recover the SSH access password of the devices.
Go to the Settings menu, then scroll down to System.

Step 5

Scroll down to Network Device SSH Authentication
Enter the details as follows:

  • Device SSH Authentication Tick Enable
  • UsernameEnter the username
  • PasswordEnter the password

Step 6

Use a shell to access via SSH your USG and enter the following STATIC DNS:

sudo vi /etc/dnsmasq.d/dnsmasq.static.conf
digit
address=/chosenhostname in the previous point/CONTOLLERIPLANPRIVATE

in our case

address=/unifi.yourdomain.com/192.168.1.100
save the new (:wq) file created and run
sudo /etc/init.d/dnsmasq force-reload

Execute a ping text to unifi.yourdomain.com from the USG console.
If the solved IP is the one just edited, you have successfully executed the STATIC DNS.

admin@USG:~$ ping unifi.yourdomain.com
PING unifi (192.168.1.100) 56(84) bytes of data.
64 bytes from unifi (192.168.1.100): icmp_req=1 ttl=128 time=1.19 ms
64 bytes from unifi (192.168.1.100): icmp_req=2 ttl=128 time=0.758 ms

Step 7

Step 7 This procedure will become permanent even if the USG is re-provisioned.