Created
June 11, 2021 04:41
-
-
Save nikolaybotev/22e35386531473f8e42c817f3d435145 to your computer and use it in GitHub Desktop.
Router Firewall Configuration (iptables)
This file contains hidden or 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
UPSTREAM_IFACE="${1:-eth1}" | |
# IPv4 and IPv6 | |
for iptables in iptables ip6tables; do | |
# :INPUT | |
# - returning traffic | |
sudo $iptables -A INPUT -i $UPSTREAM_IFACE -m state --state ESTABLISHED,RELATED -j ACCEPT | |
# - ping | |
sudo $iptables -A INPUT -i $UPSTREAM_IFACE -p icmp -j ACCEPT | |
# - ssh | |
sudo $iptables -A INPUT -i $UPSTREAM_IFACE -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT | |
# - or drop | |
sudo $iptables -A INPUT -i $UPSTREAM_IFACE -j DROP | |
# :FORWARD | |
# - returning traffic | |
sudo $iptables -A FORWARD -i $UPSTREAM_IFACE -m state --state ESTABLISHED,RELATED -j ACCEPT | |
# - or drop | |
sudo $iptables -A FORWARD -i $UPSTREAM_IFACE -j DROP | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Review config using: