是否有可能使用iptables截断数据包?

设置新的Linux服务器(专用或VPS)时,我首先想到的是如何提高安全性。 我想知道是否有可能使用iptables来截断icmp数据包。

如果使用ping -s发送数据包ping -s -s选项代表数据包大小。

 #>ping www.google.com -s 100 PING www.google.com (216.58.209.164) 100(128) bytes of data. 72 bytes from bud02s21-in-f164.1e100.net (216.58.209.164): icmp_seq=1 ttl=56 (truncated) 72 bytes from bud02s21-in-f164.1e100.net (216.58.209.164): icmp_seq=2 ttl=56 (truncated) 

你看我是怎么试着发送100个字节的数据包,以及Google如何优雅地截断这72个字节作为回报。

这可能使用iptables来做同样的事情吗? 也许使用一些iptables模块…

从我在我的内核4.2.0研究,可能不是最新的… https://www.kernel.org/finger_banner

没有像xt-TRUNCATE.h或者xt-CUT.h这样的iptables(netfilter)目标模块,这个模块可以完成截断数据包的工作,理想情况是在mangle表的某个地方。

花了我一段时间来分析http://ipset.netfilter.org/iptables-extensions.man.html来确认。

但是,创build这样一个模块的过程不应该是非常困难的。 这将需要大概200行代码或更less,因为这看起来像所有iptables目标模块的平均值。