Skip to content

Commit 7711c31

Browse files
dguidoclaude
andcommitted
Fix WireGuard handshake timeout by allowing VPN traffic on veth
The namespace test was timing out because the firewall was blocking UDP traffic on the veth interface. This adds explicit INPUT rules to allow WireGuard (51820) and IPsec (500, 4500) traffic. Also refines the MASQUERADE rule to not apply to bridge-local traffic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent e9acb12 commit 7711c31

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

tests/e2e/test-vpn-connectivity.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ cleanup() {
5959
ip netns exec "${NAMESPACE}" ipsec stroke down-nb "algovpn" 2>/dev/null || true
6060
ip netns exec "${NAMESPACE}" ipsec stop 2>/dev/null || true
6161

62-
# Remove NAT rule we added
63-
iptables -t nat -D POSTROUTING -s "${CLIENT_BRIDGE_IP}/32" -j MASQUERADE 2>/dev/null || true
62+
# Remove firewall rules we added
63+
iptables -t nat -D POSTROUTING -s "${CLIENT_BRIDGE_IP}/32" ! -d 10.99.0.0/24 -j MASQUERADE 2>/dev/null || true
64+
iptables -D INPUT -i "${VETH_SERVER}" -p udp --dport 51820 -j ACCEPT 2>/dev/null || true
65+
iptables -D INPUT -i "${VETH_SERVER}" -p udp --dport 500 -j ACCEPT 2>/dev/null || true
66+
iptables -D INPUT -i "${VETH_SERVER}" -p udp --dport 4500 -j ACCEPT 2>/dev/null || true
6467

6568
# Delete namespace (also removes veth pair)
6669
ip netns del "${NAMESPACE}" 2>/dev/null || true
@@ -116,8 +119,13 @@ setup_namespace() {
116119
# Enable forwarding on the server for NAT
117120
sysctl -w net.ipv4.ip_forward=1 > /dev/null
118121

119-
# Add MASQUERADE for the client namespace traffic
120-
iptables -t nat -A POSTROUTING -s "${CLIENT_BRIDGE_IP}/32" -j MASQUERADE
122+
# Add MASQUERADE for the client namespace traffic going to external networks
123+
iptables -t nat -A POSTROUTING -s "${CLIENT_BRIDGE_IP}/32" ! -d 10.99.0.0/24 -j MASQUERADE
124+
125+
# Allow WireGuard and IPsec traffic on the veth interface
126+
iptables -A INPUT -i "${VETH_SERVER}" -p udp --dport 51820 -j ACCEPT
127+
iptables -A INPUT -i "${VETH_SERVER}" -p udp --dport 500 -j ACCEPT
128+
iptables -A INPUT -i "${VETH_SERVER}" -p udp --dport 4500 -j ACCEPT
121129

122130
log_info "Namespace ${NAMESPACE} created with IP ${CLIENT_BRIDGE_IP}"
123131

0 commit comments

Comments
 (0)