CyborgBeta
Captain
- Registriert
- Jan. 2021
- Beiträge
- 3.346
Hallo,
ich hab mir folgende nftables Firewall Regeln überlegt:
Das Problem ist, wenn ich diese Regeln flushe und danach
Speziell geht es darum, dass durch das frühe Pre-Routing Pakete akzeptiert werden, die eigentlich gedroppt werden sollten:
Also, dass das Accept vor dem Drop kommt, bzw. eine höhere Prio hat.
Hat jemand eine Lösung hierfür? Ich kann als Prio vermutlich nicht -101 verwenden, da dies nicht für die Filter gedacht ist. Möglicherweise sperre ich mich dann selber aus.
Durch:
kann ich Docker zwar sagen, bitte iptables unberührt lassen, aber dann kann als Seiteneffekt kein einziger Container mehr mit der Außenwelt kommunizieren.
ich hab mir folgende nftables Firewall Regeln überlegt:
/etc/nftables.conf
Code:
flush ruleset
table inet firewall {
chain input {
type filter hook input priority 0; policy drop;
# Allow incoming ping
# but still honor limit and drop the excess
# It could have been rewritten using anonymous chains
# but I kept it simple.
# It has to be done as an exception to the stateful rule
# so before it.
icmp type echo-request limit rate 15/second accept
icmp type echo-request drop
icmpv6 type echo-request limit rate 15/second accept
icmpv6 type echo-request drop
# firewall becomes stateful from here:
# Allow traffic from established and related packets, drop invalid
ct state vmap { established : accept, related : accept, invalid : drop }
# Allow loopback traffic.
iifname lo accept
# Allow connections from Docker containers
ip saddr 172.18.0.0/16 accept
# Allow specific ports from remote hosts via TCP
tcp dport { ssh usw., ... } accept
# Allow specific ports from remote hosts via UDP
# udp dport { ... } accept
# minimal ICMPv6 support for an end-node system
# non-LAN ICMPv6 (as well as IPv4 ICMP) packets used to report
# errors are handled by the generic stateful rule.
icmpv6 type { nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert } accept
# (Un)comment to enable logging of denied inbound traffic
log prefix "[nftables] Inbound Denied: " counter drop
}
}
Das Problem ist, wenn ich diese Regeln flushe und danach
docker compose
aufrufe, fügt Docker für das Containers-Netzwerk eigene Regeln hinzu.Speziell geht es darum, dass durch das frühe Pre-Routing Pakete akzeptiert werden, die eigentlich gedroppt werden sollten:
Code:
# nft -y list ruleset | grep -n priority | grep drop
# Warning: table ip nat is managed by iptables-nft, do not touch!
# Warning: table ip filter is managed by iptables-nft, do not touch!
3: type filter hook input priority 0; policy drop;
88: type filter hook forward priority 0; policy drop;
126: type filter hook forward priority 0; policy drop;
Code:
# nft -y list ruleset | grep -n priority | grep accept
# Warning: table ip nat is managed by iptables-nft, do not touch!
# Warning: table ip filter is managed by iptables-nft, do not touch!
34: type nat hook postrouting priority 100; policy accept;
51: type nat hook prerouting priority -100; policy accept;
56: type nat hook output priority -100; policy accept;
Also, dass das Accept vor dem Drop kommt, bzw. eine höhere Prio hat.
Hat jemand eine Lösung hierfür? Ich kann als Prio vermutlich nicht -101 verwenden, da dies nicht für die Filter gedacht ist. Möglicherweise sperre ich mich dann selber aus.
Durch:
Code:
{
"iptables" : false
}
kann ich Docker zwar sagen, bitte iptables unberührt lassen, aber dann kann als Seiteneffekt kein einziger Container mehr mit der Außenwelt kommunizieren.