Nftables: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
 
(37 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
=Install=
[[Kategorie:Nftables]]
*apt-get install nftables
* [[Nftabels Grundlagen]]
=Create a basic IPv4 table=
* [[Grundlegendes zum Connection Tracking]]
*nft add table inet filter
* [[nftables console]]
=List that table=
* [[iptables zu nftables]]
*nft list table inet filter
* [[nftables Masquerade]]
table inet filter {
* [[nftables Host absichern]]
}
* [[nftables Netze absichern]]
=Create a chain for input traffic IPv4=
* [[nftables misc]]
*nft add chain inet filter input { type filter hook input priority 0\; }
* [[nftables Erweiterungen]]
=A rule to check that all is fine (IPv4)=
* [[nftables ipsec]]
*nft add rule inet filter input counter accept
* [[nftables Anpassung]]
=List that table=
* [[nftables Netmap]]
*nft list table inet filter
* [[nftables Webserver Beispiel]]
<pre>
* [[nftables Webserver Beispiel Ratelimit]]
table inet filter {
* [[nft monitor trace]]
chain input {
type filter hook input priority 0; policy accept;
counter packets 47 bytes 3100 accept
}
}
</pre>
=Flush rules in chain filter/input=
*nft flush chain inet filter input
=Delete the chain filter/input=
*nft delete chain inet filter input
=Delete the table filter=
*nft delete table inet filter
 
=Example Script=
<pre>
#!/usr/sbin/nft -f
#variable declaration
define tcp_lan_input_ports = { 8472, 53 }
define tcp_all_input_ports = { 80, 443 }
define udp_lan_input_ports = { 53 }
define tcp_for_input_ports = { 53 }
define udp_for_input_ports = {  53 }
 
# table declaration
add table filter
add table nat
flush chain filter input
flush chain filter output
flush chain filter forward
table filter {
        chain input {
                type filter hook input priority 0; policy drop;
                ct state established,related counter packets 97 bytes 6640 accept
                iifname "lo" counter accept
                iifname "ens19" tcp dport $tcp_lan_input_ports counter accept
                tcp dport $tcp_all_input_ports  counter accept
                udp dport $udp_lan_input_ports  counter accept
                log prefix "nft-input "
        }
 
        chain output {
                type filter hook output priority 0; policy drop;
                ct state established,related counter accept
                counter accept
                log prefix "nft-output "
        }
 
        chain forward {
                type filter hook forward priority 0; policy drop;
                ct state established,related counter accept
                iifname "ens19" oifname "ens19" counter accept
                iifname "ens19" oifname "ens18" tcp dport $tcp_for_input_ports counter accept
                iifname "ens19" oifname "ens18" udp dport $udp_for_input_ports counter accept
                iifname "ens19" oifname "ens18" icmp type echo-request counter accept
                log prefix "nft-forward "
        }
}
</pre>

Aktuelle Version vom 16. August 2026, 21:33 Uhr