For many years, Linux firewall management was dominated by iptables. It became the standard tool used by system administrators to protect servers, networks, and production environments. However, modern Linux systems introduced a new firewall framework: nftables. Designed as the successor to iptables, nftables provides a cleaner architecture, improved flexibility, better performance, and a unified approach to managing IPv4, IPv6, ARP, and other network protocols. Today, nftables is the recommended firewall framework for modern Linux distributions and an important skill for system administrators, DevOps engineers, and cybersecurity professionals. In this article, we will explore how nftables works, why it replaced iptables, and how to create a secure Linux firewall configuration. What is nftables? nftables is the modern Linux packet filtering framework built into the Linux kernel through the Netfilter subsystem. It replaces several older firewall management tools: iptables ip6tables arptables ebtables Instead of managing separate firewall systems for different protocols, nftables provides a single unified command: nft This makes firewall administration easier, especially in environments where IPv4 and IPv6 security must be managed together. The basic architecture looks like this: Applications | | nft command | | nftables ruleset | | Netfilter Framework | | Linux Kernel | | Network Interface Why was iptables replaced? iptables served Linux administrators well for many years, but its architecture had several limitations. Multiple firewall management tools Traditional Linux firewall administration required different tools: iptables ip6tables arptables ebtables Each tool handled different protocols, making configuration and automation more complicated. nftables combines these functions into one framework: nft More complex rule management iptables configurations could become difficult to maintain on larger systems. Example iptables rule: iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT The equivalent nftables rule is simpler: nft add rule inet filter input tcp dport 22 accept The nftables syntax is easier to read, automate, and manage with configuration tools. Understanding the nftables Architecture nftables is based on three main components: Tables Tables are containers used to organize firewall rules. Example: table inet firewall The inet family is especially useful because it allows the same ruleset to handle both IPv4 and IPv6 traffic. Chains Chains define where packets are inspected. Example: chain input { type filter hook input priority 0; policy drop; } Common chain hooks include: input output forward prerouting postrouting Rules Rules define what happens with network packets. Example: ip saddr 192.168.1.0/24 accept This allows traffic from a specific network. Installing nftables on Linux Debian and Ubuntu Install the package: sudo apt update sudo apt install nftables Enable the service: sudo systemctl enable nftables sudo systemctl start nftables Check the service status: systemctl status nftables Creating a Basic Secure nftables Firewall The main configuration file is: /etc/nftables.conf Example production-style firewall: #!/usr/sbin/nft -f flush ruleset table inet filter { chain input { type filter hook input priority 0; policy drop; iif lo accept ct state established,related accept tcp dport 22 accept ip protocol icmp accept ip6 nexthdr icmpv6 accept } chain forward { type filter hook forward priority 0; policy drop; } chain output { type filter hook output priority 0; policy accept; } } This configuration provides several important security features: blocks unsolicited incoming connections allows SSH administration allows existing sessions supports IPv4 and IPv6 diagnostics uses a default deny approach Managing nftables Rules Display the current firewall configuration: sudo nft list ruleset Add a new rule: sudo nft add rule inet filter input tcp dport 443 accept Delete a rule: sudo nft delete rule inet filter input handle 5 For production systems, firewall changes should always be documented and tested before deployment. Connection Tracking in nftables nftables integrates with Linux connection tracking. A common rule is: ct state established,related accept This allows: return traffic existing TCP sessions related connections Without connection tracking, administrators would need to manually define rules for every direction of communication. IPv6 Security with nftables One of the major advantages of nftables is native IPv6 support. Example: ip6 saddr 2001:db8::/32 accept Many organizations still focus mainly on IPv4 security while forgetting IPv6. This creates a potential security gap because attackers may use IPv6 paths that are not properly filtered. A modern firewall strategy must protect both protocols. Rate Limiting and Attack Protection nftables can help reduce automated attacks. Example SSH rate limiting: tcp dport 22 limit rate 5/minute accept This can reduce the impact of: brute-force attacks automated scanners suspicious connection attempts However, rate limiting should complement other security controls such as: SSH keys MFA VPN access intrusion detection systems Logging Suspicious Traffic Firewall logging is useful for security monitoring. Example: log prefix "NFT DROP: " drop Logs can be reviewed with: journalctl -k For enterprise environments, nftables logs can be integrated with: SIEM platforms monitoring systems security analytics tools nftables vs iptables Feature iptables nftables Architecture Legacy Modern IPv4/IPv6 handling Separate tools Unified framework Syntax Complex Cleaner Automation More difficult Easier Scalability Limited Better Future development Maintenance mode Active development nftables Security Best Practices Use a default deny policy A secure firewall should start with: policy drop; Only required services should be explicitly allowed. Protect SSH access Avoid exposing SSH unnecessarily. Recommended practices: use SSH keys instead of passwords restrict source IP addresses use VPN access enable monitoring Monitor firewall changes Firewall configuration changes should be tracked using tools such as: auditd journald configuration management systems Test firewall rules carefully Before applying changes on remote servers: sudo nft list ruleset Always ensure that administrative access will not be accidentally blocked. nftables in Modern Infrastructure nftables is especially valuable in modern environments: Linux servers cloud infrastructure containers DevOps pipelines security laboratories enterprise networks Combined with tools such as Docker, Kubernetes, WireGuard, and Linux security frameworks, nftables becomes an important part of a layered security strategy. Conclusion nftables represents the modern approach to Linux firewall management. Compared to iptables, it provides: unified IPv4 and IPv6 support cleaner configuration improved automation better scalability modern firewall architecture For Linux administrators, DevOps engineers, and cybersecurity professionals, understanding nftables is an essential skill for securing modern infrastructure.
Why Linux Firewalls Are Moving From iptables to nftables
Full Article
Original Source
Read the full article at Hackernoon →KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.