NFTABLES WHITELISTING

Gemeinsam ins Internet mit Firewall und Proxy.
Antworten
AlexWD
Beiträge: 1
Registriert: 03.07.2021 08:29:20

NFTABLES WHITELISTING

Beitrag von AlexWD » 03.07.2021 08:43:26

Einen schönen guten Morgen!

Seit kurzem nutze ich eine einfache nftables-Routerkonfiguration, die auch funktioniert. Nun möchte ich nftables anweisen, dass es Netzwerkverkehr nur zu bzw. von bestimmten IPs über https zulässt und alles andere blockiert. Dafür, dachte ich, reicht die Anweisung

Code: Alles auswählen

ip saddr !=@whitelist drop
in der Forward-Chain. Leider funktioniert das nicht. Was übersehe ich? Könnte es sein, dass der DNS-Server dadurch auch blockiert wird? Wenn ich dessen IP in die whitelist aufnehmen, passiert aber nichts. Es wäre toll, wenn ihr mir weiterhelfen könntet. Vielen Dank!

Code: Alles auswählen

#!/usr/sbin/nft -f

define local = eth1
define wan = eth2

flush ruleset

table arp filter {
        chain input {
                type filter hook input priority 0; policy accept;
   }

   chain output {
       type filter hook output priority 0; policy accept;
   }
}

table inet filter {
        set whitelist {
                type ipv4_addr
                elements = { 1.2.3.4,2.3.4.5 }
        }
        chain input {
                type filter hook input priority 0;
                iif $local tcp dport {ssh} limit rate 15/minute counter accept comment "allow ssh"
                iif $local accept comment "allow local packets"
                iif $wan ct state {established, related} counter accept comment "allow established wan packets"
                ct state invalid drop
                iif $wan drop
        }
        chain forward {
                type filter hook forward priority 0; policy drop;
                ip saddr != @whitelist drop
                iif $wan oif $local ct state {established, related} counter accept comment "allow wan established, related"
                iif $local oif $wan counter accept comment "allow lan to wan"
                iif $wan tcp dport {https} counter accept comment "forward https"
                iif $wan drop

        }
        chain output {
                type filter hook output priority 0;
                counter comment "count accepted packets"
        }
}


table nat {
        chain output {
                type nat hook output priority -100;
        }
        chain prerouting {
                type nat hook prerouting priority -100;
                iif $wan tcp dport {https} counter dnat to 192.168.0.0
        }
        chain postrouting {
                type nat hook postrouting priority 100;
                oif $wan counter masquerade comment "masquerade"
        }
}

Antworten