Portál AbcLinuxu, 30. října 2025 06:29
Zdá se, že tohle je otázka z roku 2015, která byla omylem postnutá dnes.
Firewall na Linuxu se jmenuje (už minimálně půl dekády) nftables.
Žádný one-size-fits-all vzor podle mě neexistuje. Na webu se povalují asi tak stovky příkladů pro různé, ba nejrůznější situace (desktop, router, server, přenosné počítače, psací stroje, mlýnky na kávu). Podstatná část konfigurace je spíš věc názorů a preferencí kolem používaných služeb než cokoliv jiného.
table ip nat {
chain prerouting {
type nat hook prerouting priority filter; policy accept;
}
chain postrouting {
type nat hook postrouting priority srcnat; policy accept;
oifgroup 72 snat to XXX.XXX.XXX.XXX
}
}
table inet filter {
chain input {
type filter hook input priority filter; policy accept;
ip6 nexthdr esp meta mark set meta mark | 0x00000101
ip protocol esp meta mark set meta mark | 0x00000101
meta mark & 0x00000101 == 0x00000101 accept
ct state { established, related } accept
ct state invalid drop
iif "lo" accept
iifgroup 99 accept
iifgroup 72 jump outer_spoof
tcp dport { 22, 25, 53, 80, 110, 143, 443, 465, 853, 993, 5222, 5269, 9418, 22200-22202 } accept
udp dport { 53, 500, 546, 4500 } accept
udp sport 547 accept
udp sport 123 udp dport 123 accept
ip6 nexthdr ipv6-icmp accept
ip protocol icmp accept
udp sport 67 udp dport 68 accept
ip6 saddr fe80::/10 tcp dport 546 accept
ip6 saddr fe80::/10 udp dport 546 accept
reject
}
chain forward {
type filter hook forward priority filter; policy accept;
ip6 nexthdr esp meta mark set meta mark | 0x00000101
ip protocol esp meta mark set meta mark | 0x00000101
meta mark & 0x00000101 == 0x00000101 accept
ct state { established, related } accept
ct state invalid drop
iifgroup 99 accept
iifgroup 72 jump outer_spoof
oifgroup 72 tcp flags syn tcp option maxseg size set rt mtu
tcp dport { 22 } accept
ip6 nexthdr ipv6-icmp accept
ip protocol icmp accept
reject
}
chain output {
type filter hook output priority filter; policy accept;
}
chain outer_spoof {
ip saddr 10.79.0.0/16 drop
ip6 saddr XXXX:XXXX:XXXX::/48 drop
return
}
}
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.