- Make sure that you have at least one tunnel device compiled into
the kernel on both gw1 and gw2. In particular you want to make sure
your kernel config has the following:
pseudo-device tun 1
If you're going to have multiple vpns (perhaps the office server will provide
vpns for multiple employee's home networks) then you should increase 1
to something larger. Build the new kernel, install it, and make the devices.
- Install the pipsecd
port on both machines. FreeBSD-3.4 will also install OpenSSL, 4.0 won't since
it's already there. Nothing special needs to be done besides a "make install".
- On gw1 create /usr/local/etc/rc.d/pipsecd.sh with
the following:
#!/bin/sh
/usr/local/sbin/pipsecd &
#
# For some reason 4.0 complains if we access the tun device
# to soon after calling pipsecd. Sleeping for a bit fixes that.
#
sleep 3
/sbin/ifconfig tun0 10.2.0.1 10.2.0.2 netmask 255.255.255.0
/sbin/route add -net 10.1.0.0 -netmask 255.255.255.0 10.2.0.2
- On gw2 create /usr/local/etc/rc.d/pipsecd.sh with
the following:
#!/bin/sh
/usr/local/sbin/pipsecd &
#
# For some reason 4.0 complains if we access the tun device
# to soon after calling pipsecd. Sleeping for a bit fixes that.
#
sleep 3
/sbin/ifconfig tun0 10.2.0.2 10.2.0.1 netmask 255.255.255.0
/sbin/route add -net 10.0.0.0 -netmask 255.255.255.0 10.2.0.1
- On gw1 create /usr/local/etc/ipsec/pipsecd.conf with
the following. 'CCCCC', 'DDDDD', 'AAAAA', 'BBBBB' can be changed to any string of
characters consisting of valid hex (ie. 0123456789ABCDEF) as long as you change them in both files.
sa ipesp spi=1000 auth=hmac-md5-96 akey=CCCCC enc=blowfish_cbc ekey=AAAAA dest=222.222.222.222
sa ipesp spi=1000 auth=hmac-md5-96 akey=DDDDD enc=blowfish_cbc ekey=BBBBB
if /dev/tun0 local_spi=1000 remote_spi=1000
- On gw2 create /usr/local/etc/ipsec/pipsecd.conf with
the following:
sa ipesp spi=1000 auth=hmac-md5-96 akey=CCCCC enc=blowfish_cbc ekey=AAAAA
sa ipesp spi=1000 auth=hmac-md5-96 akey=DDDDD enc=blowfish_cbc ekey=BBBBB dest=111.111.111.111
if /dev/tun0 local_spi=1000 remote_spi=1000
- That's it. Now, on both machines, start pipsecd by typing (as root):
sh /usr/local/etc/rc.d/pipsecd.sh
- At this point machines on either LAN should be able to connect to machines
on the other LAN -- that is, host 10.0.0.2 should be able to ping 10.1.0.2
provided that they are both on.
For some reason the gateways themselves will not be able to talk to each
other. When I setup my first VPN they could, but I must have changed
something by accident and now they can't. But it's not that big of a
deal because you shouldn't be connecting from/to your gateways very much
anyway.