Last active
October 3, 2022 12:59
-
-
Save ram0973/272f0c60ecf1f7b31e566c4255448934 to your computer and use it in GitHub Desktop.
Iptables rules for IPSEC IKEV2 VPN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
iptables -A INPUT -m state --state NEW -p tcp --dport 22 -j ACCEPT # SSH | |
iptables -A INPUT -p udp --dport 500 -j ACCEPT # for ISAKMP (handling of security associations) | |
iptables -A INPUT -p udp --dport 4500 -j ACCEPT # for NAT-T (handling of IPsec between natted devices) | |
iptables -A INPUT -p 50 -j ACCEPT # ESP - IP port 50 for ESP payload (the encrypted data packets) | |
iptables -A INPUT -j DROP | |
# Protect from trafic routing outside (WAN). Use outer interface here if any | |
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT | |
#iptables -A FORWARD -j REJECT | |
iptables -t nat -A POSTROUTING -j MASQUERADE | |
#iptables -t nat -A POSTROUTING -m policy --pol ipsec --dir out -j MASQUERADE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment