ターミナルでのWi-fi経由のインターネット接続のトラブルシューティング方法について

Wi-fi経由でうまくインターネットに接続できない時のトラブルシューティング方法

そもそもWi-fiに接続できているかどうかの確認

ターミナルで

$ ifconfig

と入力すると

Kota[02:02:45]:documents $ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
	options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
	inet 127.0.0.1 netmask 0xff000000 
	inet6 ::1 prefixlen 128 
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
	nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
XHC20: flags=0<> mtu 0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	ether 08:6d:41:c2:18:d4 
	inet6 fe80::8cb:a5e:68fa:6be8%en0 prefixlen 64 secured scopeid 0x5 
	inet 192.168.3.9 netmask 0xffffff00 broadcast 192.168.3.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
	ether 0a:6d:41:c2:18:d4 
	media: autoselect
	status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
	ether 1a:46:bf:a5:da:31 
	inet6 fe80::1846:bfff:fea5:da31%awdl0 prefixlen 64 scopeid 0x7 
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=60<TSO4,TSO6>
	ether 9a:00:07:9a:cb:00 
	media: autoselect <full-duplex>
	status: inactive
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=63<RXCSUM,TXCSUM,TSO4,TSO6>
	ether 9a:00:07:9a:cb:00 
	Configuration:
		id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
		maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
		root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
		ipfilter disabled flags 0x2
	member: en1 flags=3<LEARNING,DISCOVER>
	        ifmaxaddr 0 port 8 priority 0 path cost 0
	nd6 options=201<PERFORMNUD,DAD>
	media: <unknown type>
	status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
	options=6403<RXCSUM,TXCSUM,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
	inet6 fe80::26cf:58ce:145:3b02%utun0 prefixlen 64 scopeid 0xa 
	nd6 options=201<PERFORMNUD,DAD>
utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	options=6403<RXCSUM,TXCSUM,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
	inet6 fe80::a4d5:2253:8d2e:5ca4%utun1 prefixlen 64 scopeid 0xb 
	nd6 options=201<PERFORMNUD,DAD>

このようにずらずらと現在接続しているWi-fiの情報が出てくる。一方で

$ ifconfig | grep broad

と入力すると

Kota[02:08:19]:documents $ ifconfig | grep broad
	inet 192.168.3.9 netmask 0xffffff00 broadcast 192.168.3.255

このように先ほどの情報の内、自分のPCのIPアドレスと接続しているWi-fiIPアドレスだけが抽出されて表示される。これでそもそもWi-Fiに接続できているか、接続しているならどのWi-Fiに接続しているのかが分かる。

Wi-Fi経由でインターネットに接続できているかの確認

さらに

$ ping 8.8.8.8

と入力すると

Kota[02:10:34]:documents $ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=58 time=117.653 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=58 time=59.169 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=58 time=42.861 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=58 time=42.504 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=58 time=71.117 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=58 time=60.194 ms

このように、ごく小さい64バイトの情報量をやり取りするのにかかる時間をリアルタイムで表示してくれ、「controlキー+C」で次のように結果をまとめて終了する。

^C
--- 8.8.8.8 ping statistics ---
6 packets transmitted, 6 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 42.504/65.583/117.653/25.367 ms