RB 112-153 Secure Hotspot HowTo with HTTPS (optionally HTTPS + RADIUS)
This HowTo is intended for use on MikroTik RouterBoard 112/153, with RouterOS 2.9.34.
Open your winbox utility, and connect to the board through MDP (or do a "/system reset" on a board already in use):
Click on "New Terminal".
Now we are going to control our interfaces, and to enable/disable whoes of our interest (I have a RB 153):
[admin@MikroTik] > /interface print
Flags: X - disabled, D - dynamic, R - running
# NAME TYPE RX-RATE TX-RATE MTU
0 R ether1 ether 0 0 1500
1 R ether2 ether 0 0 1500
2 R ether3 ether 0 0 1500
3 R ether4 ether 0 0 1500
4 R ether5 ether 0 0 1500
5 X wlan1 wlan 0 0 1500
[admin@MikroTik] > interface
[admin@MikroTik] interface> set 1,2,3,4 disabled=yes
[admin@MikroTik] interface> set 5 disabled=no
[admin@MikroTik] interface> print
Flags: X - disabled, D - dynamic, R - running
# NAME TYPE RX-RATE TX-RATE MTU
0 R ether1 ether 0 0 1500
1 X ether2 ether 0 0 1500
2 X ether3 ether 0 0 1500
3 X ether4 ether 0 0 1500
4 X ether5 ether 0 0 1500
5 wlan1 wlan 0 0 1500
Set a name for the Interfaces (without space on thw wireless interfaces, otherwise the hotspot setup will fail, I think that's a bug).
[admin@MikroTik] interface> set 0 name=internet
[admin@MikroTik] interface> set 5 name=hotspot
[admin@MikroTik] interface> print
Flags: X - disabled, D - dynamic, R - running
# NAME TYPE RX-RATE TX-RATE MTU
0 R internet ether 0 0 1500
1 X ether2 ether 0 0 1500
2 X ether3 ether 0 0 1500
3 X ether4 ether 0 0 1500
4 X ether5 ether 0 0 1500
5 hotspot wlan 0 0 1500
Now, we are going to setting-up the wireless interface
[admin@MikroTik] interface> wireless set hotspot ssid=IZ3HAD band=5ghz frequency=5280 mode=ap-bridge periodic-calibration=enabled
Set an IP address for the "internet" interface, it's default gateway and it's dns. The option allow-remote-requests is to speed up the dns by caching the local request to the MikroTik box.
[admin@MikroTik] interface> /ip
[admin@MikroTik] ip> address add address=192.168.10.99/24 interface=internet
[admin@MikroTik] ip> route add gateway=192.168.10.1
[admin@MikroTik] ip> dns
[admin@MikroTik] ip dns> set primary-dns=192.168.10.1
[admin@MikroTik] ip dns> set allow-remote-requests=yes
[admin@MikroTik] ip dns> ..
[admin@MikroTik] ip> ..
Now, create a certificate
on a Linux Machine. A script could be the follow:
#!/bin/sh
SERVER=hotspot.mynetwork.net
PRIVATE_KEY=$SERVER.key
CERTIFICATE_FILE=$SERVER
VALID_DAYS=1095
openssl genrsa -des3 -out $PRIVATE_KEY 1024
openssl req -new -x509 -days $VALID_DAYS -key $PRIVATE_KEY -out $CERTIFICATE_FILE # Autocertified
Then, give it the execution properties and execute it:
chmod +x myscript
./myscript
Give your password three times.
Give all the information required (CA, email, ecc.).
Two file are produced:
--- hotspot.mynetwork.net is the certificate
--- hotspot.mynetwork.net.key is the private key
Put this (via FTP) file on the root of MT Board.
Return to the MT Board CLI and give the following commands to import the certificate and the private keys:
[admin@MikroTik] > certificate
[admin@MikroTik] certificate> import
passphrase: ****************
certificates-imported: 1
private-keys-imported: 0
files-imported: 1
decryption-failures: 0
keys-with-no-certificate: 1
[admin@MikroTik] certificate> import
passphrase: ****************
certificates-imported: 0
private-keys-imported: 1
files-imported: 1
decryption-failures: 0
decryption-failures: 0
keys-with-no-certificate: 0
[admin@MikroTik] certificate> print
Flags: K - decrypted-private-key, Q - private-key, R - rsa, D - dsa
0 KR name="cert1" subject=C=IT,ST=xxxx,L=xxxx,O=xxxx,OU=xxxx,CN=IZ3HAD,emailAddress=xxxx issuer=C=IT,ST=xxxx,L=xxxx,O=xxxx,OU=xxxx,CN=IZ3HAD,
emailAddress=xxxx
serial-number="xxxx" email=xxxx
invalid-before=nov/13/2006 13:13:27 invalid-after=nov/12/2009 13:13:27
ca=yes
It's time to set-up your hotspot.
[admin@MikroTik] certificate> /ip hotspot
[admin@MikroTik] ip hotspot> setup
hotspot interface: hotspot
local address of network: 192.168.100.1/24
masquerade network: yes
address pool of network: 192.168.100.100-192.168.100.254
select certificate: IZ3HAD
ip address of smtp server: 0.0.0.0
dns servers: 192.168.10.2
dns name: hotspot.mynetwork.net
name of local hotspot user: admin
password for the user: *******
[admin@MikroTik] ip hotspot>
To force the authentication mode to "only HTTPS", type this:
[admin@MikroTik] ip hotspot> profile
[admin@MikroTik] ip hotspot profile> set hsprof1 login-by=https
If you have a freeradius server, add in /etc/raddb/clients.conf a new entry like this:
client 192.168.10.99/24 {
secret = iz3had
shortname = hotspot
}
And, on the RB CLI:
[admin@MikroTik] > /radius
[admin@MikroTik] radius> add address 192.168.10.2 service=hotspot secret=iz3had authentication-port=1812 accounting-port=1813
[admin@MikroTik] radius> /ip hotspot profile
[admin@MikroTik] ip hotspot profile> set hsprof1 use-radius=yes
Now you have a secured hotspot! Connect your client to the MT, and type any address on Firefox: you will get a certification approval request, it's yours!
Hints
If you disable Connection Tracking, the HotSpot will not be able to redirect your connection.
P.S.
I found a perfectly working guide on a previous topic to made this config, but there was nothing on the SSL side, and no or erroneus info found for a "secure" hotspot authenticating on the rest of the forum, so I decided to made a new howto.
Thanks to Normis for it's hint.
73 de IZ3HAD