OpenVPN provides a complete replacement of
the time to time unreliable PPTP VPN which is a part of the standard SME
distribution. This Howto is focused on using OpenVPN as a Windows 2k/XP Client
to Server VPN connection. The installation consists of two steps, first the the
portion which resides on the server and then the Client. I the following setup
it is assumed that the local IP range for the private network is 192.168.1.0/24
and that the tunneled VPN network will be 192.168.100.0/24.
OpenVPN Server Configuration:
SME 6.x
[root@sme home]# cd /root
[root@sme root]# mkdir openvpn
[root@sme openvpn]# cd openvpn
[root@sme openvpn]# wget
http://sme.swerts-knudsen.com/downloads/OpenVPN/perl-DateManip-5.40-15.i386.rpm
[root@sme openvpn]# wget
http://sme.swerts-knudsen.com/downloads/OpenVPN/lzo-1.08-3.i386.rpm
[root@sme openvpn]# wget
http://sme.swerts-knudsen.com/downloads/OpenVPN/openvpn-2.0.7-1.i386.rpm
[root@sme openvpn]# wget
http://sme.swerts-knudsen.com/downloads/OpenVPN/smeserver-openvpn-0.0.1-2.noarch.rpm
[root@sme openvpn]# rpm -Uvh *.rpm
|
SME 7.0
[root@sme home]# cd /root
[root@sme root]# mkdir openvpn
[root@sme openvpn]# cd openvpn
[root@sme openvpn]# wget
http://sme.swerts-knudsen.com/downloads/OpenVPN/SME7/lzo-1.08-4.2.el4.rf.i386.rpm
[root@sme openvpn]# wget
http://sme.swerts-knudsen.com/downloads/OpenVPN/SME7/openvpn-2.0.2-1.2.el4.rf.i386.rpm
[root@sme openvpn]# wget
http://sme.swerts-knudsen.com/downloads/OpenVPN/smeserver-openvpn-0.0.1-2.noarch.rpm
[root@sme openvpn]# rpm -Uvh *.rpm
|
[root@sme home]# /sbin/e-smith/db
configuration setprop openvpn status enabled
|
[root@sme home]# cd /etc/openvpn/easy-rsa [root@sme easy-rsa]# pico vars |
[root@sme easy-rsa]# . vars [root@sme easy-rsa]# ./clean-all [root@sme easy-rsa]# ./build-ca Using configuration from /etc/openvpn/easy-rsa/openssl.cnf Generating a 1024 bit RSA private key |
Now we can build the certificate/private-key pairs for both the server and clients. Again choose choose "Organizational Unit Name" and "Common Name" as above. Do not add "A Challenge password" when asked, just press <ENTER>. The same goes for "An optional company name". Sign the certificate in the end.
[root@sme easy-rsa]#
./build-key server Using configuration from /etc/openvpn/easy-rsa/openssl.cnf Generating a 1024 bit RSA private key |
[root@sme easy-rsa]#
./build-key client Using configuration from /etc/openvpn/easy-rsa/openssl.cnf Generating a 1024 bit RSA private key |
[root@sme easy-rsa]# ./build-dh Generating DH parameters, 1024 bit long safe prime, generator 2 This is going to take a long time .................. |
The newly generated keys needs to be copied to the the OpenVPN directory.
[root@sme easy-rsa]# cp keys/ca.crt
..
[root@sme easy-rsa]# cp keys/server.crt
..
[root@sme easy-rsa]# cp keys/server.key
..
[root@sme easy-rsa]# cp
keys/dh1024.pem ..
|
The OpenVPN configuration along with authentication scripts file can be downloaded from my site. Download them and make the executable for root. There will be log files created in /var/log/openvpn indicating when users have logged in and out as well as login failures.
[root@sme easy-rsa]# cd ..
[root@sme openvpn]# wget -N
http://sme.swerts-knudsen.dk/downloads/OpenVPN/server.conf
[root@sme openvpn]# mkdir -p /var/log/openvpn
[root@sme openvpn]# wget -N
http://sme.swerts-knudsen.dk/downloads/OpenVPN/logoff.sh
[root@sme openvpn]# wget -N
http://sme.swerts-knudsen.dk/downloads/OpenVPN/logoff_user.pl
[root@sme openvpn]# wget -N
http://sme.swerts-knudsen.dk/downloads/OpenVPN/validate.sh
[root@sme openvpn]# wget -N
http://sme.swerts-knudsen.dk/downloads/OpenVPN/validate_user.pl
[root@sme openvpn]# wget -N
http://sme.swerts-knudsen.dk/downloads/OpenVPN/openvpn.up
[root@sme openvpn]# chmod 755
*.pl
[root@sme openvpn]# chmod 755
*.sh
[root@sme openvpn]# chmod 700
*.up
|
Now you need to make a few changes to the /etc/openvpn/server.conf. You need to change the red parameters to match your network configuration.
port 1194
dev tap tls-server dh dh1024.pem ca ca.crt cert server.crt key server.key auth-user-pass-verify ./validate.sh via-env client-disconnect ./logoff.sh
up ./openvpn.up
mode server duplicate-cn ifconfig 192.168.100.1 255.255.255.0 ifconfig-pool 192.168.100.100 192.168.100.200 255.255.255.0 # IP range for OpenVPN clients mtu-test tun-mtu 1500 tun-mtu-extra 32 mssfix 1450 ping 10 ping-restart 120 push "ping 10" push "ping-restart 60" push "dhcp-option DOMAIN yourdomain.com" # push the DNS domain suffix push "dhcp-option DNS 192.168.1.1" # push primary DNS entry to the openvpn clients. push "route 192.168.1.0 255.255.255.0 192.168.100.1" # add route to to protected network comp-lzo status-version 2 status openvpn-status.log verb 3 |
Then you need to open port 1194 for UDP traffic as this is the default tunnel for OpenVPN. The port open contrib can be downloaded from my site. Now go into the Server Manager panel and open the port.
[root@sme home]# rpm -Uvh http://sme.swerts-knudsen.dk/downloads/dmc-mitel-portopening-0.0.1-4.noarch.rpm |
You now need to add the VPN address range as a local networks in the server-manager under the Security section.
Add a local network
Router: IP address of the VPN server and the same value as added in server.conf under "push "route x.x.x.x 255.255.255.0 192.168.100.1"
The last thing you need to do before the installation is complete is to do a small change in the /etc/openvpn/openvpn.up file. Change the 192.168.1.1 value to match router you used when adding a local network.
#!/bin/sh route del -net 192.168.100.0 netmask 255.255.255.0 gw 192.168.1.1 route del -net 192.168.100.0 netmask 255.255.255.0 dev tap0 route add -net 192.168.100.0 netmask 255.255.255.0 gw 192.168.100.1 |
When you have changed the file to match your network we start the service.
[root@sme home]# service openvpn start |
I have noticed that sending emails through an internal mail server via the VPN connection is extremely slow. This turned out to be due to a reverse DNS timeout/error caused by the SME server. This can be corrected by adding this. Add the following red text to the /etc/e-smith/templates/var/service/tinydns/root/data/30nameServers file.
{ $OUT .= "# NS Records\n"; foreach my $domain (get_domains()) { $OUT .= ".$domain:\:$SystemName." . get_local_domainname(). "\n"; } use esmith::util; # Add name server record for local reverse zone my $reverse = esmith::util::computeLocalNetworkReversed ($LocalIP, $LocalNetmask); $reverse =~ s/\.$//; $OUT .= ".$reverse\:\:127.0.0.1\n"; #VPN addition $reverse = esmith::util::computeLocalNetworkReversed ("192.168.100.0","255.255.255.0"); $reverse =~ s/\.$//; $OUT .= ".$reverse\:\:127.0.0.1\n"; } |
Now we need to expand the config template out to make the real configuration files and the restart the affected DNS services to force them to use the new values.
[root@sme ]# /sbin/e-smith/expand-template
/var/service/tinydns/root/data
[root@sme ]# cd /var/service/tinydns/root/
[root@sme ]# tinydns-data
[root@sme ]# service dnscache
stop
[root@sme ]# service tinydns
stop
[root@sme ]# service tinydns
start
[root@sme ]# service dnscache
start
|
Check the date/time stamps of both /var/service/tinydns/root/data and /var/service/tinydns/root/data.cdb. They should match or at least be very close.
Your OpenVPN server configuration is now complete !!!
OpenVPN Client Configuration:
The Win2k/XP client installation is quite simple and pretty much only require the Windows GUI and a configuration file. The Windows GUI can be downloaded from my download area or from its origin. When the GUI has been installed you need to create a configuration file for your VPN tunnel. Create a file in "C:/Program Files/OpenVPN/config" called VPN.ovpn with the following content and where you change the vpn.yourdomain.com to match your configuration.
port 1194 dev tap remote vpn.yourdomain.com tls-client auth-user-pass ca ca.crt cert client.crt key client.key mtu-test tun-mtu 1500 tun-mtu-extra 32 mssfix 1450 pull comp-lzo verb 4 |
You now need to copy the Client keys you generated during the Server installation to the same directory on the Win2k/XP client. The following keys and certificates must be copied to the "C:/Program Files/OpenVPN/config" folder.
- ca.crt
- client.crt
- client.key
ไม่มีความคิดเห็น:
แสดงความคิดเห็น