我们知道,ipv6地址因为很长,中间如果都是0的场景下,可以压缩简写,例如:
3ffe:0000:0000:0000:1010:2a2a:0000:0001 可以简写压缩为:3ffe::1010:2a2a::0001
ipv4在telnet和ping使用的时候,也可以有类似的简写方式,我们来看一下:
- IP地址中间两个都是零的情况下,可以省略:
如127.0.0.1可以用127.1表示;10.0.0.2可以用10.2表示
[root@centos opt]# ping 127.1 PING 127.1 (127.0.0.1) 56(84) bytes of data. 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.027 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.030 ms 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.020 ms 64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.035 ms --- 127.1 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 112ms rtt min/avg/max/mdev = 0.020/0.028/0.035/0.005 ms [root@centos opt]# telnet 10.2 80 Trying 10.0.0.2... Connected to 10.0.0.2. Escape character is '^]'.
- IP地址倒数第二个是0,可以省略
如192.168.0.1可以用192.168.1表示;172.16.0.2可以用172.16.2表示
[root@centos opt]# ping 192.168.1 PING 192.168.1 (192.168.0.1) 56(84) bytes of data. 64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.036 ms 64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.044 ms 64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=0.075 ms 64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=0.037 ms --- 127.1 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 81ms rtt min/avg/max/mdev = 0.036/0.048/0.075/0.015 ms [root@centos opt]# telnet 172.16.2 80 Trying 172.16.0.2... Connected to 172.16.0.2. Escape character is '^]'.
当然这种方式只能用于telnet和ping,其他要填写IP地址的时候,是不能简写的!
文章评论