Created
July 14, 2014 20:36
-
-
Save reox/cd5f0a53c6f5e7de2c40 to your computer and use it in GitHub Desktop.
ipv6 firewall script
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
if [ "$1" = "--reset" ]; then | |
ip6tables -F INPUT | |
ip6tables -F FORWARD | |
ip6tables -F OUTPUT | |
ip6tables -P INPUT ACCEPT | |
ip6tables -P OUTPUT ACCEPT | |
ip6tables -P FORWARD ACCEPT | |
else | |
# Disable processing of any RH0 packet | |
# Which could allow a ping-pong of packets | |
ip6tables -A INPUT -m rt --rt-type 0 -j DROP | |
ip6tables -A OUTPUT -m rt --rt-type 0 -j DROP | |
ip6tables -A FORWARD -m rt --rt-type 0 -j DROP | |
ip6tables -A OUTPUT -o wlan0 -j ACCEPT | |
ip6tables -A OUTPUT -o eth0 -j ACCEPT | |
ip6tables -A INPUT -i wlan0 -m state --state ESTABLISHED,RELATED -j ACCEPT | |
ip6tables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT | |
# Allow anything on the local link | |
ip6tables -A INPUT -i lo -j ACCEPT | |
ip6tables -A OUTPUT -o lo -j ACCEPT | |
# Allow Link-Local addresses | |
ip6tables -A INPUT -s fe80::/10 -j ACCEPT | |
ip6tables -A OUTPUT -s fe80::/10 -j ACCEPT | |
# Allow multicast | |
ip6tables -A INPUT -d ff00::/8 -j ACCEPT | |
ip6tables -A OUTPUT -d ff00::/8 -j ACCEPT | |
# Allow ICMP | |
ip6tables -A INPUT -p icmpv6 -j ACCEPT | |
ip6tables -A OUTPUT -p icmpv6 -j ACCEPT | |
# Disable privileged ports for the outside | |
ip6tables -A INPUT -p tcp --dport 1:65535 -j REJECT | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
quick and dirty... you probably want to make it better ;)