SlideShare a Scribd company logo
NF TABLESNF TABLES
Marian HackMan Marinov
Chief System Architect of SiteGround.com
<mm@1h.com>
Who am I?Who am I?
HistoryHistory
➢ ipfw
➢ ipchains
➢ iptables
➢ arptables
➢ ebtables
➢ nftables
nftablesnftables
➢ Replacement of iptables, ip6tables,
arptables & ebtables
➢ including ipset
➢ Remove the duplicated code from all
modules
➢ Simplify the dual stack(IPv4/6) handling
➢ ip, ip6, inet, arp & bridge address families
nftablesnftables
➢ Merged mainstream in October 2013,
available since January 2014 in Linux kernel
3.13.
➢ It reuses the existing Netfilter building
blocks: hooks, conntrack, NAT, logging and
userspace queueing.
➢ It also reuses existing xtables extensions
through nft compat.
nftables - the evolution of Linux Firewall
nftables - the evolution of Linux Firewall
nftables flownftables flow
Routing
Decision
Routing
Decision
Local
Process
prerouting
input
output
forward postrouting
NETWORK
NETWORK
Routing
Decision
Routing
Decision
Local
Process
prerouting
input
output
forward postrouting
NETWORK
NETWORKRouting
Decision
ingress
nftables flownftables flow
with ingress filterwith ingress filter
nftables vs. iptablesnftables vs. iptables
➢ Tables and chains are fully configurable
list
tables [family]
table [family] <name>
chain [family] <table> <name>
add
table [family] <name>
chain [family] <table> <name> [chain definitions]
rule [family] <table> <chain> <rule definition>
table [family] <name> (shortcut for `add table`)
Families:
ip - IPv4
ip6 - IPv6
inet - IPv4 or v6
arp - arp
bridge - linux bridge
nftables vs. iptablesnftables vs. iptables
➢ Tables and chains are fully configurable
➢ Tables are without any predefined purpose
➢ there are no raw, filter, nat & mangle tables
nftables vs. iptablesnftables vs. iptables
➢ Tables and chains are fully configurable
➢ Tables are without any predefined purpose
➢ there are no raw, filter, nat & mangle tables
➢ By default there are no chains
➢ if there is no chain that would match the packet
it will not be touched by netfilter code
➢ Every chain has a type:
➢ filter
➢ nat (only the first packet of a flow hits this chain)
➢ route (mangle)
HooksHooks
➢ Base chains are the ones that are attached
to hooks
➢ Non-base chains are used for ordering
➢ All available hooks:
➢ ingress
➢ input
➢ output
➢ forward
➢ prerouting
➢ postrouting
nftables vs. iptablesnftables vs. iptables
➢ No distinction between matches and targets
anymore
➢ no difference between ACCEPT and -s
# nft insert rule filter input ct state established accept
VS.
# iptables -I INPUT -j ACCEPT -m conntrack --ctstate
ESTABLISHED
nftables vs. iptablesnftables vs. iptables
➢ You can specify several actions in one
single rule
# nft add rule filter forward tcp dport 22 log drop
VS.
# iptables -A FORWARD -p tcp --dport 22 -j LOG
# iptables -A FORWARD -p tcp --dport 22 -j DROP
nftables vs. iptablesnftables vs. iptables
➢ No built-in counter per chain and rules
➢ counters introduce delays in packet processing
➢ counters can be added to any chain using the
'counter' keyword
# nft add rule ip filter output ip daddr 1.2.3.4
counter drop
nftables vs. iptablesnftables vs. iptables
➢ New supported protocols without kernel
upgrades
➢ most of the logic in nftables is inside its
userspace
➢ it compiles the rules to VM bytecode in netlink
format and then it pushes this into the kernel via
the nftables Netlink API
➢ it provides generic set and map infrastructure
nftables vs. iptablesnftables vs. iptables
➢ Better support for dynamic ruleset updates
➢ iptables always replaces all rules
➢ even if you only delete one rule
➢ even if you only add one rule
➢ nftables uses linked-list to solve this issue
flush rulesetflush ruleset
table inet filter {table inet filter {
chain input {chain input {
type filter hook input priority 0; policy drop;type filter hook input priority 0; policy drop;
# established/related connections# established/related connections
ct state established,related acceptct state established,related accept
# invalid connections# invalid connections
ct state invalid dropct state invalid drop
# loopback interface# loopback interface
iif lo acceptiif lo accept
# ICMP# ICMP
# routers may also want: mld-listener-query, nd-router-solicit# routers may also want: mld-listener-query, nd-router-solicit
ip6 nexthdr icmpv6 icmpv6 type { destination-unreachable, packet-too-big,ip6 nexthdr icmpv6 icmpv6 type { destination-unreachable, packet-too-big,
time-exceeded, parameter-problem, nd-router-advert, nd-neighbor-solicit, nd-time-exceeded, parameter-problem, nd-router-advert, nd-neighbor-solicit, nd-
neighbor-advert } acceptneighbor-advert } accept
ip protocol icmp icmp type { destination-unreachable, router-advertisement,ip protocol icmp icmp type { destination-unreachable, router-advertisement,
time-exceeded, parameter-problem } accepttime-exceeded, parameter-problem } accept
# SSH (port 22)# SSH (port 22)
tcp dport ssh accepttcp dport ssh accept
# HTTP (ports 80 & 445)# HTTP (ports 80 & 445)
tcp dport { http, https } accepttcp dport { http, https } accept
}}
}}
➢ Basic Jump example:Basic Jump example:
table inet filter {table inet filter {
chain web {chain web {
tcp dport http accepttcp dport http accept
tcp dport 8080 accepttcp dport 8080 accept
}}
chain input {chain input {
type filter hook input priority 0;type filter hook input priority 0;
ip saddr 10.0.2.0/24 jump webip saddr 10.0.2.0/24 jump web
dropdrop
}}
}}
InterestingInteresting
➢ Concatenated Value Pairs
# nft add element traffic-filter dict { 192.168.0.1 :
drop, 192.168.0.2 : accept }
➢ Easy Data Export
# nft export json
➢ Multiple Actions
# nft add rule ip filter input ip protocol vmap
{ tcp : jump tcp-chain, udp : jump udp-chain,
icmp : jump icmp-chain }
JumpsJumps
➢accept (accept a packet)
➢reject (reject a packet)
➢drop (drop a packet)
➢snat (perform source NAT on a packet)
➢dnat (perform destination NAT on a packet)
➢log (log a packet)
➢counter (keep a counter on a packet; counters are
optional in nftables)
➢return (stop traversing the chain)
➢jump <chain> (jump to another chain)
➢goto <chain> (jump to another chain, but do not return)
Match argumentsMatch arguments
meta:
oif <output interface INDEX>
iif <input interface INDEX>
oifname <output interface NAME>
iifname <input interface NAME>
(oif and iif accept string arguments and are
converted to interface indexes)
(oifname and iifname are more dynamic, but
slower because of string matching)
Match argumentsMatch arguments
icmp:
type <icmp type>
icmpv6:
type <icmpv6 type>
ip:
protocol <protocol>
daddr <destination address>
saddr <source address>
ip6:
daddr <destination address>
saddr <source address>
Match argumentsMatch arguments
tcp:
dport <destination port>
sport <source port>
udp:
dport <destination port>
sport <source port>
ct:
state <new | established | related | invalid>
Load BalancingLoad Balancing
IPv4 performanceIPv4 performance
method req/sec %cpu
LVS-SNAT 313427.91 24.11
NFT-SNAT 289035.54 23.2
NFT-DNAT 303356.59 23.12
LVS-DSR 356212.05 4.78
NFT-DSR 393672.35 0.54
DSR - Direct Server Return
SLB - Server Load Balancing(SNAT/DNAT)
Kernel configurationKernel configuration
[*] Networking support --->
Networking options --->
[*] Network packet filtering framework (Netfilter) --->
Core Netfilter Configuration --->
<M> Netfilter nf_tables support
<M> Netfilter nf_tables conntrack module
<M> Netfilter nf_tables counter module
<M> Netfilter nf_tables log module
<M> Netfilter nf_tables limit module
<M> Netfilter nf_tables masquerade support
<M> Netfilter nf_tables nat module
IP: Netfilter Configuration --->
<M> IPv4 nf_tables support
<M> IPv4 nf_tables route chain support
<M> IPv4 packet rejection
<M> IPv4 NAT
<M> IPv4 nf_tables nat chain support
<M> IPv4 masquerade support
<M> IPv4 masquerading support for nf_tables
nftables - the evolution of Linux Firewall
Marian HackMan Marinov <mm@1h.com>
hackman @ irc.freenode.net
https://github.com/hackman

More Related Content

PDF
netfilter and iptables
PDF
EBPF and Linux Networking
PPTX
Linux Network Stack
PDF
Faster packet processing in Linux: XDP
PDF
LinuxCon 2015 Linux Kernel Networking Walkthrough
PDF
Linux Networking Explained
PPTX
The TCP/IP Stack in the Linux Kernel
PDF
BPF / XDP 8월 세미나 KossLab
netfilter and iptables
EBPF and Linux Networking
Linux Network Stack
Faster packet processing in Linux: XDP
LinuxCon 2015 Linux Kernel Networking Walkthrough
Linux Networking Explained
The TCP/IP Stack in the Linux Kernel
BPF / XDP 8월 세미나 KossLab

What's hot (20)

PDF
Fun with Network Interfaces
PDF
VMworld 2013: ESXi Native Networking Driver Model - Delivering on Simplicity ...
PPTX
Tutorial: Using GoBGP as an IXP connecting router
PDF
Open vSwitch Introduction
ODP
eBPF maps 101
PDF
eBPF - Rethinking the Linux Kernel
PDF
DevConf 2014 Kernel Networking Walkthrough
PPTX
Understanding eBPF in a Hurry!
PDF
BPF Internals (eBPF)
PDF
Introduction to eBPF and XDP
PDF
introduction to linux kernel tcp/ip ptocotol stack
PDF
Ccnp workbook network bulls
PDF
Neighbor Discovery Deep Dive – IPv6-Networking-Referat
PDF
BPF & Cilium - Turning Linux into a Microservices-aware Operating System
PPTX
eBPF Basics
PPTX
Packet flow on openstack
PDF
Ixgbe internals
PDF
Bash production guide
PDF
The linux networking architecture
PDF
DPDK: Multi Architecture High Performance Packet Processing
Fun with Network Interfaces
VMworld 2013: ESXi Native Networking Driver Model - Delivering on Simplicity ...
Tutorial: Using GoBGP as an IXP connecting router
Open vSwitch Introduction
eBPF maps 101
eBPF - Rethinking the Linux Kernel
DevConf 2014 Kernel Networking Walkthrough
Understanding eBPF in a Hurry!
BPF Internals (eBPF)
Introduction to eBPF and XDP
introduction to linux kernel tcp/ip ptocotol stack
Ccnp workbook network bulls
Neighbor Discovery Deep Dive – IPv6-Networking-Referat
BPF & Cilium - Turning Linux into a Microservices-aware Operating System
eBPF Basics
Packet flow on openstack
Ixgbe internals
Bash production guide
The linux networking architecture
DPDK: Multi Architecture High Performance Packet Processing
Ad

Viewers also liked (20)

PDF
Application Security Testing for Software Engineers: An approach to build sof...
PPTX
Regular Expression Denial of Service RegexDoS
PDF
How penetration testing techniques can help you improve your qa skills
ODP
Securing the network for VMs or Containers
PDF
Io t introduction to electronics
PDF
Lxd the proper way of runing containers
ODP
Computer vision for your projects
PDF
Protecting your home and office in the era of IoT
PDF
Make your internship "worth it"
ODP
How to setup your linux server
ODP
Home assistant
PPTX
LUG-BG - Kostadin Slavkov - PostgreSQL 10
PDF
Gluster.community.day.2013
PDF
Comparison of foss distributed storage
PDF
LUG-BG 2017 - Rangel Ivanov - Spread some butter - BTRFS
PDF
4 Sessions
PDF
Practical my sql performance optimization
PDF
Introduction to python
PDF
Why we are migrating to Slackware
PDF
Moving your router inside container
Application Security Testing for Software Engineers: An approach to build sof...
Regular Expression Denial of Service RegexDoS
How penetration testing techniques can help you improve your qa skills
Securing the network for VMs or Containers
Io t introduction to electronics
Lxd the proper way of runing containers
Computer vision for your projects
Protecting your home and office in the era of IoT
Make your internship "worth it"
How to setup your linux server
Home assistant
LUG-BG - Kostadin Slavkov - PostgreSQL 10
Gluster.community.day.2013
Comparison of foss distributed storage
LUG-BG 2017 - Rangel Ivanov - Spread some butter - BTRFS
4 Sessions
Practical my sql performance optimization
Introduction to python
Why we are migrating to Slackware
Moving your router inside container
Ad

Similar to nftables - the evolution of Linux Firewall (20)

PDF
Iptables presentation
PDF
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
PPTX
How to convert your Linux box into Security Gateway - Part 1
PDF
True stories on the analysis of network activity using Python
PDF
Introduction to firewalls through Iptables
PPT
Packet_Filteringfgasdgasdgsagdsgsagasg.ppt
PDF
iptable casestudy by sans.pdf
PDF
IPv6 for Pentesters
PDF
IPv6 for Pentesters
PDF
Network Security Best Practice (BCP38 & 140)
PPT
IPTABLES
PPT
Iptables
PDF
IPv6 Fundamentals & Securities
PPTX
Cisco CCNA EIGRP IPV6 Configuration
PDF
Implementing an IPv6 Enabled Environment for a Public Cloud Tenant
PDF
[Webinar Slides] Programming the Network Dataplane in P4
TXT
Services
PDF
Chapter 6 firewall
PDF
eLea4555555555555555555555555555555rnSecurity .pdf
PDF
Complete squid &amp; firewall configuration. plus easy mac binding
Iptables presentation
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
How to convert your Linux box into Security Gateway - Part 1
True stories on the analysis of network activity using Python
Introduction to firewalls through Iptables
Packet_Filteringfgasdgasdgsagdsgsagasg.ppt
iptable casestudy by sans.pdf
IPv6 for Pentesters
IPv6 for Pentesters
Network Security Best Practice (BCP38 & 140)
IPTABLES
Iptables
IPv6 Fundamentals & Securities
Cisco CCNA EIGRP IPV6 Configuration
Implementing an IPv6 Enabled Environment for a Public Cloud Tenant
[Webinar Slides] Programming the Network Dataplane in P4
Services
Chapter 6 firewall
eLea4555555555555555555555555555555rnSecurity .pdf
Complete squid &amp; firewall configuration. plus easy mac binding

More from Marian Marinov (20)

PDF
How to start and then move forward in IT
PDF
Thinking about highly-available systems and their setup
PDF
Understanding your memory usage under Linux
PDF
How to implement PassKeys in your application
PDF
Dev.bg DevOps March 2024 Monitoring & Logging
PDF
Basic presentation of cryptography mechanisms
PDF
Microservices: Benefits, drawbacks and are they for me?
PDF
Introduction and replication to DragonflyDB
PDF
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
PDF
How to successfully migrate to DevOps .pdf
PDF
How to survive in the work from home era
PDF
Managing sysadmins
PDF
Improve your storage with bcachefs
PDF
Control your service resources with systemd
PDF
Comparison of-foss-distributed-storage
PDF
Защо и как да обогатяваме знанията си?
PDF
Securing your MySQL server
PDF
Sysadmin vs. dev ops
PDF
DoS and DDoS mitigations with eBPF, XDP and DPDK
PDF
Challenges with high density networks
How to start and then move forward in IT
Thinking about highly-available systems and their setup
Understanding your memory usage under Linux
How to implement PassKeys in your application
Dev.bg DevOps March 2024 Monitoring & Logging
Basic presentation of cryptography mechanisms
Microservices: Benefits, drawbacks and are they for me?
Introduction and replication to DragonflyDB
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
How to successfully migrate to DevOps .pdf
How to survive in the work from home era
Managing sysadmins
Improve your storage with bcachefs
Control your service resources with systemd
Comparison of-foss-distributed-storage
Защо и как да обогатяваме знанията си?
Securing your MySQL server
Sysadmin vs. dev ops
DoS and DDoS mitigations with eBPF, XDP and DPDK
Challenges with high density networks

Recently uploaded (20)

PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Pre independence Education in Inndia.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
master seminar digital applications in india
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Basic Mud Logging Guide for educational purpose
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Microbial diseases, their pathogenesis and prophylaxis
Microbial disease of the cardiovascular and lymphatic systems
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Pre independence Education in Inndia.pdf
Pharma ospi slides which help in ospi learning
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
TR - Agricultural Crops Production NC III.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Final Presentation General Medicine 03-08-2024.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
master seminar digital applications in india
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Basic Mud Logging Guide for educational purpose
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx

nftables - the evolution of Linux Firewall

  • 1. NF TABLESNF TABLES Marian HackMan Marinov Chief System Architect of SiteGround.com <mm@1h.com>
  • 2. Who am I?Who am I?
  • 3. HistoryHistory ➢ ipfw ➢ ipchains ➢ iptables ➢ arptables ➢ ebtables ➢ nftables
  • 4. nftablesnftables ➢ Replacement of iptables, ip6tables, arptables & ebtables ➢ including ipset ➢ Remove the duplicated code from all modules ➢ Simplify the dual stack(IPv4/6) handling ➢ ip, ip6, inet, arp & bridge address families
  • 5. nftablesnftables ➢ Merged mainstream in October 2013, available since January 2014 in Linux kernel 3.13. ➢ It reuses the existing Netfilter building blocks: hooks, conntrack, NAT, logging and userspace queueing. ➢ It also reuses existing xtables extensions through nft compat.
  • 10. nftables vs. iptablesnftables vs. iptables ➢ Tables and chains are fully configurable list tables [family] table [family] <name> chain [family] <table> <name> add table [family] <name> chain [family] <table> <name> [chain definitions] rule [family] <table> <chain> <rule definition> table [family] <name> (shortcut for `add table`) Families: ip - IPv4 ip6 - IPv6 inet - IPv4 or v6 arp - arp bridge - linux bridge
  • 11. nftables vs. iptablesnftables vs. iptables ➢ Tables and chains are fully configurable ➢ Tables are without any predefined purpose ➢ there are no raw, filter, nat & mangle tables
  • 12. nftables vs. iptablesnftables vs. iptables ➢ Tables and chains are fully configurable ➢ Tables are without any predefined purpose ➢ there are no raw, filter, nat & mangle tables ➢ By default there are no chains ➢ if there is no chain that would match the packet it will not be touched by netfilter code ➢ Every chain has a type: ➢ filter ➢ nat (only the first packet of a flow hits this chain) ➢ route (mangle)
  • 13. HooksHooks ➢ Base chains are the ones that are attached to hooks ➢ Non-base chains are used for ordering ➢ All available hooks: ➢ ingress ➢ input ➢ output ➢ forward ➢ prerouting ➢ postrouting
  • 14. nftables vs. iptablesnftables vs. iptables ➢ No distinction between matches and targets anymore ➢ no difference between ACCEPT and -s # nft insert rule filter input ct state established accept VS. # iptables -I INPUT -j ACCEPT -m conntrack --ctstate ESTABLISHED
  • 15. nftables vs. iptablesnftables vs. iptables ➢ You can specify several actions in one single rule # nft add rule filter forward tcp dport 22 log drop VS. # iptables -A FORWARD -p tcp --dport 22 -j LOG # iptables -A FORWARD -p tcp --dport 22 -j DROP
  • 16. nftables vs. iptablesnftables vs. iptables ➢ No built-in counter per chain and rules ➢ counters introduce delays in packet processing ➢ counters can be added to any chain using the 'counter' keyword # nft add rule ip filter output ip daddr 1.2.3.4 counter drop
  • 17. nftables vs. iptablesnftables vs. iptables ➢ New supported protocols without kernel upgrades ➢ most of the logic in nftables is inside its userspace ➢ it compiles the rules to VM bytecode in netlink format and then it pushes this into the kernel via the nftables Netlink API ➢ it provides generic set and map infrastructure
  • 18. nftables vs. iptablesnftables vs. iptables ➢ Better support for dynamic ruleset updates ➢ iptables always replaces all rules ➢ even if you only delete one rule ➢ even if you only add one rule ➢ nftables uses linked-list to solve this issue
  • 19. flush rulesetflush ruleset table inet filter {table inet filter { chain input {chain input { type filter hook input priority 0; policy drop;type filter hook input priority 0; policy drop; # established/related connections# established/related connections ct state established,related acceptct state established,related accept # invalid connections# invalid connections ct state invalid dropct state invalid drop # loopback interface# loopback interface iif lo acceptiif lo accept
  • 20. # ICMP# ICMP # routers may also want: mld-listener-query, nd-router-solicit# routers may also want: mld-listener-query, nd-router-solicit ip6 nexthdr icmpv6 icmpv6 type { destination-unreachable, packet-too-big,ip6 nexthdr icmpv6 icmpv6 type { destination-unreachable, packet-too-big, time-exceeded, parameter-problem, nd-router-advert, nd-neighbor-solicit, nd-time-exceeded, parameter-problem, nd-router-advert, nd-neighbor-solicit, nd- neighbor-advert } acceptneighbor-advert } accept ip protocol icmp icmp type { destination-unreachable, router-advertisement,ip protocol icmp icmp type { destination-unreachable, router-advertisement, time-exceeded, parameter-problem } accepttime-exceeded, parameter-problem } accept # SSH (port 22)# SSH (port 22) tcp dport ssh accepttcp dport ssh accept # HTTP (ports 80 & 445)# HTTP (ports 80 & 445) tcp dport { http, https } accepttcp dport { http, https } accept }} }}
  • 21. ➢ Basic Jump example:Basic Jump example: table inet filter {table inet filter { chain web {chain web { tcp dport http accepttcp dport http accept tcp dport 8080 accepttcp dport 8080 accept }} chain input {chain input { type filter hook input priority 0;type filter hook input priority 0; ip saddr 10.0.2.0/24 jump webip saddr 10.0.2.0/24 jump web dropdrop }} }}
  • 22. InterestingInteresting ➢ Concatenated Value Pairs # nft add element traffic-filter dict { 192.168.0.1 : drop, 192.168.0.2 : accept } ➢ Easy Data Export # nft export json ➢ Multiple Actions # nft add rule ip filter input ip protocol vmap { tcp : jump tcp-chain, udp : jump udp-chain, icmp : jump icmp-chain }
  • 23. JumpsJumps ➢accept (accept a packet) ➢reject (reject a packet) ➢drop (drop a packet) ➢snat (perform source NAT on a packet) ➢dnat (perform destination NAT on a packet) ➢log (log a packet) ➢counter (keep a counter on a packet; counters are optional in nftables) ➢return (stop traversing the chain) ➢jump <chain> (jump to another chain) ➢goto <chain> (jump to another chain, but do not return)
  • 24. Match argumentsMatch arguments meta: oif <output interface INDEX> iif <input interface INDEX> oifname <output interface NAME> iifname <input interface NAME> (oif and iif accept string arguments and are converted to interface indexes) (oifname and iifname are more dynamic, but slower because of string matching)
  • 25. Match argumentsMatch arguments icmp: type <icmp type> icmpv6: type <icmpv6 type> ip: protocol <protocol> daddr <destination address> saddr <source address> ip6: daddr <destination address> saddr <source address>
  • 26. Match argumentsMatch arguments tcp: dport <destination port> sport <source port> udp: dport <destination port> sport <source port> ct: state <new | established | related | invalid>
  • 27. Load BalancingLoad Balancing IPv4 performanceIPv4 performance method req/sec %cpu LVS-SNAT 313427.91 24.11 NFT-SNAT 289035.54 23.2 NFT-DNAT 303356.59 23.12 LVS-DSR 356212.05 4.78 NFT-DSR 393672.35 0.54 DSR - Direct Server Return SLB - Server Load Balancing(SNAT/DNAT)
  • 28. Kernel configurationKernel configuration [*] Networking support ---> Networking options ---> [*] Network packet filtering framework (Netfilter) ---> Core Netfilter Configuration ---> <M> Netfilter nf_tables support <M> Netfilter nf_tables conntrack module <M> Netfilter nf_tables counter module <M> Netfilter nf_tables log module <M> Netfilter nf_tables limit module <M> Netfilter nf_tables masquerade support <M> Netfilter nf_tables nat module IP: Netfilter Configuration ---> <M> IPv4 nf_tables support <M> IPv4 nf_tables route chain support <M> IPv4 packet rejection <M> IPv4 NAT <M> IPv4 nf_tables nat chain support <M> IPv4 masquerade support <M> IPv4 masquerading support for nf_tables
  • 30. Marian HackMan Marinov <mm@1h.com> hackman @ irc.freenode.net https://github.com/hackman