0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

8進数と10進数の混在(ping, telnet)

Last updated at Posted at 2021-12-18

192.168.012.1 が 192.168.12.1 ではない(ことがある)

今更ではある内容だが、ミスタイプしてtelnet アドレス直打ちのコマンドを叩いたら、おかしな挙動をしていたので、メモしておくそす。

ちなみにどうなるのかというと、192.168.012.1192.168.10.1 として解釈され実行される。

windows10_20H2
C:\Users\user> ping 192.168.012.1

192.168.10.1 に ping を送信しています 32 バイトのデータ:
Ctrl+C
^C
C:\Users\user>
CentOS7
[user@linux ~]$ ping 192.168.012.1
PING 192.168.012.1 (192.168.10.1) 56(84) bytes of data.
^C
--- 192.168.012.1 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999ms

[user@linux ~]$

お、どうやら、Linuxだけじゃなくて、WinNTでも再現するっぽい...

確認したのは以下の環境そす

  • Windows10 20H2
    • Microsoft Windows [Version 10.0.19042.1348]
  • CentOS Linux release 7.9.2009 (Core)
    • 3.10.0-1160.25.1.el7.x86_64
  • Ubuntu 20.04.3 LTS
    • 5.4.0-1045-raspi

ちなみにubuntu(raspi)は結果同じだったので省略

じゃあ、192.168.012 にtypoしたらどうなるのか

いわゆる、第4オクテットの入力せずにEnterKeyターンっしたパターン

C:\Users\user> ping 192.168.012

192.168.0.10 に ping を送信しています 32 バイトのデータ:
Ctrl+C
^C
C:\Users\user>
[user@linux ~]$ ping 192.168.012
PING 192.168.012 (192.168.0.10) 56(84) bytes of data.
^C
--- 192.168.012 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 1999ms

[user@linux ~]$

ん、192.168.012192.168.0.10 になった。

ドット無し10進数ってのもある

[user@linux ~]$ ping 3232238081
PING 3232238081 (192.168.10.1) 56(84) bytes of data.
^C
--- 3232238081 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1000ms

[user@linux ~]$ 

これは知ってた。
ちなみにブラウザでも http://3232238081/ ってやると、http://192.168.10.1/ に勝手に置き換わる。

ちなみにIPアドレス→10進数への変換は面倒だったので、そうゆうサイトを使った

あ、そういえば、さっきの8進数と10進数の混在アドレスをブラウザに打ち込んだらどうなるんだろうか。

://192.168.012.1

バージョン: 96.0.4664.110(Official Build) (64 ビット)

http://192.168.012.1/ ってやると、http://192.168.10.1/ ってなった。やっぱりOSレベル?カーネルレベル?で動いてるっぽい

他のOSではどうなるんだろうか

追加で Cisco-IOS で動作する Ciscoルータ(C891FJ/K9)(version: 15.4) と Junos で動作する Juniper(20.4R3.8) で確かめたら、Junosでは発生した。(出力結果がLinuxそのままだったので省略)

ちなみに、Ciscoでは置き換わりは起きなかった。うーんOS設計のレベルまで行くのかな。。。

cisco# ping 192.168.012.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.12.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
cisco#

参考までに

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?