|
This is little bit later than I originally intended but I finally got around to setting up OpenVPN, and here’s how I did it. This guide is pretty simple to follow and should have an OpenVPN server on debian or ubuntu working within half an hour. I’ll also explain how to connect to the VPN from a windows PC. First, install OpenVPN on the server (you’ll need to be root for all of this guide) apt-get install openvpn Next, we need to configure the server. You need to make a decision here whether you want tun (routed) or tap (bridged) connections. The main difference is that tap will give the client a network address on the server network, whereas tun creates a private network managed by the server. In this guide I will use tap because I find that it works better with windows clients. Now you need to create certificates for the server and client for authentication purposes (which is much more secure than the passwords used in pptp). This is done through a number of steps: Preparing to generate the keys mkdir /etc/openvpn/easy-rsa cp /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /etc/openvpn/easy-rsa Now you need to edit /etc/openvpn/easy-rsa/vars with your required settings. You only really need to change the last section which is the default values for the fields in the certificates. Generate the certificate authority (CA) which will be used to sign the server and client certificates. cd /etc/openvpn/easy-rsa source ./vars ./clean-all ./build-ca Next, we need to create the server keys ./build-key-server servername Answer ‘yes’ when asked to sign the certificate and commit to the database, and then you’ll need to generate the diffie-hellman parameters which are used for key exchange between the client and server. ./build-dh And finally, create some client keys which will be used to allow clients to authenticate with the server. I prefer to use pkcs12 which stores the client public key and certificate in one passworded file. ./build-key-pkcs12 client1 As before, sign the key and commit to the database. You will be asked for a password which the client will use to connect to the server. Now all the keys are created, we need to configure the server. vim /etc/openvpn/server.conf (add the following lines) port 443 proto tcp dev tap ca /etc/openvpn/easy-rsa/keys/ca.crt cert /etc/openvpn/easy-rsa/keys/servername.crt key /etc/openvpn/easy-rsa/keys/servername.key dh /etc/openvpn/easy-rsa/keys/dh1024.pem ifconfig-pool-persist ipp.txt server-bridge 10.1.0.1 255.255.255.0 10.1.0.236 10.1.0.245 push “route 10.0.0.0 255.0.0.0″ keepalive 10 120 comp-lzo persist-key persist-tun status /var/log/openvpn-status.log verb 3 The only lines which you will need to change are ’server-bridge’, which is simply the default gateway, subnet mask, and the start and end IP’s to assign the clients, and the push route, which pushes specific routes to all clients. Now we need to create an ethernet bridge. First, we need to install bridge-utils: apt-get install bridge-utils Rather than explain how to set up a network bridge, I found a shell script which will do it for you. This can be found here. Just edit this with your network settings and execute it. You will also need to set it to create the bridge at boot time: update-rc.d bridge defaults Now you can start the openvpn server /etc/init.d/openvpn start Now we need to set up the windows client. First, download the OpenVPN client from here (at the time of writing, select 2.1 RC15). Install it, and create a file ‘client.conf’ in the config directory with the following parameters client dev tap proto tcp remote x.x.x.x 443 # (replace with your server IP) resolv-retry infinite nobind pkcs12 client1.p12 # (replace with the client name) ns-cert-type server comp-lzo verb 3 You can also add ‘redirect-gateway’ to the client configuration to pass all traffic down the VPN tunnel (rather than just traffic intended for the VPN itself). Now copy the client1.p12 certificate file to the config directory on the client, start the gui, and connect. Everything should now work. If you need to create any clients in the future, do the following: cd /etc/openvpn/easy-rsa source ./vars ./build-key-pkcs12 clientx If one of your certificates is compromised, you can revoke it using the guide here. This guide has been written from my notes and what I remember, so there may be a couple of things which aren’t 100% right. If anything goes wrong then post a comment or contact me and I’ll update the guide. Thanks to Author, orignal link http://www.monkeedev.co.uk/blog/2009/03/06/setting-up-openvpn-in-debianubuntu/
|