L2TP over IPSec is available in MAC OS X, and is very stable in Ventura with OpenBSD server. However, if your network is in the same subnet as the remote network you’re reaching with the VPN is tricky. Let me try to explain:
me (with home network 192.168.1.0/24) —- L2TP VPN with IP 10.0.0.2 —– Internet —— Office L2TP VPN with 10.0.0.1 gateway —- Office network 192.168.1.0/24 {some machines you want to reach 192.168.1.9 and 192.168.1.124 for example}
Now, when you establish the VPN, you can ping 10.0.0.1 from your laptop at home, but you can not ping 192.168.1.9 on the other side of the VPN (my office network).
The easiest way is to add these routes in the point-to-point config in Mac OS.
1. Open a shell and go to /etc/ppp directory
# cd /etc/ppp
2. Create a file called ip-up with:
# sudo nano ip-up
3. Put inside these additional routings you want to pop-up when you establish the VPN:
#!/bin/sh
/sbin/route add 192.168.1.116/32 -interface ppp0
/sbin/route add 192.168.1.117/32 -interface ppp0
/sbin/route add 192.168.1.124/32 -interface ppp0
4. Exit and save.
Now, when a VPN is setup, these 3 routes 192.168.1.116, .117, .124 will be available thru the VPN interface ppp0 (the default in Mac Os X).
How easy it is to make an OpenBSD L2TP VPN server? Very easy, just need to touch three files 🙂
Let’s first enable IPSEC and ISAKMPD on the OpenBSD box:
# rcctl enable ipsec
# rcctl enable isakmpd
# rcctl set isakmpd flags -K
In OpenBSD 7.2, all you need to do is:
1. In /etc/npppd folder open the npppd-users file and add:
dilyan:\
:password=123456:
This will add user “dilyan” with password “123456”
2. In the same directory, you need to to touch the npppd.conf file to configure DNS, IP addresses and listening ports, etc:
authentication LOCAL type local {
users-file “/etc/npppd/npppd-users”
}
tunnel L2TP protocol l2tp {
listen on 0.0.0.0
listen on ::
}
ipcp IPCP {
pool-address 10.0.0.2-10.0.0.254
dns-servers 192.168.1.9 8.8.8.8
}
interface pppx0 address 10.0.0.1 ipcp IPCP
bind tunnel from L2TP authenticated by LOCAL to pppx0
—
with this basically we’re saying – listen on the host for IPv4 and v6, have a gateway address of 10.0.0.1, assign to the coming connections addresses from 10.0.0.2 till 254, and use DNSs 192.168.1.9 and 8.8.8.8.
3. The last is to touch /etc/ipsec.conf with adding the following text:
ike passive esp tunnel from X.Y.Z.Q to any \
main group “modp1024” \
quick group “modp1024” \
psk “0987654”
where X.Y.Z.Q is the public IP address of the VPN server, and 0987654 is the password for the tunnel (the shared secret).
In Mac OS X, the L2TP over IPSec is in the default VPN configurations (System Setting -> VPN -> Add VPN Configuration), add the server address (the X.Y.Z.Q from the step above), user authorization is “Password” and put the 123456 from the npppd configuration, the Machine Authentication shall be chose as “Shared Secret” and is the 0987654 one you put in ipsec.conf. Voila.
More details in the OpenBSD FAQ: https://www.openbsd.org/faq/faq17.html