]> git.somenet.org - root/pub/somesible.git/blob - roles/base/network/files/default/nftables.conf
[roles/base/wireguard] install wireguard tools
[root/pub/somesible.git] / roles / base / network / files / default / nftables.conf
1 #!/usr/sbin/nft -f
2 ################################################
3 ### Managed by someone's ansible provisioner ###
4 ################################################
5 # Part of: https://git.somenet.org/root/pub/somesible.git
6 # 2017-2024 by someone <someone@somenet.org>
7 #
8
9 flush ruleset
10
11 table inet filter {
12 #    ct helper ftp-standard { type "ftp" protocol tcp; }
13 #
14 #    chain RAW {
15 #        type filter hook prerouting priority raw; policy accept;
16 #
17 #        # accept any inside traffic.
18 #        iifname "lo" counter accept
19 #
20 #        # accept all other traffic, by policy.
21 #    }
22
23     chain PRE {
24         type filter hook prerouting priority -150; policy accept;
25
26         # accept any inside traffic.
27         iifname "lo" counter accept
28
29         # incoming, public facing traffic.
30         counter jump PRE_outside
31
32         # accept any other traffic - should not happen.
33         counter log prefix "NFT:PRE:ACCEPT-unk; " accept
34     }
35
36     chain PRE_outside {
37         # mark outside-initiated incoming connections.
38         ct state new meta mark set 2 ct mark set meta mark
39
40         # accept neighbour discovery otherwise IPv6 connectivity breaks.
41         ip6 nexthdr icmpv6 icmpv6 type { nd-neighbor-advert, nd-neighbor-solicit, nd-router-advert} counter accept
42         ip protocol icmp icmp type { echo-request} counter accept
43
44         # accept connections to these services.
45         tcp dport 2 counter accept
46
47         # switch to something better than ftp, ssh/sftp for example, but if you must, use the ftp conntrack helper.
48 #        tcp dport 21 ct state new ct helper set "ftp-standard" counter accept
49
50         # accept traffic originated from us.
51         ct state established,related counter accept
52
53         # accept any other traffic.
54         counter accept
55 #        counter log prefix "NFT:PRE_outside:ACCEPT-all; " accept
56     }
57
58 #    chain INPUT {
59 #        type filter hook input priority 0; policy accept;
60 #        counter accept
61 #    }
62 #    chain FORWARD {
63 #        type filter hook forward priority 0; policy accept;
64 #        counter accept
65 #    }
66 #    chain OUTPUT {
67 #        type filter hook output priority 0; policy accept;
68 #        counter accept
69 #    }
70
71     chain POST {
72         type filter hook postrouting priority 150; policy accept;
73
74         # accept any inside traffic.
75         oifname "lo" counter accept
76
77         # outgoing, public facing traffic.
78         counter jump POST_outside
79
80         # accept any other traffic - should not happen.
81         counter log prefix "NFT:POST:ACCEPT-unk; " accept
82     }
83
84     chain POST_outside {
85         # mark inside-initiated outgoing traffic.
86         ct mark 0 meta mark set 1 ct mark set meta mark
87
88         # accept all traffic.
89         counter accept
90 #        counter log prefix "NFT:POST_outside:ACCEPT-all; " accept
91     }
92 }
93
94
95 #table ip nat {
96 #    chain NAT_PRE {
97 #        type nat hook prerouting priority dstnat; policy accept;
98 #        meta l4proto tcp ip daddr 127.0.0.1 tcp dport 80 counter redirect to :1080
99 #        meta l4proto tcp ip daddr 127.0.0.1 tcp dport 443 counter redirect to :10443
100 #    }
101 #    chain NAT_POST {
102 #        type nat hook postrouting priority 100; policy accept;
103 #        oifname "eth0" counter masquerade fully-random,persistent
104 #    }
105 #}