ping -m 选项有什么用?我阅读了 ping 手册页,但无法理解。谷歌搜索后,我看到如果使用 -m 选项,则会将 SO_MARK 选项添加到套接字。那么,这个选项有什么用,什么时候用呢?
提前致谢。
最佳答案
在 Linux 上,SO_MARK用于标记传出数据包:
SO_MARK (since Linux 2.6.25) Set the mark for each packet sent through this socket (similar to the netfilter MARK target but socket-based). Changing the mark can be used for mark-based routing without netfilter or for packet filtering. Setting this option requires the CAP_NET_ADMIN capability.
因此,如果您使用该选项执行 ping 操作:
$ping -m 10 <host>
然后可以在 <host>
上使用 iptables 对其进行过滤:
$iptables -A INPUT -m mark --mark 0xa -j ACCEPT
或直接在代码中使用 getsockopt()
.
它可以用于多种原因,例如路由决策或网络调试。
关于linux - 在 ping 中使用 -m 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36856897/