Troubleshooting NFTables: Not Dropping Packets

Abstract: Resolve NFTables failing to drop packets by placing simple Layer 3 drop rules in the correct input or forward chain before any accept rules.

Created: 2026-09-22 by
NFTables fails to drop packets when rules are incorrectly placed in routing chains or use overly complex match criteria that bypass the filter table. The most effective solution is to implement a simple drop rule within the appropriate input or forward chain, ensuring it precedes any accept rules. This approach leverages Layer 3 filtering for immediate packet rejection without relying on higher-level protocol matches.

Understanding NFTables Chain Placement

A common reason for packet dropping failures in nftables is placing drop rules in the wrong chain type. Unlike iptables, which often encourages users to manipulate the INPUT, OUTPUT, and FORWARD chains directly, nftables uses a more flexible hook-based system. If you are trying to block traffic destined for your local machine, you must place the rule in the input hook of the filter table. Placing it in the route hook or the postrouting hook will not work for inbound traffic because those hooks occur after the routing decision has already been made or after the packet has left the local stack.

The hierarchy matters significantly. The prerouting hook processes packets before routing decisions, while the input hook handles packets destined for the local host. If you attempt to drop a packet at the forward hook, it only affects traffic passing through the device, not traffic intended for the device itself. Misidentifying the hook leads to silent failures where packets appear to be accepted despite existing rules.

Implementing Simple Layer 3 Drop Rules

To resolve this issue, simplify your rule set by focusing on Layer 3 (Network Layer) attributes rather than Layer 4 (Transport Layer) details. Dropping based on IP address or protocol is faster and less prone to errors than dropping based on ports or states if the connection tracking is not fully established. A basic rule to drop all IPv4 traffic from a specific source IP should look like this:

nft add rule ip filter input ip saddr 192.168.1.100 drop

This command adds a rule to the ip family, specifically the filter table, in the input chain. It matches packets with a source address of 192.168.1.100 and immediately drops them. Notice that we do not need to specify a port or protocol. By keeping the match criteria minimal, you ensure that the packet is evaluated against this rule early in the processing pipeline. If you have multiple IPs to block, you can group them into an IP set for better performance and manageability.

For IPv6 traffic, the syntax is similar but uses the ip6 family. You might also consider using named sets to manage large lists of blocked addresses dynamically. This reduces the number of individual rules in the chain, improving lookup speeds. For more advanced configurations involving dynamic IP changes, such as remote access scenarios, you may want to explore how to Match Traffic Destination MAC using nftables for Remote IPv6 LAN Access with Dynamic IP to maintain security without manual rule updates.

Debugging Rule Evaluation Order

If your drop rules still fail, the problem is likely rule ordering. nftables evaluates rules sequentially within a chain. The first matching rule determines the fate of the packet. If an accept rule appears before your drop rule, the packet will be allowed, and the drop rule will never be reached. Always verify the order of your rules using the list command.

nft list ruleset

Examine the output carefully. Look for the position of your drop rule relative to other rules. If you see an accept rule for a broader range (e.g., ip saddr 192.168.1.0/24) before your specific drop rule for 192.168.1.100, you must reorder them. You can delete the incorrect rule and re-add it in the correct position, or use the nft insert command to place the rule at the top of the chain.

Additionally, check for implicit accept policies. If your chain policy is set to accept, packets that do not match any rule will be accepted. Ensure your chain policy is set to drop or reject if you want a default deny stance, and then explicitly allow necessary traffic. However, even with a drop policy, explicit accept rules can override subsequent drop rules if ordered incorrectly.

Handling Stateful Filtering Issues

Sometimes, administrators try to drop packets based on connection state, such as ct state invalid. While this is a valid strategy, it can sometimes lead to confusion if the connection tracking subsystem is not functioning as expected. In some cases, packets that appear "invalid" to the tracker might still be processed by the kernel networking stack before the drop rule is hit, depending on the hook placement. For straightforward blocking tasks, avoid relying on ct state unless you are dealing with fragmented packets or specific attack patterns.

If you are redirecting local requests to different IPs, understanding how nftables handles NAT and redirection is crucial. Incorrectly configured redirection rules can mask the fact that a drop rule is working, leading to false positives in troubleshooting. For insights on managing traffic redirection, refer to our guide on how to Redirect Local Requests to IP to Other IP (Linux). This ensures that your filtering rules are not being bypassed by unexpected NAT transformations.

Verifying Packet Drops with Logging

To confirm whether your drop rules are active, enable logging for the specific chain or rule. Add a log rule before your drop rule to see what packets are hitting it.

nft add rule ip filter input ip saddr 192.168.1.100 log prefix "DROP: " drop

Check your system logs (dmesg or /var/log/syslog) for entries prefixed with DROP:. If you see these entries, your rule is working correctly, and the issue lies elsewhere, such as application-level behavior or network path anomalies. If you do not see logs, the packet is likely being dropped by a different mechanism or is not reaching the chain you expect.

Frequently Asked Questions

Why does my nftables drop rule work for ping but not for web traffic?

This usually indicates that the web traffic is being handled by a different chain or table, possibly due to conntrack states allowing established connections. Ensure your drop rule is placed in the correct hook (input or forward) and that it does not rely on state tracking that might bypass it for existing sessions.

Can I use nftables to drop packets based on MAC address?

Yes, you can match on MAC addresses using the ether keyword in the bridge or arp families, but it is generally recommended to stick to IP-based filtering for Layer 3 devices. MAC filtering is more efficient in bridge tables but requires careful consideration of hardware offloading features.

How do I make my nftables rules persistent across reboots?

Save your current ruleset to a configuration file using nft list ruleset > /etc/nftables.conf. Most modern Linux distributions automatically load this file during boot via a systemd service or init script. Verify that the service is enabled and running.

What is the difference between drop and reject in nftables?

drop silently discards the packet without sending any response, which can cause timeouts on the client side. reject sends an ICMP error message back to the sender, providing immediate feedback that the connection was refused. Use reject for interactive services and drop for stealthier blocking.

Why are my IPv6 drop rules not working while IPv4 ones do?

IPv6 rules reside in the ip6 family, separate from the ip family used for IPv4. Ensure you are creating rules in the correct table family. Additionally, check if IPv6 is disabled on the interface or if firewall rules are being overridden by SELinux or AppArmor profiles.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More