X-Git-Url: https://git.distorted.org.uk/~mdw/firewall/blobdiff_plain/eb4cb6714854decd932f1a495794cd70139fb151..0291d6d55d3dc38a12d61abc007dda5cc3aa5110:/classify.m4 diff --git a/classify.m4 b/classify.m4 index 148a72f..27eb376 100644 --- a/classify.m4 +++ b/classify.m4 @@ -67,7 +67,7 @@ clearchain mangle:local-source ## Packets over the loopback interface are automatically trusted. All manner ## of weird stuff happens on lo, and it's best not to second-guess it. -run iptables -t mangle -A in-classify -i lo -j ACCEPT +run ip46tables -t mangle -A in-classify -i lo -j ACCEPT ## Local bootp packets have bizarre addresses. Don't block them just because ## of this. @@ -83,9 +83,15 @@ run iptables -t mangle -A local-source -j RETURN \ -m addrtype --dst-type BROADCAST run iptables -t mangle -A local-source -j RETURN \ -m addrtype --dst-type MULTICAST -run iptables -t mangle -A local-source -g bad-source-address +run ip6tables -t mangle -A local-source -j RETURN \ + -d ff00::/8 +run ip46tables -t mangle -A local-source -g bad-source-address run iptables -t mangle -A in-classify -j local-source \ -m addrtype --src-type LOCAL +for addr in $host_6addrs; do + run ip6tables -t mangle -A in-classify -j local-source \ + -s $addr +done m4_divert(41)m4_dnl ## Define the important networks. @@ -97,7 +103,7 @@ done m4_divert(46)m4_dnl ## Mark addresses reachable on non-default interfaces as not reachable on the ## default interface. -trace "nets = $allnets" +trace "nets = $allnets $allnets6" for net in $allnets; do case $net in "$defaultiface":*) @@ -108,6 +114,16 @@ for net in $allnets; do ;; esac done +for net in $allnets6; do + case $net in + "$defaultiface":*) + ;; + *) + run ip6tables -t mangle -A in-$defaultiface \ + -s ${net#*:} -g bad-source-address + ;; + esac +done ## Fill in the black holes in the network. for addr in \ @@ -116,17 +132,23 @@ for addr in \ do run iptables -t mangle -A in-default -s $addr -g bad-source-address done +for addr in \ + fc00::/7 \ + 2001:0db8::/32 +do + run ip6tables -t mangle -A in-default -s $addr -g bad-source-address +done m4_divert(92)m4_dnl ## Put the final default decision on the in-default chain, and attach the ## classification chains to the PREROUTING hook. -run iptables -t mangle -A in-$defaultiface -g mark-from-$defaultclass -run iptables -t mangle -A PREROUTING -j in-classify -run iptables -t mangle -A PREROUTING -j out-classify +run ip46tables -t mangle -A in-$defaultiface -g mark-from-$defaultclass +run ip46tables -t mangle -A PREROUTING -j in-classify +run ip46tables -t mangle -A PREROUTING -j out-classify ## Now it's safe to let stuff through. for i in PREROUTING INPUT FORWARD OUTPUT POSTROUTING; do - run iptables -t mangle -P $i ACCEPT + run ip46tables -t mangle -P $i ACCEPT done m4_divert(-1)