iptables rules to allow access to 192.168.0.0/24 subnet from 198.51.100.2 IP address.

979 B · 19 lines · Created 1mo ago

PostUp = sysctl -w net.ipv4.ip_forward=1
PostUp = iptables -N WIREGUARD_wg0
PostUp = iptables -A FORWARD -j WIREGUARD_wg0
PostUp = iptables -A WIREGUARD_wg0 -o %i -d 198.51.100.0/24 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
PostUp = iptables -A WIREGUARD_wg0 -i %i -s 198.51.100.0/24 -d 192.168.0.0/24 -j ACCEPT
PostUp = iptables -A WIREGUARD_wg0 -i %i -o enp37s0 -j ACCEPT
PostUp = iptables -A WIREGUARD_wg0 -i %i -j DROP
PostUp = iptables -t nat -A POSTROUTING -s 198.51.100.0/24 -o enp37s0 -j MASQUERADE
PostUp = iptables -t mangle -A FORWARD -i %i -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

PostDown = iptables -D FORWARD -j WIREGUARD_wg0
PostDown = iptables -F WIREGUARD_wg0
PostDown = iptables -X WIREGUARD_wg0
PostDown = iptables -t nat -D POSTROUTING -s 198.51.100.0/24 -o enp37s0 -j MASQUERADE
PostDown = iptables -t mangle -D FORWARD -i %i -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
Sign up or Sign in to add to the discussion.