|For an overview over all existing Virtual private network (VPN)-related articles in the OpenWrt wiki, please visit vpn.overview|
For all those people who want to use openswan for a site to site connection here are the gory details…
In our office environment we use Centos on many of our internet faceing servers. In RedHat Enterprise Linux 5 the IPsec implementation was provided by racoon (KAME), userland tools, and NETKEY in the kernel. We set up our six office WAN using this and when it's up and running it seems to be stable, however adding a new site to the WAN seems to require reseting all of the IPsec server accross the WAN. This can be accomplished by killing off the racoon service and starting it again. This is not particularly helpfull. RedHat have decided to move to openswan for their Enterprise Linux 6 release as the default IPsec implementation using pluto for the userland tools but keeping with NETKEY for the kernel stack. We are now in the process of migrating all our IPsec VPN connections to Centos 6.x.
IPsec Linux Journal IPsec article A good explanation IPsec implementations in linux. A good grounding on openSwan and openVPN with discussion about the two kernel stacks KLIPS and NETKEY as well as the userland tools pluto (openswan) and racoon (KAME). Note KLIPS is used in openWRT and NETKEY is used in RHEL 6.x / CENTOS 6.x the pecularities of this are discussed later.
You need to install the openswan package
yum install openswan
Use the graphical package manager to install openswan
from the command prompt using opkg
# opkg install openswan
Edit /etc/ipsec.conf file and add this to the bottom of the file. ( You may only have to uncomment the line )
Edit /etc/ipsec.secrets file and add this to the bottom of the file.
These two lines allow you to create separate configuration and secret files in the /etc/ipsec.d/ directory for each connection.
By convention it makes sense to name these files :-
Connecting two private networks opens an interesting DNS challenge. The ACME DNS server does not only resolve official server names to IP addresses but also those of ACME internal servers. E.g. hobbit.acme.inc and its IP 10.1.2.42. As we have established a VPN connection we already can reach this host by its address. To get it by its name too we have to offer a name resolution in our home domain. With OpenWrt being very powerful we assume that our router has an active Dnsmasq DNS server. So we have two possibilities to resolve acme.inc addresses.
DNS fowarding through VPN tunnels is almost the same as normal DNS forwarding with one exception. Dnsmasq must use the correct source interface. By default it will use the OpenWrt internet IP for it's requests but this cannot be tunneled. So just expand the Dnsmasq forward settings in LuCI with the OpenWrt internal IP address. In our scenario we wan't to reach ACME DNS at 10.1.2.250 by using our internal IP 192.168.2.82. Don't forget to add this domain on the whitelist otherwise Dnsmasq will detect rebind attacks and discard requests.
To enable/disable start on boot:
/etc/init.d/ipsec enable this simply creates a symlink:
/etc/rc.d/S60ipsec → /etc/init.d/ipsec
/etc/init.d/ipsec disable this removes the symlink again
If you are having problems getting the IPsec stuff to work try dropping the firewalls
Try `iptables -h' or 'iptables --help' for more information.then bla bla bla
# ping -I <local internal interface | local internal ip> <remote internal ip> # tcpdump -i <external interface> # tcpdump -i <internal interface> # ipsec look <connection name> # ipsec auto --add <connection name> # ipsec auto --up <connection name> # ipsec auto --down <connection name> # ipsec auto --delete <connection name> # route # ifconfig # ip xfrm policy # ip xfrm state