大网数据广告活动
服务器运维问答

nftables reject resulting in a drop verdict instead

· 52CE 我爱测

I have nftables setup to reject packets that don't match my allow block ( nft list ruleset added below), but the packets are being dropped instead. For context, I have a service that listens on port 8080 that only localhost shoul…

问题原文

原帖链接 · ricekab · CC BY-SA 4.0

I have nftables setup to reject packets that don't match my allow block (nft list ruleset added below), but the packets are being dropped instead.

For context, I have a service that listens on port 8080 that only localhost should have access to (for now). My setup allows that but clients are timing out with their requests instead of getting a reject.

This is the ruleset I'm using (slightly truncated for brevity), including the traces I've used for debugging:

# nft list ruleset
table inet firewall {
    set allowed_protocols {
            type inet_proto
            elements = { icmp, ipv6-icmp }
    }

    set allowed_interfaces {
            type ifname
            elements = { "lo" }
    }

    set allowed_tcp_dports {
            type inet_service
            elements = { 22, 80, 443 }
    }

    chain allow {
            ct state established,related accept
            meta l4proto @allowed_protocols accept
            iifname @allowed_interfaces accept
            meta nftrace set 1
            tcp dport @allowed_tcp_dports accept
    }

    chain input {
            type filter hook input priority 20; policy accept;
            jump allow
            meta nftrace set 1
            reject
    }

    chain forward {
            type filter hook forward priority 20; policy accept;
            jump allow
            meta nftrace set 1
            reject
    }
}

From my trace, I can see packets being dropped instead:

trace id 36f72c1b inet firewall allow rule meta nftrace set 1 (verdict continue)
trace id 36f72c1b inet firewall allow verdict continue
trace id 36f72c1b inet firewall input rule meta nftrace set 1 (verdict continue)
trace id 36f72c1b inet firewall input rule reject (verdict drop)

It explicitly reads reject but then decided to drop anyway. Any idea what the cause for this is?

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

Seeing verdict drop in the trace is normal. The reject still sends the proper ICMP error, not simply dropping the packet. You can fire up Wireshark and look at them if you wish to be sure. Yes, this is confusing.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-09-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。