Configure IPSec VPN Gateway to Connect to External Systems using Strongswan
net.ipv4.ip_forward = 1 net.ipv6.conf.all.forwarding = 1sudo sysctl --system
sudo apt install strongswan libcharon-extra-plugins libcharon-extauth-plugins libstrongswan-extra-pluginssudo cp /etc/ipsec.conf /etc/ipsec.conf.origconfig setup charondebug="all" uniqueids=yes conn openg2p-to-external-vpn type=tunnel auto=start keyexchange=ikev2 authby=psk # Phase 1 ike=aes256-sha256-ecp521 ikelifetime=28800s # Phase 2 esp=aes256-sha256-ecp256 lifetime=3600s aggressive=no keyingtries=%forever rekeymargin=3m left=10.10.0.15 leftsubnet=10.10.0.15/32 leftid=3.10.x.x right=4.10.y.y rightsubnet=192.168.0.0/24 rightid=4.10.y.y dpddelay=30s dpdtimeout=120s dpdaction=restart10.10.0.15 4.10.y.y : PSK "<PSK Value>"sudo systemctl enable ipsec sudo systemctl start ipsecsudo ipsec statusall
sudo apt install iptables-persistentsudo iptables -P FORWARD DROPsudo iptables -A FORWARD -o <primary_network_interface_name> -s <10.10.node1.internalip> -j ACCEPT sudo iptables -A FORWARD -i <primary_network_interface_name> -d <10.10.node1.internalip> -j ACCEPT sudo iptables -A FORWARD -o <primary_network_interface_name> -s <10.10.node2.internalip> -j ACCEPT sudo iptables -A FORWARD -i <primary_network_interface_name> -d <10.10.node2.internalip> -j ACCEPTsudo iptables -A POSTROUTING -t nat -o <primary_network_interface_name> -j MASQUERADEsudo bash -c 'iptables-save > /etc/iptables/rules.v4'
sudo ip route add 192.168.0.0/24 via 10.10.0.15
Last updated
Was this helpful?

