blob: 90c0010cb43a82889e8007b81bc9c7d7a65fd035 [file] [log] [blame]
Matteo Scandolo74ba1592017-08-16 13:08:11 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
Scott Baker761e1062016-06-20 17:18:17 -070014#
15# rules.before
16#
17# Rules that should be run before the ufw command line added rules. Custom
18# rules should be added to one of these chains:
19# ufw6-before-input
20# ufw6-before-output
21# ufw6-before-forward
22#
23
24# Don't delete these required lines, otherwise there will be errors
25*filter
26:ufw6-before-input - [0:0]
27:ufw6-before-output - [0:0]
28:ufw6-before-forward - [0:0]
29# End required lines
30
31
32# allow all on loopback
33-A ufw6-before-input -i lo -j ACCEPT
34-A ufw6-before-output -o lo -j ACCEPT
35
36# drop packets with RH0 headers
37-A ufw6-before-input -m rt --rt-type 0 -j DROP
38-A ufw6-before-forward -m rt --rt-type 0 -j DROP
39-A ufw6-before-output -m rt --rt-type 0 -j DROP
40
41# for stateless autoconfiguration (restrict NDP messages to hop limit of 255)
42-A ufw6-before-input -p icmpv6 --icmpv6-type neighbor-solicitation -m hl --hl-eq 255 -j ACCEPT
43-A ufw6-before-output -p icmpv6 --icmpv6-type neighbor-solicitation -m hl --hl-eq 255 -j ACCEPT
44-A ufw6-before-input -p icmpv6 --icmpv6-type neighbor-advertisement -m hl --hl-eq 255 -j ACCEPT
45-A ufw6-before-output -p icmpv6 --icmpv6-type neighbor-advertisement -m hl --hl-eq 255 -j ACCEPT
46-A ufw6-before-input -p icmpv6 --icmpv6-type router-solicitation -m hl --hl-eq 255 -j ACCEPT
47-A ufw6-before-input -p icmpv6 --icmpv6-type router-advertisement -m hl --hl-eq 255 -j ACCEPT
48
49# quickly process packets for which we already have a connection
50-A ufw6-before-input -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
51-A ufw6-before-output -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
52-A ufw6-before-forward -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
53
54# for multicast ping replies from link-local addresses (these don't have an
55# associated connection and would otherwise be marked INVALID)
56-A ufw6-before-input -p icmpv6 --icmpv6-type echo-reply -s fe80::/10 -j ACCEPT
57
58# drop INVALID packets (logs these in loglevel medium and higher)
59-A ufw6-before-input -m conntrack --ctstate INVALID -j ufw6-logging-deny
60-A ufw6-before-input -m conntrack --ctstate INVALID -j DROP
61
62# ok icmp codes for INPUT
63-A ufw6-before-input -p icmpv6 --icmpv6-type destination-unreachable -j ACCEPT
64-A ufw6-before-input -p icmpv6 --icmpv6-type packet-too-big -j ACCEPT
65-A ufw6-before-input -p icmpv6 --icmpv6-type time-exceeded -j ACCEPT
66-A ufw6-before-input -p icmpv6 --icmpv6-type parameter-problem -j ACCEPT
67-A ufw6-before-input -p icmpv6 --icmpv6-type echo-request -j ACCEPT
68
69# ok icmp code for FORWARD
70-A ufw6-before-forward -p icmpv6 --icmpv6-type destination-unreachable -j ACCEPT
71-A ufw6-before-forward -p icmpv6 --icmpv6-type packet-too-big -j ACCEPT
72-A ufw6-before-forward -p icmpv6 --icmpv6-type time-exceeded -j ACCEPT
73-A ufw6-before-forward -p icmpv6 --icmpv6-type parameter-problem -j ACCEPT
74-A ufw6-before-forward -p icmpv6 --icmpv6-type echo-request -j ACCEPT
75
76# allow dhcp client to work
77-A ufw6-before-input -p udp -s fe80::/10 --sport 547 -d fe80::/10 --dport 546 -j ACCEPT
78
79# allow MULTICAST mDNS for service discovery
80-A ufw6-before-input -p udp -d ff02::fb --dport 5353 -j ACCEPT
81
82# allow MULTICAST UPnP for service discovery
83-A ufw6-before-input -p udp -d ff02::f --dport 1900 -j ACCEPT
84
85# don't delete the 'COMMIT' line or these rules won't be processed
86COMMIT