Peters School of Business · Assiniboine College · NETW-0014
2 hours · Lab 5B · ipsec.secrets, ipsec.conf, NAT exclusion, SA verification, tcpdump
Lab 5B — Install StrongSwan, configure PSK VPN, verify SA and encrypted traffic
Part 1 — Install StrongSwan on S1 and S3 (10 min)
sudo apt install strongswan. Verify the service is installed: sudo ipsec version. The key packages installed alongside: libstrongswan, strongswan-charon (the IKE daemon), strongswan-starter.Part 2 — Configure ipsec.secrets (15 min)
/etc/ipsec.secrets. Add one line (replace IPs with actual external IPs):
[S1-External-IP] [S3-External-IP] : PSK "Room225!"
[S3-External-IP] [S1-External-IP] : PSK "Room225!"
Part 3 — Configure ipsec.conf (25 min)
/etc/ipsec.conf. Add a connection definition after the config setup section:
conn S1_to_S3
authby=secret
left=[S1-External-IP]
leftsubnet=192.168.50.0/24
right=[S3-External-IP]
rightsubnet=192.168.51.0/24
ike=aes256-sha2_256-modp1024!
esp=aes256-sha2_256!
keyingtries=0
ikelifetime=1h
lifetime=8h
dpddelay=30
dpdtimeout=120
dpdaction=restart
auto=start
conn S3_to_S1
authby=secret
left=[S3-External-IP]
leftsubnet=192.168.51.0/24
right=[S1-External-IP]
rightsubnet=192.168.50.0/24
Part 4 — NAT exclusion rule (15 min)
sudo iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -t nat -A POSTROUTING -s 192.168.50.0/24 ! -d 192.168.51.0/24 -o eth0 -j MASQUERADE
ping 8.8.8.8 from S2 — should succeed (internet traffic is still masqueraded; only S3's LAN is excluded).Part 5 — Start ipsec and verify (25 min)
sudo ipsec restart
sudo ipsec status
Security Associations (1 up, 0 connecting) followed by the SA details including the cipher suite and subnet selectors.
ping 192.168.51.2 (or whatever S3's LAN address is)
sudo tcpdump -i eth0 -n esp
Learning outcomes — by end of Day 2, students can…
Common issues and fixes
| Issue | Likely cause | Fix |
|---|---|---|
| ipsec status shows 0 SAs after restart | PSK mismatch, wrong IPs in ipsec.conf, or firewall blocking UDP 500 | Check syslog: sudo grep charon /var/log/syslog | tail -30. Common messages: "no proposal chosen" (cipher mismatch), "authentication failed" (PSK wrong), "peer not responding" (firewall/connectivity) |
| S2 cannot ping S3's LAN even with SA up | NAT exclusion rule not applied, or applied on wrong interface | Check: sudo iptables -t nat -L POSTROUTING -n. The rule must show ! -d 192.168.51.0/24. Also verify S3 has the matching exclusion for its MASQUERADE rule |
| S2 loses internet access after NAT exclusion rule | Exclusion rule syntax error — may be excluding all traffic | Check: from S2, ping 8.8.8.8. If failing, verify the ! -d syntax is correct. The ! must precede -d, not -s |