linux – Ping并使用三个八位位组的ipv4地址.它为什么有效?
发布时间:2020-12-13 22:57:04 所属栏目:Linux 来源:网络整理
导读:偶然我有一个错字,并发现我可以ping和ssh到IP地址10.8.290 …正确的一个八位字节丢失.有人可以向我解释一下吗?这是协议的一部分还是一些 linux-black-magic(我使用的是Debian)? user@ws:~$ping -c3 10.8.290PING 10.8.290 (10.8.1.34) 56(84) bytes of dat
偶然我有一个错字,并发现我可以ping和ssh到IP地址10.8.290 …正确的一个八位字节丢失.有人可以向我解释一下吗?这是协议的一部分还是一些
linux-black-magic(我使用的是Debian)?
user@ws:~$ping -c3 10.8.290 PING 10.8.290 (10.8.1.34) 56(84) bytes of data. 64 bytes from 10.8.1.34: icmp_req=1 ttl=62 time=0.910 ms 64 bytes from 10.8.1.34: icmp_req=2 ttl=62 time=0.686 ms 64 bytes from 10.8.1.34: icmp_req=3 ttl=62 time=0.708 ms --- 10.8.290 ping statistics --- 3 packets transmitted,3 received,0% packet loss,time 1998ms rtt min/avg/max/mdev = 0.686/0.768/0.910/0.100 ms user@ws:~$ssh root@10.8.290 The authenticity of host '10.8.290 (10.8.1.34)' can't be established. ECDSA key fingerprint is 21:bd:7e:fb:1e:6d:1e:c1:e9:11:c0:a9:73:a8:cf:85. Are you sure you want to continue connecting (yes/no)? no Host key verification failed. 解决方法
它的工作原理是因为你在ip地址的第三个字节使用值290.一个字节可以存储0到255之间的值,给出256个值.由于IPv4地址是4字节值,因此将290传递到第三字节导致整数溢出到第4字节 – > 290 – 256 => 34
它与协议“功能”无关. ping只是不验证目标命令行参数的各个八位字节的值,只是将它传递给较低级别??的C函数inet_aton()(aton表示ascii为number).这导致ping 10.8.1.34. 我不确定,但我希望其他版本的ping(在Windows上,BSD)表现相同. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |