As an experienced technical person I am not afraid to admit when I don’t know something. But, I also have the confidence and determination to say that I can/will figure something out. Well, one of my personal projects that was half-finished was the setup of a functioning IPCop proxy with a working OpenVPN connection.
I wanted to install the most recent version of IPCop that was available for download. But, I needed the ability to use the IPCop server as a VPN server as well. It turns out if you edit the install bash script for ZERINA and comment out the version check below you are able to install ZERINA(OpenVPN) on any version of IPCop that you would like.
#if [ ! "`echo $IPCOPVERSION | grep "1.4.15"`" ] ; then
# echo
# echo “ERROR: This ZERINA addon only works with IPCop 1.4.15!\n”
# echo “Sorry. Please update your IPCop – visit www.ipcop.org!\n”
# echo “”
# exit 1
#fi
The next step after installing ZERINA (OpenVPN) for IPCop was ensuring my routing was correct. So I ran the command below to check my routes.
netstat -rn
I will not go into much detail here other than to say that OpenVPN has its own routes that it will add automatically once the OpenVPN server is enabled. These routes added by OpenVPN are listed below and will disappear if the OpenVPN server is disabled. The IP addresses below may vary depending on the IP range you entered for the VPN.
192.168.2.2 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
192.168.2.0 192.168.2.2 255.255.255.0 UG 0 0 0 tun0
You will need to add custom routes that are not shown above in order to reach different subnets within your network. I have included the command below as an example to aid you.
route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.1.1 eth0
If you intend for your routes to exist after a reboot you need to add them to the end of the rc.netaddresses.up with is located in /etc/rc.d/rc.netaddresses.up. Each one of the routes below signify networks that need to be reached.
route add -net 192.168.3.0/24 gw 192.168.1.1
route add -net 192.168.4.0/24 gw 192.168.1.1
Once I had everything installed and ready to go I issued the VPN certificates, downloaded them off the IPCop/OpenVPN server and put them on my Mac. I was able to successfully connect to the VPN and reach the IPCop interface but I wasn’t able to reach anything else on the internal network. I happened to stumble across a command that was my saving grace.
iptables -t nat -A CUSTOMPOSTROUTING -s 192.168.2.0/24 -o eth0 -j MASQUERADE
In order to avoid any confusion “CUSTOMPOSTROUTING” is suppose to be used literally in the command. You do not need to change it to an IP address. It is a way to identify unique custom added routes. Also, etho is ethernet zero as in the first interface available for use on this sever. The font is a little misleading.
I hope this helps someone in their efforts to understand how OpenVPN works. I believe my next step will be to attempt setting up my own OpenVPN server from scratch. I have done it many times in the past but never got the routing to work correctly. But, with the MASQUERADE command above I believe that I should be able to make it work correctly.