Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
linux下如何基于tcp选项域进行丢包_Linux_Networking_Linux Kernel_Iptables_Tcp Ip - Fatal编程技术网

linux下如何基于tcp选项域进行丢包

linux下如何基于tcp选项域进行丢包,linux,networking,linux-kernel,iptables,tcp-ip,Linux,Networking,Linux Kernel,Iptables,Tcp Ip,我想删除基于TCP选项字段的Linux主机的传入流量。 类似于TCP选项30多路径TCP。 如果数据包包含多路径tcp表示法或选项字段30,则我的Linux主机需要断开连接或数据包 我的设置是主机1主机2主机3。 主机1通过主机2向主机3发送数据包。 主机2有两个接口eth0和eth1。 eth0连接主机1,eth1连接主机3。 当传入的eth 0数据包包含选项字段30时,我只想取消连接或丢弃数据包 我尝试了iptablesstring比较,但没有成功 命令是, sudo iptables -I

我想删除基于TCP选项字段的Linux主机的传入流量。 类似于TCP选项30多路径TCP。 如果数据包包含多路径tcp表示法或选项字段30,则我的Linux主机需要断开连接或数据包

我的设置是主机1主机2主机3。 主机1通过主机2向主机3发送数据包。 主机2有两个接口eth0和eth1。 eth0连接主机1,eth1连接主机3。 当传入的eth 0数据包包含选项字段30时,我只想取消连接或丢弃数据包

我尝试了
iptables
string比较,但没有成功

命令是,

sudo iptables -I INPUT -j DROP -p tcp -s 0.0.0.0/0 -m string --string "Multipath TCP" --algo bm.
但上述规则并不阻止通过主机2 eth0、eth1发送和接收多路径TCP。 主机2无法丢弃多路径TCP(选项字段30)通信。
是否可以根据选项字段删除指定的TCP数据包。

首先,您需要在host2上的转发链中添加规则(原因是数据包不是针对host2的,不会命中输入链)

iptables
中有一个选项可用于匹配TCP选项。请尝试以下
iptables
命令:

iptables -I FORWARD -p tcp --tcp-option 30 -j DROP