Scott Baker | 761e106 | 2016-06-20 17:18:17 -0700 | [diff] [blame^] | 1 | # |
| 2 | # rules.before |
| 3 | # |
| 4 | # Rules that should be run before the ufw command line added rules. Custom |
| 5 | # rules should be added to one of these chains: |
| 6 | # ufw6-before-input |
| 7 | # ufw6-before-output |
| 8 | # ufw6-before-forward |
| 9 | # |
| 10 | |
| 11 | # Don't delete these required lines, otherwise there will be errors |
| 12 | *filter |
| 13 | :ufw6-before-input - [0:0] |
| 14 | :ufw6-before-output - [0:0] |
| 15 | :ufw6-before-forward - [0:0] |
| 16 | # End required lines |
| 17 | |
| 18 | |
| 19 | # allow all on loopback |
| 20 | -A ufw6-before-input -i lo -j ACCEPT |
| 21 | -A ufw6-before-output -o lo -j ACCEPT |
| 22 | |
| 23 | # drop packets with RH0 headers |
| 24 | -A ufw6-before-input -m rt --rt-type 0 -j DROP |
| 25 | -A ufw6-before-forward -m rt --rt-type 0 -j DROP |
| 26 | -A ufw6-before-output -m rt --rt-type 0 -j DROP |
| 27 | |
| 28 | # for stateless autoconfiguration (restrict NDP messages to hop limit of 255) |
| 29 | -A ufw6-before-input -p icmpv6 --icmpv6-type neighbor-solicitation -m hl --hl-eq 255 -j ACCEPT |
| 30 | -A ufw6-before-output -p icmpv6 --icmpv6-type neighbor-solicitation -m hl --hl-eq 255 -j ACCEPT |
| 31 | -A ufw6-before-input -p icmpv6 --icmpv6-type neighbor-advertisement -m hl --hl-eq 255 -j ACCEPT |
| 32 | -A ufw6-before-output -p icmpv6 --icmpv6-type neighbor-advertisement -m hl --hl-eq 255 -j ACCEPT |
| 33 | -A ufw6-before-input -p icmpv6 --icmpv6-type router-solicitation -m hl --hl-eq 255 -j ACCEPT |
| 34 | -A ufw6-before-input -p icmpv6 --icmpv6-type router-advertisement -m hl --hl-eq 255 -j ACCEPT |
| 35 | |
| 36 | # quickly process packets for which we already have a connection |
| 37 | -A ufw6-before-input -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT |
| 38 | -A ufw6-before-output -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT |
| 39 | -A ufw6-before-forward -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT |
| 40 | |
| 41 | # for multicast ping replies from link-local addresses (these don't have an |
| 42 | # associated connection and would otherwise be marked INVALID) |
| 43 | -A ufw6-before-input -p icmpv6 --icmpv6-type echo-reply -s fe80::/10 -j ACCEPT |
| 44 | |
| 45 | # drop INVALID packets (logs these in loglevel medium and higher) |
| 46 | -A ufw6-before-input -m conntrack --ctstate INVALID -j ufw6-logging-deny |
| 47 | -A ufw6-before-input -m conntrack --ctstate INVALID -j DROP |
| 48 | |
| 49 | # ok icmp codes for INPUT |
| 50 | -A ufw6-before-input -p icmpv6 --icmpv6-type destination-unreachable -j ACCEPT |
| 51 | -A ufw6-before-input -p icmpv6 --icmpv6-type packet-too-big -j ACCEPT |
| 52 | -A ufw6-before-input -p icmpv6 --icmpv6-type time-exceeded -j ACCEPT |
| 53 | -A ufw6-before-input -p icmpv6 --icmpv6-type parameter-problem -j ACCEPT |
| 54 | -A ufw6-before-input -p icmpv6 --icmpv6-type echo-request -j ACCEPT |
| 55 | |
| 56 | # ok icmp code for FORWARD |
| 57 | -A ufw6-before-forward -p icmpv6 --icmpv6-type destination-unreachable -j ACCEPT |
| 58 | -A ufw6-before-forward -p icmpv6 --icmpv6-type packet-too-big -j ACCEPT |
| 59 | -A ufw6-before-forward -p icmpv6 --icmpv6-type time-exceeded -j ACCEPT |
| 60 | -A ufw6-before-forward -p icmpv6 --icmpv6-type parameter-problem -j ACCEPT |
| 61 | -A ufw6-before-forward -p icmpv6 --icmpv6-type echo-request -j ACCEPT |
| 62 | |
| 63 | # allow dhcp client to work |
| 64 | -A ufw6-before-input -p udp -s fe80::/10 --sport 547 -d fe80::/10 --dport 546 -j ACCEPT |
| 65 | |
| 66 | # allow MULTICAST mDNS for service discovery |
| 67 | -A ufw6-before-input -p udp -d ff02::fb --dport 5353 -j ACCEPT |
| 68 | |
| 69 | # allow MULTICAST UPnP for service discovery |
| 70 | -A ufw6-before-input -p udp -d ff02::f --dport 1900 -j ACCEPT |
| 71 | |
| 72 | # don't delete the 'COMMIT' line or these rules won't be processed |
| 73 | COMMIT |