使用正确的标志来代替--icmp-type?

使用正确的标志来代替--icmp-type?

我正在尝试在 Debian 11 Raspberry Pi 上设置 iptables v1.8.7 来阻止 ICMP 时间戳请求和答复。我正在关注的教程和我看过的所有其他论坛都说要使用标志--icmp-type,例如:

iptables -I INPUT -p icmp --icmp-type timestamp-request -j DROP

但是,当我运行此命令时,我收到错误iptables v1.8.7 (nf_tables): unknown option "--icmp-type"。我找不到替代此标志的替代方法 - 所有论坛都使用此标志,手册页甚至从未提及此标志。我尝试猜测正确的语法:

pi@fuelightcontrol:/etc $ iptables -I INPUT -p icmp --type timestamp-request -j DROP
iptables v1.8.7 (nf_tables): unknown option "--type"
Try `iptables -h' or 'iptables --help' for more information.
pi@fuelightcontrol:/etc $ iptables -I INPUT -p icmp -type timestamp-request -j DROP
iptables v1.8.7 (nf_tables): table 'ype' does not exist
Perhaps iptables or your kernel needs to be upgraded.
pi@fuelightcontrol:/etc $ iptables -I INPUT -p icmp --icmp-type 13 -j DROP
iptables v1.8.7 (nf_tables): unknown option "--icmp-type"
Try `iptables -h' or 'iptables --help' for more information.
pi@fuelightcontrol:/etc $ iptables -I INPUT -p icmp timestamp-request -j DROP
Bad argument `timestamp-request'
Try `iptables -h' or 'iptables --help' for more information.
pi@fuelightcontrol:/etc $ iptables -I INPUT -p icmp 13 -j DROP
Bad argument `13'
Try `iptables -h' or 'iptables --help' for more information.

有人能帮我找到该命令的正确语法吗iptables -I INPUT -p icmp --icmp-type timestamp-request -j DROP?感谢您的时间和考虑!

更新:我尝试使用sudo apt purge iptablesthen sudo apt autoremovethen重新安装 iptables sudo apt install iptables。没有成功,但现在我注意到虽然 iptables-persistent 已被卸载,但并未重新安装。如果需要,这应该是一个简单的修复。

答案1

编辑:没关系,这个没用。不过,这个也许对你有帮助,尽管它对我没有帮助:https://www.unix.com/linux/11290-linux-icmp-timestamp-requests.html

对于以后遇到这种情况的人:请改用 nftables!对我有用的是这个。# 是注释。

nft add table ip filter #create table. I would have needed to enter this, but the table was already created so I didn't have to. 
nft add chain ip filter INPUT { type filter hook input priority 0 \; } # create chain
nft insert rule ip filter INPUT icmp type timestamp-request counter drop
nft insert rule ip filter INPUT icmp type timestamp-reply counter drop
sudo systemctl start nftables
sudo systemctl enable nftables
#backup your old /etc/nftables.conf file first before continuing
sudo nft list ruleset > /etc/nftables.conf

相关内容