Nftables Masquerade: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 21: | Zeile 21: | ||
chain input { | chain input { | ||
type filter hook input priority 0; policy drop; | type filter hook input priority 0; policy drop; | ||
ct state {established, related} | ct state {established, related} accept | ||
iif lo accept | iif lo accept | ||
iif != lo ip daddr 127.0.0.1/8 | iif != lo ip daddr 127.0.0.1/8 drop | ||
ip protocol icmp | ip protocol icmp accept | ||
tcp dport 22 | tcp dport 22 accept | ||
} | } | ||
chain forward { | chain forward { | ||
type filter hook forward priority 0; policy drop; | type filter hook forward priority 0; policy drop; | ||
} | } | ||
| Zeile 37: | Zeile 35: | ||
type filter hook output priority 0; policy accept; | type filter hook output priority 0; policy accept; | ||
} | } | ||
} | } | ||
table ip nat { | |||
chain prerouting { | |||
type nat hook prerouting priority 0; policy accept; | |||
} | |||
chain postrouting { | |||
type nat hook postrouting priority 100; policy accept; | |||
oif "enp0s3" masquerade | |||
} | |||
} | |||
= Links = | = Links = | ||
* https://wiki.gentoo.org/wiki/Nftables/Examples | * https://wiki.gentoo.org/wiki/Nftables/Examples | ||
Version vom 7. März 2023, 14:00 Uhr
Einfache Routing Firewall
- Eine einfache Firewall, die Pakete aus dem LAN ins WAN weiterleitet
- Pakete aus dem WAN von etablierten Verbindungen sollen ins LAN geleitet werden
Routing aktivieren
- sysctl -w net.ipv4.ip_forward = 1
Einfaches NAT
- Quell IP Adressen aus dem LAN sollen auf die WAN IP geändert werden
- Am einfachsten ist dafür das "Masquerading"
- Sowohl dynamische als auch statische WAN IPs können damit Zugriff auf das Internet gewähren
- Wenn sicher eine statische IP hat, ist SNAT ein wenig schneller
- vim /etc/nftables.conf
flush ruleset
table ip filter {
chain input {
type filter hook input priority 0; policy drop;
ct state {established, related} accept
iif lo accept
iif != lo ip daddr 127.0.0.1/8 drop
ip protocol icmp accept
tcp dport 22 accept
}
chain forward {
type filter hook forward priority 0; policy drop;
}
chain output {
type filter hook output priority 0; policy accept;
}
}
table ip nat {
chain prerouting {
type nat hook prerouting priority 0; policy accept;
}
chain postrouting {
type nat hook postrouting priority 100; policy accept;
oif "enp0s3" masquerade
}
}