TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Why does pinging 192.168.072 return a response from 192.168.0.58?

136 点作者 sathyabhat超过 12 年前

14 条评论

tzs超过 12 年前
Note that when you write an IP address in the form a.b.c, the c is actually allowed to be 16 bits. E.g., 192.168.2345, which is equivalent to 192.168.9.41.<p>Note also that telephone numbers in the US can be written in the form a.b.c, where a and b are 3 digits and c is four digits.<p>It would be really cool to get a matching telephone number and IP address, so you could print on your business card something like "Telephone and IP: 206.253.2317".
评论 #4647495 未加载
ojiikun超过 12 年前
It is a sad day for computing when<p>- hackers can't read an RFC<p>- hackers don't know octal<p>- hackers can't trial-and-error an interesting behaviour until they see a pattern and learn for themselves.
评论 #4648196 未加载
评论 #4647777 未加载
评论 #4647948 未加载
geophile超过 12 年前
072 octal = 58 decimal?<p>Seems to work. My localhost is 172.16.53.144 and pinging 172.020.53.144 works, returning 172.16.53.144.<p>Never knew that notation was supported.
评论 #4647203 未加载
gioele超过 12 年前
Have a look at this other answer by LarsH: &#60;<a href="http://superuser.com/a/486904/99285&#62;" rel="nofollow">http://superuser.com/a/486904/99285&#62;</a>. I think it is a much better more in-depth answer than the accepted one.
评论 #4646968 未加载
rachelbythebay超过 12 年前
All of those posts and no mention of strtol(), which is probably what's making this base-swapping behavior actually work? Oh well.<p><pre><code> $ ping 0x7f.0x0.0x0.0x1 PING 0x7f.0x0.0x0.0x1 (127.0.0.1): 56 data bytes</code></pre>
piffey超过 12 年前
You can use this in your web browser. Some really crappy local filters will also let you pass by using decimal/octal notation. Was a great trick in high school.
jnazario超过 12 年前
in this case it's octal in action. leading 0 causes the libc calls to expect non-decimal input (octal or hex, depending on what comes next).<p>a few organizations, FWIW, insist on writing decimal dotted quads zero padded (e.g. 192.168.19.20 becomes 192.168.019.020) for evan formatting. this barfs various tools and scripts that (not surprisingly) expect octal if they see a leading 0 and then barf on the non-octal-ness of the data OR get it wrong.<p>something to be aware of, especially if you script batch processing of inputs that include lists of IPs.
wmf超过 12 年前
This kind of non-obvious behavior seems like a dark side of Postel's Law.
评论 #4647188 未加载
Gilly_LDN超过 12 年前
Also, it is allowed in the ICMP standard, that a device can respond if it is pinged directly and also if its subnet broadcast address is pinged.
评论 #4648219 未加载
aw3c2超过 12 年前
That makes me want to own 222.173.190.239 or 177.107.0.181, just to link to them in hex. If only browsers would keep that in the address bar.
评论 #4647158 未加载
评论 #4647009 未加载
评论 #4647028 未加载
ashleyw超过 12 年前
I stumbled upon this by accident a couple of years ago. Setup your internal network to start at 10.0.0.1 (or should I say…10.1), and you'll never need to type out a bunch of zeros again! My NAS has a static IP of 10.2. :)
评论 #4648680 未加载
smackfu超过 12 年前
So has anyone ever intentionally used this feature?
评论 #4647246 未加载
6ren超过 12 年前
<p><pre><code> $ ping 10.010.0x10 PING 10.010.0x10 (10.8.0.16) 56(84) bytes of data.</code></pre>
mikiem超过 12 年前
I feel old. I have seven this question several times, but only every 3-5 years.