tcpdump net 用法疑问

2020-08-05 16:59:46 +08:00
 plko345
# 正常开始捕获
tcpdump net 65.192.0.0/10          # 1

# 报错: tcpdump: non-network bits set in "10.44.0.0/10"
tcpdump net 10.44.0.0/10            # 2

# 正常开始捕获
tcpdump net 10.44.0.0/14            # 3,   14 以上正常捕获

找到网上的说法是:

This is because the apparent intent of your rule is to exclude traffic from your local network, and the correct way to specify a network address is to specify the network's lowest IP address (which is called the network address) / netmask. If you specify any address other than the lowest address in the range for a network with a netmask of $myNetworkBytes, then you will get the error message:

man page 中的解释:

True if the IPv4/v6 address matches net with a netmask len bits wide. May be qualified with src or dst.

OK, 然后我还是没太明白(哭~), 有大佬解释下吗? 1 可以, 2 却不行, 3 为什么 14 就可以了, 不应该是 16 之后才可以吗?

1450 次点击
所在节点    问与答
5 条回复
hatebugs
2020-08-05 17:32:33 +08:00
44-= 00101100 14=8+6 。 老老实实先算好再用 net
mason961125
2020-08-05 17:59:09 +08:00
plko345
2020-08-05 18:23:22 +08:00
@hatebugs 谢谢, 那为什么 tcpdump 不支持 10.44.0.0/10 这种写法呢? 这种不就等于 10.0.0.0/10 吗?
gefranks
2020-08-05 20:57:39 +08:00
10.44.0.0/10 还真不等于 10.0.0.0/10 在我看来会产生 4 个子网 10.0.0.0/10, 10.64.0.0/10, 10.128.0.0/10, 10.192.0.0/10
这个 44 是落在第一个子网里的, 而写目标网络的时候是按一块一块来写的.
写主机地址的时候 10.44.0.0/10 是可以的,但是网络地址是不对的
plko345
2020-08-05 21:22:16 +08:00
@gefranks 谢谢, 大致明白了, 我再去复习下

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/695899

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX