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

IPv4 identification field manipulation in linux

· 52CE 我爱测

When Don't Fragment flag is set, IPv4 RFC allows set Identification filed to 0x0000 . I got a peer which is behind firewall that brakes RFC and block any IPv4 packets with such 0x0000 ID field. My "modern" 4.4.0 linux kernel gene…

问题原文

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

When Don't Fragment flag is set, IPv4 RFC allows set Identification filed to 0x0000.

I got a peer which is behind firewall that brakes RFC and block any IPv4 packets with such 0x0000 ID field. My "modern" 4.4.0 linux kernel generates packets with ID 0x0000 thus I can't create TCP connection.

How can I disallow generating this 0x0000 ID or how to manipulate this field with iptables mangle or any another way?

已采纳解答

原帖链接 · A.B · CC BY-SA 4.0

You are probably refering to RFC 6864.

On a 4.17.x Linux I could see id = 0 only appear reliably for the SYN+ACK packet of a server answering a received connection, but not after.

UPDATE: OP confirmed that was the usual case in the Question too (with a 4.4.x kernel).

Probable minimal requirement: nftables v0.6 . notrack is not needed, conntrack entries don't care about this id.

For what it's worth, here's a nftables rule to alter the id value to the value 0xbeef when [DF] is set and id == 0. I don't think iptables is able to do this at all.

nft add table raw
nft 'add chain raw output {type filter hook output priority -300;}'
nft 'add rule raw output ip frag-off & 0x4000 != 0 ip id == 0 ip id set 0xbeef'    

0x4000 here means the DF flag.

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

资料来源与适用范围

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

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

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