LoginSignup
3
2

More than 5 years have passed since last update.

Bash on Ubuntu on Windowsでping/ポートスキャンをする

Posted at

Bash on Ubuntu on Windows(といいつつ、個人的にはzshで使っていますが…)ではpingすらできなくて、とても不便に感じていました。

ところが、実はBash on Ubuntu on Windowsでもpingやポートスキャンも出来る…ということで、その方法のご紹介です。

ping

Admin権限で起動してあげます。それだけです。「管理者として実行」でBash on Ubuntu on Windowsを起動します。(cmderの場合はコマンドラインの先頭に*をつけます)

$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=3.00 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=2.29 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=56 time=2.50 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=56 time=2.43 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=56 time=2.30 ms
^C
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 2.291/2.507/3.000/0.262 ms

ポートスキャン

Admin権限でもnmapは動きません。

$ nmap x.x.x.x

Starting Nmap 6.40 ( http://nmap.org ) at 2017-01-06 14:14 DST
Problem binding to interface , errno: 22
socket_bindtodevice: Invalid argument
NSOCK ERROR [1.0590s] mksock_bind_device(): Setting of SO_BINDTODEVICE failed (IOD #1): Invalid argument (22)
NSOCK ERROR [1.0600s] mksock_bind_device(): Setting of SO_BINDTODEVICE failed (IOD #2): Invalid argument (22)
NSOCK ERROR [1.0600s] mksock_bind_device(): Setting of SO_BINDTODEVICE failed (IOD #3): Invalid argument (22)
Problem binding to interface , errno: 22
socket_bindtodevice: Invalid argument
Problem binding to interface , errno: 22
socket_bindtodevice: Invalid argument

なので代わりにnc(netcat)を使います。こちらはAdmin権限でなくても動きます。

$ nc -vz x.x.x.x 20-23
nc: connect to x.x.x.x port 20 (tcp) failed: Connection refused
nc: connect to x.x.x.x port 21 (tcp) failed: Connection refused
Connection to x.x.x.x 22 port [tcp/ssh] succeeded!
nc: connect to x.x.x.x port 23 (tcp) failed: Connection refused

結果が長いので、開いてるポートだけ見るには

$ nc -vz x.x.x.x 20-23 2>&1|grep succeeded
Connection to x.x.x.x 22 port [tcp/ssh] succeeded!

その他

自分の場合は、その他、digwhoisあたりをよく使いますが、こちらは問題なく使えているのでワークアラウンドは不要です。

参考(というかまんまですが…)

3
2
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
3
2