OpenVPN between Mikrotik and OpenWRT: Difference between revisions
Brian Wilson (talk | contribs) mNo edit summary |
Brian Wilson (talk | contribs) mNo edit summary |
||
Line 49: | Line 49: | ||
source vars | source vars | ||
./pkitool ''clientname'' | ./pkitool ''clientname'' | ||
Can I test the keys before spending hours trying to deploy them? | |||
http://www.cyberciti.biz/faq/test-ssl-certificates-diagnosis-ssl-certificate/ | |||
Put all the certificate and key files somewhere on the debian server. Start a server. | |||
Try to connect to the server with a client. | |||
# In the first window run this so you can see its debug output | |||
cd keys | |||
openssl s_server -cert server.crt -key server.key | |||
Enter pass phrase for server.key: | |||
# In another window on the same server, connect to the server | |||
openssl s_client -showcerts -connect localhost:4433 -cert client.crt -key client.key -CAfile ca.crt | |||
In the server window you should see | |||
<code> | |||
Using default temp DH parameters | |||
Using default temp ECDH parameters | |||
ACCEPT | |||
-----BEGIN SSL SESSION PARAMETERS----- | |||
MFUCAQECAgMDBALAMAQABDB6p4OTXApCEW3xW99wF2wwP56zeXzzoQBNZuNQWdPy | |||
9S0gMHk/mJcc7xeTnDiJpfuhBgIEVJnFhKIEAgIBLKQGBAQBAAAA | |||
-----END SSL SESSION PARAMETERS----- | |||
Shared ciphers:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-DSS-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-DSS-CAMELLIA256-SHA:ECDH-RSA-AES256-GCM-SHA384:ECDH-ECDSA-AES256-GCM-SHA384:ECDH-RSA-AES256-SHA384:ECDH-ECDSA-AES256-SHA384:ECDH-RSA-AES256-SHA:ECDH-ECDSA-AES256-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:CAMELLIA256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:ECDH-RSA-DES-CBC3-SHA:ECDH-ECDSA-DES-CBC3-SHA:DES-CBC3-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-DSS-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-DSS-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:DHE-RSA-SEED-SHA:DHE-DSS-SEED-SHA:DHE-RSA-CAMELLIA128-SHA:DHE-DSS-CAMELLIA128-SHA:ECDH-RSA-AES128-GCM-SHA256:ECDH-ECDSA-AES128-GCM-SHA256:ECDH-RSA-AES128-SHA256:ECDH-ECDSA-AES128-SHA256:ECDH-RSA-AES128-SHA:ECDH-ECDSA-AES128-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:SEED-SHA:CAMELLIA128-SHA:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:ECDH-RSA-RC4-SHA:ECDH-ECDSA-RC4-SHA:RC4-SHA:RC4-MD5:EDH-RSA-DES-CBC-SHA:EDH-DSS-DES-CBC-SHA:DES-CBC-SHA:EXP-EDH-RSA-DES-CBC-SHA:EXP-EDH-DSS-DES-CBC-SHA:EXP-DES-CBC-SHA:EXP-RC2-CBC-MD5:EXP-RC4-MD5 | |||
CIPHER is ECDHE-RSA-AES256-GCM-SHA384 | |||
Secure Renegotiation IS supported | |||
</code> | |||
In the client window you should see | |||
<code> | |||
</code> | |||
== The OpenWRT router == | == The OpenWRT router == |
Revision as of 21:31, 23 December 2014
This is a page full of details, for the intro and how to set up Windows and Linux clients, see OpenVPN.
I am writing this while testing with three virtual machines on a Mac. Once I have the steps down, I will be transferring everything over to a Buffalo WZR WiFi access point running OpenWRT 14.xx and a Mikrotik RB750 running RouterOS 5.27.
I am running my virtual machines on VirtualBox. I use images downloaded from OpenWRT and Mikrotik and install them into very minimal setups. This is handy, they boot FAST and I don't risk cutting myself off from the remote end as I do tests and experiment.
The main reasons I chose to use OpenVPN over other options (today) are:
- I can directly route packets so I don't need to mess with NAT at one end as with PPTP
- My endpoint is hiding behind several layers of access points and routers that I don't control. OpenVPN works fine in this case.
The virtual network
Plover (Macintosh) 192.168.56.1 LAN (This will be the LAN in my house) 192.168.56.101 VM1 = Router #1, OpenWRT Barrier Breaker 76.0.0.1 Internet 76.0.0.2 VM2 = Router #2, Mikrotik RouterOS 6.23 192.168.2.1 REMOTE LAN (this will be the CDS OFFICE LAN) 192.168.2.2 VM3 = Remote Debian server
Creating the certificate and key files
First time
cd /etc/openvpn/easy-rsa emacs vars source vars ./clean-all ./pkitool --initca ./pkitool --pass --server servername ./pkitool clientname
Later to create more clients
cd /etc/openvpn/easy-rsa source vars ./pkitool clientname
Can I test the keys before spending hours trying to deploy them? http://www.cyberciti.biz/faq/test-ssl-certificates-diagnosis-ssl-certificate/
Put all the certificate and key files somewhere on the debian server. Start a server. Try to connect to the server with a client.
# In the first window run this so you can see its debug output cd keys openssl s_server -cert server.crt -key server.key Enter pass phrase for server.key: # In another window on the same server, connect to the server openssl s_client -showcerts -connect localhost:4433 -cert client.crt -key client.key -CAfile ca.crt
In the server window you should see
Using default temp DH parameters
Using default temp ECDH parameters
ACCEPT
BEGIN SSL SESSION PARAMETERS-----
MFUCAQECAgMDBALAMAQABDB6p4OTXApCEW3xW99wF2wwP56zeXzzoQBNZuNQWdPy
9S0gMHk/mJcc7xeTnDiJpfuhBgIEVJnFhKIEAgIBLKQGBAQBAAAA
END SSL SESSION PARAMETERS-----
Shared ciphers:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-DSS-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-DSS-CAMELLIA256-SHA:ECDH-RSA-AES256-GCM-SHA384:ECDH-ECDSA-AES256-GCM-SHA384:ECDH-RSA-AES256-SHA384:ECDH-ECDSA-AES256-SHA384:ECDH-RSA-AES256-SHA:ECDH-ECDSA-AES256-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:CAMELLIA256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:ECDH-RSA-DES-CBC3-SHA:ECDH-ECDSA-DES-CBC3-SHA:DES-CBC3-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-DSS-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-DSS-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:DHE-RSA-SEED-SHA:DHE-DSS-SEED-SHA:DHE-RSA-CAMELLIA128-SHA:DHE-DSS-CAMELLIA128-SHA:ECDH-RSA-AES128-GCM-SHA256:ECDH-ECDSA-AES128-GCM-SHA256:ECDH-RSA-AES128-SHA256:ECDH-ECDSA-AES128-SHA256:ECDH-RSA-AES128-SHA:ECDH-ECDSA-AES128-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:SEED-SHA:CAMELLIA128-SHA:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:ECDH-RSA-RC4-SHA:ECDH-ECDSA-RC4-SHA:RC4-SHA:RC4-MD5:EDH-RSA-DES-CBC-SHA:EDH-DSS-DES-CBC-SHA:DES-CBC-SHA:EXP-EDH-RSA-DES-CBC-SHA:EXP-EDH-DSS-DES-CBC-SHA:EXP-DES-CBC-SHA:EXP-RC2-CBC-MD5:EXP-RC4-MD5
CIPHER is ECDHE-RSA-AES256-GCM-SHA384
Secure Renegotiation IS supported
In the client window you should see
The OpenWRT router
Refer to http://wiki.openwrt.org/doc/howto/vpn.openvpn I am not going to copy all the instructions here, just go look at that page now.
ssh [email protected] opkg update opkg install openvpn-openssl mkdir /etc/openvpn mv /tmp/openwrt.* /tmp/ca.crt /etc/openvpn
A Debian client
When I could not get the OpenWRT and Mikrotik devices to talk, I backed off on the OpenWrt side and used the Debian Server as an OpenVPN client.
The Mikrotik router
Refer to same Mikrotik page as mentioned above, http://wiki.mikrotik.com/wiki/OpenVPN
Import the three files transferred in the "create" section above.
/certificate import file-name=ca.crt import file-name=server.crt import file-name=server.key set 0 name=ca set 1 name=cdswireless # This will let you have many OpenVPN clients /ip pool add name=ovpn-pool ranges=10.10.10.2-10.10.10.50 /ppp profile add change-tcp-mss=default local-address=10.8.0.1 \ name="ovpn_profile" only-one=default remote-address=ovpn-pool \ use-compression=default use-encryption=required use-vj-compression=default /ppp secret add caller-id="" comment="" disabled=no limit-bytes-in=0 \ limit-bytes-out=0 name="ovpn" password="password" routes="" service=any
# If you don't already have these defined, /ip address add address=192.168.4.253/24 comment="Management LAN" interface=ether1 network=192.168.4.0 add address=192.168.2.1/24 comment="CDS LAN" interface=ether2 network=192.168.2.0 add address=172.16.1.1/24 comment=Internet interface=ether3 network=172.16.1.0
/ip route # This is how we really reach the Internet add distance=1 gateway=192.168.4.254 add dst-address=10.8.0.0/24 gateway=10.8.0.1 comment="OVPN"
# If you change the keys later you will need to repeat this step /interface ovpn-server server set auth=sha1,md5 certificate=cdswireless \ cipher=blowfish128,aes128,aes192,aes256 default-profile=ovpn_profile \ enabled=yes keepalive-timeout=disabled max-mtu=1500 mode=ip netmask=27 \ port=1194 require-client-certificate=no
# I have the firewall turned off for testing right now. # When I activate the firewall I will need this /ip firewall filter add action=accept chain=input comment="OpenVPN" disabled=no dst-port=1194 protocol=udp
The "remote" server
I have a generic Debian server installed already in a VirtualBox machine, so I used it as the far end of my network to allow me to test connectivity through the two routers.
Tests
Start the client
/etc/init.d/openvpn start cat /tmp/openvpn.log ifconfig tun0
Make sure you can reach each of the routers and the Debian server from the Mac, and that you can reach each of the routers and the Mac from the Debian server.