I have a server which I VPN into using strongswan with a IKEv2 setup and it works as expected. This setup assigns my client machine a IP in the 10.10.10.0/24
range. What I'd like to be able to do is open all ports to the server from clients connected to it via VPN. Is something like this possible? Can I write a rule that targets everything coming from a VPN client?
Here's my current set of iptables.rules
:
*filter
# default policies
-P INPUT DROP
-P OUTPUT ACCEPT
-P FORWARD DROP
# established connections keep working
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
# connections from loopback are accepted
-A INPUT -i lo -j ACCEPT
# invalid requests
-A INPUT -m state --state INVALID -j DROP
# sshd
-A INPUT -p tcp --dport 22 -j ACCEPT
# ikev2/ipsec
-A INPUT -p udp -m udp --dport 500 -j ACCEPT
-A INPUT -p udp -m udp --dport 4500 -j ACCEPT
# pings
-A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
-A INPUT -p icmp --icmp-type echo-request -j ACCEPT
# forward VPN traffic anywhere
-A FORWARD -s 10.10.10.0/24 -m policy --dir in --pol ipsec --proto esp -j ACCEPT
-A FORWARD -d 10.10.10.0/24 -m policy --dir out --pol ipsec --proto esp -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-unreachable
-A FORWARD -j REJECT --reject-with icmp-host-unreachable
COMMIT
*mangle
# reduce MTU/MSS values for dumb VPN clients
-A FORWARD -s 10.10.10.0/24 -o eth0 -p tcp -m policy --dir in --pol ipsec -m tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1361:1536 -j TCPMSS --set-mss 1360
COMMIT
*nat
# masquerade VPN traffic over eth0
-A POSTROUTING -s 10.10.10.0/24 -o eth0 -m policy --dir out --pol ipsec -j ACCEPT
-A POSTROUTING -s 10.10.10.0/24 -o eth0 -j MASQUERADE
COMMIT