Background:
When I first decided to create my own server I ran down a list of elements I wanted. The first were obvious, web-server, and e-mail server. However I also realized that I have many games that I would enjoy playing with friends. These are older games that only allow multiplayer over local networks. A very secure and novel solution is to use OpenVPN to make the remote computers appear as though they are on the same local network. So I set out to implement this on my second computer. I used Ubuntu Dapper Drake server edition and then began the painstaking task of configuring all the components. However when I tried to configure OpenVPN the documentation on their web-site was lacking. It has been updated and is very good now (this was in March of 2006) but I wrote a guide to installing and configuring OpenVPN on Ubuntu Dapper Drake. I hope you find this interesting and beneficial.
Purpose:
The purpose of this document is to describe how to install OpenVPN server on an Ubuntu Linux system and have it utilize an Ethernet bridge to access your local network. Ethernet bridges essentially allow the operating system to treat multiple network interfaces as one combined port. When used with OpenVPN a bridge will allow you to easily connect external users to your internal network and have them receive all traffic as though they were locally connected. The alternative is to use OpenVPN with a route but that will not allow some forms of traffic through (such as multicast), multicast traffic is important to me as many games require multicast data.
What is needed:
- Linux System running Ubuntu (tutorial will work with any Linux install with a few modifications)
- Root access to the server
- External computer to test with
Scope:
This tutorial aims to instruct how to install and configure an OpenVPN server with internal network access via an Ethernet bridge. This tutorial does not explain how to install Linux and get the OS environment configured. There are many good tutorials out there that you can use, once you have your Linux server ready simply follow this document.
If you are interested in a tutorial to configure your system I recommend this easy to follow guide:
http://www.howtoforge.com/perfect_setup_ubuntu_6.06
Tutorial:
1. The first thing you should do when installing OpenVPN is to read some of the documentation on the OpenVPN web-site. This seems like a simple step to skip but if you do not know exactly how OpenVPN works then you risk opening your internal network to security problems. Additionally there is a lot of good documentation on the OpenVPN site that will help you understand networking terms and methods. Such as exactly what an Ethernet Bridge is and how it differs from a route.
# Link to OpenVPN Homepage http://openvpn.net/ # Link to Explanation of bridging http://openvpn.net/bridge.html |
2. Now that you have taken some time to understand OpenVPN and Bridges we can begin to implement these technologies into a server on your local network. The first step is to collect information about your network, this tutorial is designed for a network that meets the following:
Linux Server Internal IP: 173.23.1.5 Internet Gateway: 173.23.1.1 Gateway's IP Address: 139.142.227.155 Network Layout: Internet ----- Router/Firewall ----- OpenVPN Server (eth1) |
3. To simplify setup for users you should register your IP address with an Internet Domain service. If you are cheap like me simply use "no-ip.com". Create an account then download their dynamic dns update tool and follow their installation instructions. This will give you a free dynamic domain. Additionally the IP address for your server needs to be static, this is due to the fact that the bridge will not update on a DHCP IP address change. You can configure this in your /etc/network/interfaces file. My server has an entry for my network card that looks like this:
# The primary network interface # connects to insecure router auto eth0 iface eth0 inet static address 173.23.1.5 netmask 255.255.255.0 network 173.23.1.0 broadcast 173.23.1.255 gateway 173.23.1.1 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 142.165.200.5 |
4. Now that the information is collected you can begin by installing OpenVPN and the utilities to manage a bridge, to do this simply type:
sudo apt-get install openvpn bridge-utils |
5. With OpenVPN installed we can now begin to configure, the first step is to move the apt-get directory into /etc/openvpn for easy access, and to preserve the original data (in case you mess up and need to revert).
cp -R /usr/share/doc/openvpn/examples/ /etc/openvpn/ |
6. Now we want to load the vars file with our own defaults. Open the file in your favorite editor and change KEY_COUNTRY, KEY_PROVINCE, KEY_CITY, KEY_ORG, and KEY_EMAIL to match your information.
cd /etc/openvpn/examples/easy-rsa/ vi ./vars |
My vars file looks like this: (key components only)
#this is to ensure secure data export KEY_SIZE=2048 # These are the default values for fields # which will be placed in the certificate. # Don't leave any of these fields blank. export KEY_COUNTRY=CA export KEY_PROVINCE=SK export KEY_CITY=Martensville export KEY_ORG="TheBakershome" export KEY_EMAIL="geoff@thebakershome.net" |
7. Now we to begin the configuration of the server.
. ./vars ./clean-all ./build-ca |
The purpose of these command are as follows, the first one will clear any old keys or configuration elements, there should not be any there but it does not hurt to be sure. The last command will setup OpenVPN configuration items, be sure to follow the prompt and make sure you fill in using elements to match your situation. Since we loaded the vars file with your settings prior to these steps the default values should work on almost all elements, but the Common Name will need to be specified.
8. Now you need to create the server keys, these are private files that you should keep secure.
./build-key-server server |
I found that if I did not use the same information that I used in the build-ca step above that the "Sign Certificate" and "commit" did not work. If you experience this problem just repeat this step with the same values, it should work at that point. This should not occur for you as we have loaded the default values into the vars file, but just in case be aware of the cause.
9. Now you are ready to generate keys for users, first decide if you wish to password protect the keys or not. I recommend building with passwords if you are not going to implement authentication in OpenVPN, if you are then simply generate without. This tutorial will assume that you are going to implement authentication in OpenVPN, since it is the most trusted method. Make sure that you specify the correct Common Name when prompted.
#Generate with password ./build-key-pass username #Generate without password ./build-key username |
10. Now you need to build the Diffie Hellman parameters, for details on what these are simply check the OpenVPN homepage. The simple answer is that they provide a method to negotiate a secure connection over an insecure channel. This process will take a bit of time so you may want to take a break, just relax we are almost there.
./build-dh #generate server id key openvpn --genkey --secret ta.key |
11. As an aside I found a very interesting table on the OpenVPN web-page. It provides some information on what to do with the various files we just generated. For the purposes of this tutorial I have "borrowed" their table and pasted it here, to view the original visit the OpenVPN installation guide on their homepage.
| Filename | Needed By | Purpose | Secret |
| ca.crt | server + all clients | Root CA certificate | NO |
| ca.key | key signing machine only | Root CA key | YES |
| dh{n}.pem | server only | Diffie Hellman parameters | NO |
| server.crt | server only | Server Certificate | NO |
| server.key | server only | Server Key | YES |
| ta.key | server+ all clients | Server TLS Auth Key | YES |
| client1.crt | client1 only | Client1 Certificate | NO |
| client1.key | client1 only | Client1 Key | YES |
| client2.crt | client2 only | Client2 Certificate | NO |
| client2.key | client2 only | Client2 Key | YES |
| client3.crt | client3 only | Client3 Certificate | NO |
| client3.key | client3 only | Client3 Key | YES |
12. Now we need to configure the server.conf file to setup the operation. Here is my configuration file:
# Which local IP address should OpenVPN # listen on? (optional) local 173.23.1.5 port 1194 # TCP or UDP server? proto udp #This is key to configuring our bridge dev tap0 #direct these to your generated files ca /etc/openvpn/openvpn/examples/easy-rsa/keys/ca.crt cert /etc/openvpn/openvpn/examples/easy-rsa/keys/server.crt key /etc/openvpn/openvpn/examples/easy-rsa/keys/server.key dh /etc/openvpn/openvpn/examples/easy-rsa/keys/dh2048.pem ifconfig-pool-persist ipp.txt #ensure the range of ip addresses you use in the last two arguments # of this statement are not in use by either the DHCP server or any other # device on your internal network. server-bridge 173.23.1.5 255.255.255.0 173.23.1.60 173.23.1.70 #needed to allow communication to internal network client-to-client keepalive 10 120 #encryption - very important ;) #AES encryption is backed by many security firms #however if you are concerned about speed use blowfish: "BF-CB" cipher AES-128-CBC #if you have another subnet you need to provide the route push "route 173.23.2.0 255.255.255.0" #server id protection tls-auth ta.key 0 #compression for network speed comp-lzo # if packets are too large fragment them (only really useful if you have an old router) #fragment 1400 #limit the number of connections max-clients 5 #some secuurity settings # do not use if running server on Windows user nobody group nogroup persist-key persist-tun #log file settings status openvpn-status.log verb 3 # authentication plugin #forces client to have a linux acount in order to connect plugin /usr/lib/openvpn/openvpn-auth-pam.so login |
13. Now that the server is configured we need to create the bridge interface. The bridge is managed by Linux and is only used by OpenVPN so setup is a little different. I did it using a script to start/stop the interface. Place this script in "/etc/init.d/bridge" and then run the following:
update-rc.d bridge defaults 15 |
Here is the script, before using you will need to edit it for your network and server settings.
#!/bin/bash
# Create global variables
# Define Bridge Interface
br="br0"
# Define list of TAP interfaces to be bridged,
# for example tap="tap0 tap1 tap2".
tap="tap0"
# Define physical ethernet interface to be bridged
# with TAP interface(s) above.
eth="eth0"
eth_ip="173.23.1.5"
eth_netmask="255.255.255.0"
eth_broadcast="173.23.1.255"
gw="173.23.1.1"
start_bridge () {
#################################
# Set up Ethernet bridge on Linux
# Requires: bridge-utils
#################################
for t in $tap; do
openvpn --mktun --dev $t
done
for t in $tap; do
ifconfig $t 0.0.0.0 promisc up
done
ifconfig $eth 0.0.0.0 promisc up
brctl addbr $br
brctl addif $br $eth
for t in $tap; do
brctl addif $br $t
done
ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast up
route add default gw $gw $br
}
stop_bridge () {
####################################
# Tear Down Ethernet bridge on Linux
####################################
ifconfig $br down
brctl delbr $br
for t in $tap; do
openvpn --rmtun --dev $t
done
ifconfig $eth $eth_ip netmask $eth_netmask broadcast $eth_broadcast up
route add default gw $gw $eth
}
case "$1" in
start)
echo -n "Starting Bridge"
start_bridge
;;
stop)
echo -n "Stopping Bridge"
stop_bridge
;;
restart)
stop_bridge
sleep 2
start_bridge
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac
|
14. Now you need to edit your client configuration script, client.conf. This will be given to your clients and will be the script they invoke (via openvpn) to connect to your server. In the same way you modified the server.conf file edit the network information to match your internal network. Here is an example of one of my scripts:
client dev tap proto udp # change this to your server's address remote thebakers.no-ip.org 1194 resolv-retry infinite nobind persist-key persist-tun # Point the key and crt files to # the ones for this user tls-client ca ca.crt cert geoff.crt key geoff.key #ensure that we are talking to a server ns-cert-type server #confirm we are talking to the correct server tls-auth ta.key 1 # Select a cryptographic cipher. # If the cipher option is used on the server # then you must also specify it here. cipher AES-128-CBC # Enable compression on the VPN link. comp-lzo #fragment large packets # I found I needed this for some games but it is # not required #fragment 1400 # enable user/pass authentication auth-user-pass |
15. Now you are ready to test your server, to do this load the server from the command line:
sudo /etc/init.d/bridge start sudo openvpn /etc/openvpn/server.conf |
##Look for any errors that may be reported while OpenVPN parses the server.conf file. If it gets to the "Succeeded" state then switch computers to a PC on an external network (I used my PC at work) and open the OpenVPN connection. If everything is working here reboot your server and attempt to open the connection again, this will ensure that everything is booting correctly.
###Once the connection is established by the client test it by pinging devices on your internal network. Assuming everything is connected correctly you should be able to contact them.
16. If you have any troubles with step 16, the first place to look is at firewalls. If your server has firewall restrictions they may be blocking the bridge from operating, check your config and adjust as necessary. At this point your server should be running, good luck and have fun.
Post-Install
I ended up having some difficulty configuring shorewall on my openvpn server. It is a little tricky since you have to tell shorewall to differentiate between a physical input (eth0) and the virtual input (tap0). To do this open "/etc/shorewall/hosts" and add:
net br0:eth0 vpn br0:tap0 |
This will tell shorewall to differentiate between the vpn and the insecure traffic. Once you have this data you need to add the following to your policy file. This will tell shorewall that the traffic from the vpn is trusted so just let it all through.
vpn all ACCEPT
You will also need to mention the vpn in the zones file by adding
vpn ipv4 |
Lastly you will need to tell shorewall that a tunnel is coming through by opening the tunnels file and adding:
openvpn net 0.0.0.0/0 vpn |
Conclusion:
I hope your server is working good and that you can now play your old classic games with friends. The other benefit of this network is that you can access your data on your home PC from anywhere and you will be certain that your connection if free from intrusion.

Comments
Hi Geoff. Thanks for the
Hi Geoff.
Thanks for the tutorial.
Got a small problem with your /etc/init.d/bridge script:
server1:/etc/openvpn# /etc/init.d/bridge start
/etc/init.d/bridge: line 69: syntax error near unexpected token `exit'
/etc/init.d/bridge: line 69: `esac exit 0 '
Any ideas?
Thanks
Good catch
Yes the posting in my tutorial has an error, the "exit 0" at the end of the script should not be present. I must have goofed when I was copying/pasting as my actual operating script does not have this error.
I hope I did not cause you too much grief.
I edited my post above and it should work now. Thanks for the comment, hopefully things work for you now.
vpn server _is firewall
hi geoff -
great site. thanks fo rputting this up. how would your config be different if your vpn server was on the same machine as your firewall?
this has been driving me crazy trying to figure it out.
best,
ed
vpn server is firewall
If I understand you correctly you are wondering how to change the OpenVPN configuration file in this scenario. There are somethings you will need to do:
- You are going to want to have openvpn listen on all interfaces, however you will want the bridge to exist on your internal connection (eth1).
This is due to the fact that your external connection is managed by your Internet providers DHCP server. Once you make the configuration changes so that you are always using eth1 in the bridge and openvpn server.conf things should work.
- You do not need to push a route for the internal network since you have now made the connecting system a member of the internal network.
Honestly I have never tried this so please give this a shot and e-mail me at: geoff@thebakershome.net to let me know how it works. Also I am interested to see how this would run so e-mail me if you have troubles and I will see if I can help you get it working.
I think that what I explained should work but once you test it we can work through to get this running.
For more information see: http://openvpn.net/bridge.html
vpn server is firewall
hi geoff -
thank you for your reply.
my network looks like this:
[ fw / vpn server same machine static IP] <---> internet <---> [ fw / vpn client same machine static IP]
server IP external (static) 33.33.33.1
server IP internal LAN (static) 192.168.0.1
client IP external (static) 34.34.34.1
client IP internal LAN (static) 192.168.1.1
i will do some more reading and let you know what i find out.
best,
ed
Open VPN
oot@openvpn-test:/etc/init.d# ./bridge start
Starting BridgeFri Nov 17 09:41:17 2006 TUN/TAP device tap0 opened
Fri Nov 17 09:41:17 2006 Persist state set to: ON
./bridge: line 30: brctl: command not found
./bridge: line 31: brctl: command not found
./bridge: line 33: brctl: command not found
SIOCSIFADDR: No such device
br0: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device
SIOCSIFBRDADDR: No such device
br0: ERROR while getting interface flags: No such device
br0: ERROR while getting interface flags: No such device
SIOCADDRT: No such device
root@openvpn-test:/etc/init.d#
please tell me what the problem is thanks
Ben
bridge-utils
I will add this to the tutorial but you need to install the bridge -utils package. This will add the bridge interface and the tools to manage it.
sudo apt-get install bridge-utils
Client won't connect, TLS handshake failed
Hi there,
I followed your guide completely (I hope) and get all of the way to the end when connecting but the server log looks like this;
Sun Dec 10 20:31:18 2006 MULTI: multi_create_instance called
Sun Dec 10 20:31:18 2006 121.44.251.128:50024 Re-using SSL/TLS context
Sun Dec 10 20:31:18 2006 121.44.251.128:50024 LZO compression initialized
Sun Dec 10 20:31:18 2006 121.44.251.128:50024 Control Channel MTU parms [ L:1594 D:166 EF:66 EB:0 ET:0 EL:0 ]
Sun Dec 10 20:31:18 2006 121.44.251.128:50024 Data Channel MTU parms [ L:1594 D:1450 EF:62 EB:135 ET:32 EL:0 AF:3/1 ]
Sun Dec 10 20:31:18 2006 121.44.251.128:50024 Fragmentation MTU parms [ L:1594 D:1400 EF:61 EB:135 ET:33 EL:0 AF:3/1 ]
Sun Dec 10 20:31:18 2006 121.44.251.128:50024 Local Options hash (VER=V4): 'b35f3855'
Sun Dec 10 20:31:18 2006 121.44.251.128:50024 Expected Remote Options hash (VER=V4): '29f2fd82'
Sun Dec 10 20:31:18 2006 121.44.251.128:50024 TLS: Initial packet from 121.44.251.128:50024, sid=457c8a72 d1eeba8a
Sun Dec 10 20:31:21 2006 121.44.251.128:50024 VERIFY OK: depth=1, /C=AU/ST=NSW/L=Sydney/O=Nerdforce/CN=server/emailAddress=nick@nerdforce.net
Sun Dec 10 20:31:21 2006 121.44.251.128:50024 VERIFY OK: depth=0, /C=AU/ST=NSW/O=Nerdforce/CN=nick/emailAddress=nick@nerdforce.net
Sun Dec 10 20:31:22 2006 121.44.251.128:50024 TLS Error: Auth Username/Password was not provided by peer
Sun Dec 10 20:31:22 2006 121.44.251.128:50024 TLS Error: TLS handshake failed
Sun Dec 10 20:31:22 2006 121.44.251.128:50024 SIGUSR1[soft,tls-error] received, client-instance restarting
It then just repeats this over and over again.
I have tried using passworded and non-passworded client keys to no avail.
Any suggestions?
Nick
E-mail me
Nick,
I am sorry that it is not working for you. Can you send me your config files for both the server and the client. I will go through them to see if I can see anything.
My e-mail is geoff@thebakershome.net
Also I will look through my logs and see if there is anything there differing from yours that may show an error.
Hopefully we can get this working for you quickly.
I have the same problem
I'm currently experimenting the same problem.. have you found the solution ?
No
Unfortunatly we did not get to a solution since Nick failed to contact me further. Perhaps he found one on his own.
I would suggest repeating the steps in my tutorial (it worked for me) just to make sure you did not miss anything. Otherwise please e-mail me so we can work to fix this.
At the very least if you do find a fix please post a solution to help others.
My email address is: geoff@thebakershome.net
Auth/User Problem
Hi, I had the same Problem while using openvpn under windows. While Linux authenticates itself with the unix account, Windows had its Problems.
My Solution:
I erased the last line of the server.conf
"plugin /usr/lib/openvpn/openvpn-auth-pam.so login"
Worked for me. But on the other hand: there is no further security but the keys. I would like another user/pw authentication. Anybody got an idea how to get that done?
Auth Solution
It seems that your client.conf example is missing the line:
--auth-user-pass
This prompts the client for a username and password to connect to the server with. It works for me so you might want to add it to the tutorial.
Thanks
Thank-you for the great catch. Seems I had added this to my local client.conf files but must have forgotten to put it in my notes. I have added it to the tutorial now. Hopefully others will benefit from your find.
One thing I noticed is that
One thing I noticed is that the section with build-key-pass and build-key are missing the ./ and therefore didn't work for me initially. :)
thanks
Good tip I will make that change
cannot start the bridge
i am trying to put VPN on the firewall&gateway on Ubuntu. did all the steps and the server freezes while staring the bridge. so i went and give the commands from /etc/init.d/bridge script by hand and discovered that on:
ifconfig eth0 0.0.0.0 promisc up
the eth0 interface stops responding and server does not route the connections, i can still login from console...
please help!
Expected
At that point in the script the eth0 interface is not supposed to be working. Consider that point to be the end of the preparation for the bridge.
You need to finish executing the rest of the commands in the bridge script (through the console) in order to get the network running correctly. Also the command needs to be run as root. So to test it simply run (from the console)
sudo /etc/init.d/bridge start
good luck!
unfortunately
i did this. i also reboot the server. and it does not work... i do not know what to do.
the computer has 2 interfaces eth0:192.168.0.200 and eth1:public_ip and i am giving below commands by hand. they execute fine but the connection is lost. what do i do wrong?
openvpn --mktun --dev tap0
ifconfig tap0 0.0.0.0 promisc up
ifconfig eth0 0.0.0.0 promisc up
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 tap0
ifconfig br0 192.168.0.200 netmask 255.255.255.0 broadcast 192.168.0.255 up
route add default gw 192.168.0.200 br0
One problem
I see one problem in the commands you posted. Your gateway needs to be the IP address of your firewall or last point before the internet. Example:
Openvpn Server -> Router -> Internet
192.168.0.200 192.168.0.1 <internet IP>
So your gateway would need to be 192.168.0.1. Does that make sense?
In your case the <public ip> must have a default gateway associated with it. Likely provided via DHCP from your internet provider. So you do not need to provide a default gw since it is provided on the other ethernet port. Test your connection before running that command and see what happens.
Almost there....
Thx for you nice tutorial. well written so even a linux newbie can follow. I do have a question though. Somehow it doesn't create a ta.key file. when i list all files in my key folder there is no ta.key
This is what is says
Thu Feb 1 13:13:15 2007 OpenVPN 2.0.6 i486-pc-linux-gnu [SSL] [LZO] [EPOLL] built on Apr 10 2006
Thu Feb 1 13:13:15 2007 IMPORTANT: OpenVPN's default port number is now 1194, based on an official port number assignment by IANA. OpenVPN 2.0-beta16 and earlier used 5000 as the default port.
Thu Feb 1 13:13:15 2007 Diffie-Hellman initialized with 2048 bit key
Thu Feb 1 13:13:15 2007 Cannot open file key file 'ta.key': No such file or directory (errno=2)
Thu Feb 1 13:13:15 2007 Exiting
i did follow your explaination very closley. I did not include the
plugin /usr/lib/openvpn/openvpn-auth-pam.so login
in my conf file so i dont have so many accounts. if i should please tell me :)
There was a problem i my case and i dont know if it helps other that follow the same road. In the config file it states
"dh /etc/openvpn/openvpn/examples/easy-rsa/keys/dh2048.pem"
there seems an openvpn folder in an openvpn folder which i haven't had. So some people wanna change this.
Your site brought me heaps closer then anything else to vpn on linux. Thx alot for your work greatly appriciated
Ralf
Fixed it..
All i did was opening all ports on my router to my Linux. Anyhow does anyone have an idea on what i have to setup on my my router under the vpn settings? Its a netgear dg834gb. It asks me quite a lot :)
thx
ralf
Perhaps I can guess :)
I do not have a netgear router but have you tried:
1. enabling VPN pass-through
2. Opening port 1194 and forwarding this to your openvpn server?
hope you can get it running.
Problem w. ta.key
I've got the same ta.key file error as above. How do I fix it?
try this
I have not confirmed the exact cause of the ta.key problem being reported, however you can try simply removing the ta.key line from the client and server. That should allow it to work, although it will not have the extra security afforded with the ta.key.
If that temporarily fixes the problem let me know and perhaps we can work to find a permanent solution.
Same problem.
I had exactly the same 'ta.key' error as described above so I included the full path to the file and it gets past that. I was thrown for a bit when creating the bridge script until I remembered to 'chmod' it to make it executable. And, in the paths to the .crt and .key files, your tutorial has the path as '/etc/openvpn/openvpn/..' whereas I only had one mention of openvpn to make the path correct.
I'm still trying to sort an external connection to test it but it looks OK. One thing, though, is that the program is still running from my console. Can't I automate it to run in the background? (Probably very easy answer, still a bit of a linux noob)
Very nice tutorial! Got
Very nice tutorial! Got Openvpn set up on my Ubuntu 6.06 Server and got my Windows XP to connect to it with no problems, and all thanks to this tutorial!
There are some little info you fail to mention, but I figured them out. Things like the openssl package, where the server.conf file is located, and where to put the ta.key. People will figure it out.
server.conf not found
hi Geoff, great guide!
but i stuck halfway as i cannot find the server.conf in the openvpn directory.
Try here
If it is not in /etc/openvpn/ then look in the documentation directory:
/usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz
Just decompress that file and copy it into /etc/openvpn/
now login problem
Hi Geoff,
thanks for the reply I got that done already, now my problem is my windows client cannot logon to the server even though i opened the port in my router and directed to my server, when i try to connect, it keep asking for username and password.
connecting to client has failed
this is the message that i got when i try to logon.
Login?
If it is asking you for a login name and password you need to make sure that you enter the login/pass of a valid account on your openvpn server. i.e. on my server I run Linux, so when I connect from a Windows computer I enter my login/pass for my Linux machine.
Alternatively you could disable authentication and just use the openvpn keys, but this would only be something you should do to test. It is a better security policy to rely on the authentication in combination with the keys.
Problem configuring certificate openvpn
Hi Geoff,
I googled on openvpn installation on ubuntu and hit the narrative that you hav provided. Thanks for a wonderful step by step explanation. I followed exactly all the steps as narrated by you. But when I execute command
openvpn /etc/openvpn/server.conf i get an error of dh2048.pem not found. then i checked the directory in which the folder "keys" is created. It shows me a broken link. I am unable to browse this folder.
I tried running from sudo as well as from su the three primary steps:
. ./vars
./clean-all
./build-ca
but I dont know why this folder that is being created shows a broken link. Do you have any ideas?
Regards,
Harshal
well, I guess Geoff miss
well, I guess Geoff miss this out...
openssl dhparam -out dh1024.pem 1024
I ran this in the "keys" folder (eg. /etc/openvpn/easy-rsa/keys)
I hope it works for you.
client problems
hi, having trouble the client side. Any ideas? I've installed openvpn there and copied over ca.crt user.crt user.key and ta.key. Am i missing something. I dont quite understand how where you say "The other benefit of this network is that you can access your data on your home PC from anywhere" if you have to set all this up on the client side :/ or do i misunderstand?
Wed Oct 3 15:17:29 2007 IMPORTANT: OpenVPN's default port number is now 1194, based on an official port number assignment by IANA. OpenVPN 2.0-beta16 and earlier used 5000 as the default port.
Wed Oct 3 15:17:29 2007 Control Channel Authentication: using '/etc/openvpn/ta.key' as a OpenVPN static key file
Wed Oct 3 15:17:29 2007 LZO compression initialized
Wed Oct 3 15:17:29 2007 UDPv4 link local: [undef]
Wed Oct 3 15:17:29 2007 UDPv4 link remote: xxx.xxx.xxx.xxx:1194
Wed Oct 3 15:18:29 2007 TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity)
Wed Oct 3 15:18:29 2007 TLS Error: TLS handshake failed
Wed Oct 3 15:18:29 2007 SIGUSR1[soft,tls-error] received, process restarting
Hmmm
I think you are misunderstanding some stuff but I am not sure exactly where. OpenVPN provides a secure connection through the internet into your home network or computer systems.
This means you can have a laptop with you at school and connect via the internet using a secure openvpn tunnel to your home network and access files/information from your home networks.
If you have setup openvpn client on your laptop then you can access the data frmo anywhere. I am not sure why the TLS key negotiation failed, however you could try the config in a less secure mode by disabling the TLS just for testing purposes.
Hi, please help =).
Have done everything as the guide told me but when I get this problem:
root@o3h2:/etc/openvpn# /etc/init.d/bridge start
bash: /etc/init.d/bridge: Permission denied
If I deny this and start the server anyway I get the following error when the client has connected:
Fri Oct 26 22:44:58 2007 o3h.net/85.194.56.151:2469 SENT CONTROL [o3h.net]: 'PUS H_REPLY,route-gateway 192.168.1.3,ping 10,ping-restart 120,ifconfig 192.168.1.60 255.255.255.0' (status=1)
Fri Oct 26 22:45:02 2007 o3h.net/85.194.56.151:2469 FRAG_IN error flags=0xfaffff ff: FRAG_TEST not implemented
(Maybe this will fix it self when I can run the bridge script?)
Thank you for a very good guide!!
Please help =)
First off excellent guide.
Have done everything until this:
root@o3h2:/home/o3h# /etc/init.d/bridge start
bash: /etc/init.d/bridge: Permission denied
If I ignore this and start the server and let client connect I get this error in the server:
Fri Oct 26 23:03:20 2007 o3h.net/85.194.56.151:2558 SENT CONTROL [o3h.net]: 'PUSH_REPLY,route-gateway 192.168.1.3,ping 10,ping-restart 120,ifconfig 192.168.1.60 255.255.255.0' (status=1)
Fri Oct 26 23:03:22 2007 o3h.net/85.194.56.151:2558 FRAG_IN error flags=0xfaffffff: FRAG_TEST not implemented
Fri Oct 26 23:03:23 2007 o3h.net/85.194.56.151:2558 FRAG_IN error flags=0xfaffffff: FRAG_TEST not implemented
Fri Oct 26 23:03:24 2007 o3h.net/85.194.56.151:2558 FRAG_IN error flags=0xfaffffff: FRAG_TEST not implemented
Fri Oct 26 23:03:25 2007 o3h.net/85.194.56.151:2558 Bad LZO decompression header byte: 0
Fri Oct 26 23:03:25 2007 o3h.net/85.194.56.151:2558 Bad LZO decompression header byte: 127
Maybe these errors will be fixed if I can start the script?
And I cant for example connect to 192.168.1.3 (the server) from 192.168.1.60 (client).
Thank you.
Make it executable
You need to make the script executable. Basically you need to set the permission flag for the file to enable execution.
To do this enter the directory where the file is located and run.
chmod +x bridge
OK.
It worked. But when I connect with the client it works, but I cant ping any of the ips in my local network.
Server:
Sun Oct 28 21:47:06 2007 o3h.net/85.194.56.151:1607 SENT CONTROL [o3h.net]: 'PUS H_REPLY,route-gateway 192.168.1.3,ping 10,ping-restart 120,ifconfig 192.168.1.60 255.255.255.0' (status=1)
Sun Oct 28 21:47:09 2007 o3h.net/85.194.56.151:1607 FRAG_IN error flags=0xfaffff ff: FRAG_TEST not implemented
Sun Oct 28 21:47:10 2007 o3h.net/85.194.56.151:1607 FRAG_IN error flags=0xfaffff ff: FRAG_TEST not implemented
Client:
Sun Oct 28 21:51:39 2007 Re-using SSL/TLS context
Sun Oct 28 21:51:39 2007 LZO compression initialized
Sun Oct 28 21:51:40 2007 UDPv4 link local: [undef]
Sun Oct 28 21:51:40 2007 UDPv4 link remote: 85.194.56.150:1194
Sun Oct 28 21:51:40 2007 WARNING: 'link-mtu' is used inconsistently, local='link
-mtu 1590', remote='link-mtu 1594'
Sun Oct 28 21:51:40 2007 WARNING: 'mtu-dynamic' is present in remote config but
missing in local config, remote='mtu-dynamic'
Sun Oct 28 21:51:40 2007 [o3h.net] Peer Connection Initiated with 85.194.56.150:
1194
Sun Oct 28 21:51:41 2007 Preserving previous TUN/TAP instance: Anslutning till l
okalt nõtverk 3
Sun Oct 28 21:51:41 2007 Initialization Sequence Completed
Sun Oct 28 21:51:51 2007 Bad LZO decompression header byte: 0
Sun Oct 28 21:52:01 2007 Bad LZO decompression header byte: 0
Sun Oct 28 21:52:11 2007 Bad LZO decompression header byte: 0
Sun Oct 28 21:52:22 2007 Bad LZO decompression header byte: 0
Sun Oct 28 21:52:32 2007 Bad LZO decompression header byte: 0
Sun Oct 28 21:52:43 2007 Bad LZO decompression header byte: 0
Do you have an idea? Thank you.
Wow!
I honestly have no clue what is happening there. If you wish you could send me your config files in an e-mail (geoff@thebakershome.net) and I can see if I can help.
question about this setup
Geoff,
Your article works wonders. I'm setup. Only then I realized one fatal flaw.
When I connect from to my home network vpn, it usually assigns an ip betweek 192.168.1.50 and 1.60.
I imagine this failing in epic proportions if im on another network with the same network (standard linksys)
Is it possible to make the vpn network a separate one?
Thanks,
Bez
Yes
Yes you are correct, if you connect from a network where your IP address is in the same subnet as the one your home VPN assigns then you will not be able to connect. The only way around this is to use a different subnet for your home network then the remote network.
This is not a perfect solution but it is the only method that I know of.
Thanks a lot
Thanks a lot for your tutorial. I got everything working with only a few minor hitches along the way. I got the same LTS error that people above were reporting, since the client I'm using is OpenVPN GUI for Windows. I fixed that error by adding auth-user-pass to my client configuration file.
It does work in the sense that I can see all of my machines on my home network when logged on through the VPN, but any traffic that isn't explicitly targeted to one of these machines is going out unencrypted. It's desirable for all traffic to flow out through the encrypted VPN connection when using, say, publicly accessible WiFi. So I'm wondering, would it make sense to add something to the tutorial on how to force all traffic through the VPN for these kinds of situations?
Thanks once again.
Simple to do
Well if you did desire to route all traffic through the openvpn connection you simply need to modify your client.
# setup system to route all traffic through openvpn server
redirect-gateway def1
dhcp-option DNS <insert your home DNS IP Here>
This is expecially useful when you are on an unencrypted wireless network and you want to protect your private information (at least as much as surfing at home would protect)
Issue with server port setting
Couldn't see this addressed already, so thought I would point out the sample server configuration file has the port statement on the same line as the local ip address. This doesn't cause an error, but if you change the port #, the change is ignored and the default port (1194) is use. Just need to move the port statement to its own line.
Current:
local x.x.x.x port 1194
Correct:
local x.x.x.x
port 1194
Thanks for a great HOW-TO
Thanks
Thank-you for the tip, I will make a change to the tutorial.
Hi, i have this problem with
Hi, i have this problem with the client:
Thu Feb 14 17:48:15 2008 Cannot load private key file client.key: error:0906D06C:PEM routines:PEM_read_bio:no start line: error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib
Thu Feb 14 17:48:15 2008 Error: private key password verification failed
Thu Feb 14 17:48:15 2008 Exiting
What can i do?
Thanks
odd error
I would try regenerating the client keys and then ensure that you copy them to the client correctly. (Use an MD5 sum to confirm the data copies correctly)
Cannot ping anything but the server...
Thanks for the great tutorial Geoff! I have, however, stumbled onto a problem I would like to ask for your help on. To the best of my knowledge I have my OpenVPN server configured identical to your tutorial on a clean install of Fedora 6. From my WinXP clients (the only ones I have) I can establish a connection fine, and also ping the server, but I don't seem to be able to ping any other devices on the remote network. I have tried from two different clients at two different locations with the same results each time. Any idea what i've done wrong?
Thank you!