Nftables Masquerade: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| Zeile 19: | Zeile 19: | ||
table ip filter { | table ip filter { | ||
| − | + | chain input { | |
type filter hook input priority 0; policy drop; | type filter hook input priority 0; policy drop; | ||
ct state {established, related} counter accept comment "accept all connections related to connections made by us" | ct state {established, related} counter accept comment "accept all connections related to connections made by us" | ||
Version vom 7. März 2023, 13:21 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} counter accept comment "accept all connections related to connections made by us"
iif lo accept comment "accept loopback"
iif != lo ip daddr 127.0.0.1/8 counter drop comment "drop connections to loopback not coming from loopback"
ip protocol icmp counter accept comment "accept all ICMP types"
tcp dport 22 counter accept comment "accept SSH"
counter comment "count dropped packets"
}
chain forward {
type filter hook forward priority 0; policy drop;
counter comment "count dropped packets"
}
chain output {
type filter hook output priority 0; policy accept;
}
}