用tcpdump可以抓取某个ip地址范围内的报文。例如:
抓取目的地址范围是192.168.1.10 ~ 192.168.1.100
的报文使用命令:
tcpdump -n -nn 'ip[16] == 192 and ip[17] == 168 and ip[18] == 1 and ip[19] > 9 and ip[19] < 101'
ip[16]是取得ip协议偏移为16的那个字节的值。这个
方法也可用于其他协议,例如:
icmp[0], icmp[1]是取得icmp协议偏移是0或1的值。
我要抓取ping命令发出和接收报文,我可以用这样的命令:
tcpdump 'icmp and (icmp[0] == 0 or icmp[0] == 8)'
抓取目的地址范围是192.168.1.10 ~ 192.168.1.100
的报文使用命令:
tcpdump -n -nn 'ip[16] == 192 and ip[17] == 168 and ip[18] == 1 and ip[19] > 9 and ip[19] < 101'
ip[16]是取得ip协议偏移为16的那个字节的值。这个
方法也可用于其他协议,例如:
icmp[0], icmp[1]是取得icmp协议偏移是0或1的值。
我要抓取ping命令发出和接收报文,我可以用这样的命令:
tcpdump 'icmp and (icmp[0] == 0 or icmp[0] == 8)'