今天在配置防火墙的时候出现一些例外,搞了很久,终于发现自己写的脚本有问题,
一个多输入0,导致配置错误.
实际上比如如果输入192.168.1.011,实际上IP地址是192.168.1.9,011表示的是八进制.再举一些例子,假设IP=192.168.101.150
d:\tools>bc -l -q
obase=8
150
226
101
145
obase=16
150
96
101
65
quit
d:\tools>ping 192.168.101.0226
Pinging 192.168.101.150 with 32 bytes of data:
Reply from 192.168.101.150: bytes=32 time=16ms TTL=128
Ping statistics for 192.168.101.150:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 16ms, Maximum = 16ms, Average = 16ms
d:\tools>ping 192.168.101.0x96
Pinging 192.168.101.150 with 32 bytes of data:
Reply from 192.168.101.150: bytes=32 time=7ms TTL=128
Ping statistics for 192.168.101.150:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
ping 192.168.0145.150
ping 192.168.0x65.150
ping 192.168.0145.0226
ping 192.168.0x65.0226
ping 192.168.0x65.0x96
都是一样的.
d:\tools>bc -l -q
101*256+150
26006
168*256*256+101*256+150
11036054
192*256*256*256+168*256*256+101*256+150
3232261526
quit
ping 192.168.26006
ping 192.11036054
ping 3232261526
都是相同效果的!
一个多输入0,导致配置错误.
实际上比如如果输入192.168.1.011,实际上IP地址是192.168.1.9,011表示的是八进制.再举一些例子,假设IP=192.168.101.150
d:\tools>bc -l -q
obase=8
150
226
101
145
obase=16
150
96
101
65
quit
d:\tools>ping 192.168.101.0226
Pinging 192.168.101.150 with 32 bytes of data:
Reply from 192.168.101.150: bytes=32 time=16ms TTL=128
Ping statistics for 192.168.101.150:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 16ms, Maximum = 16ms, Average = 16ms
d:\tools>ping 192.168.101.0x96
Pinging 192.168.101.150 with 32 bytes of data:
Reply from 192.168.101.150: bytes=32 time=7ms TTL=128
Ping statistics for 192.168.101.150:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
ping 192.168.0145.150
ping 192.168.0x65.150
ping 192.168.0145.0226
ping 192.168.0x65.0226
ping 192.168.0x65.0x96
都是一样的.
d:\tools>bc -l -q
101*256+150
26006
168*256*256+101*256+150
11036054
192*256*256*256+168*256*256+101*256+150
3232261526
quit
ping 192.168.26006
ping 192.11036054
ping 3232261526
都是相同效果的!