關於IP地址的問題

lfree發表於2010-10-27
今天在配置防火牆的時候出現一些例外,搞了很久,終於發現自己寫的指令碼有問題,
一個多輸入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

都是相同效果的!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-676887/,如需轉載,請註明出處,否則將追究法律責任。

相關文章