6.1 ネットワークの設定
6.1.1 ネットワークデバイス
インタフェース名
ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1460
inet 10.146.0.4 netmask 255.255.255.255 broadcast 10.146.0.4
inet6 fe80::4001:aff:fe92:4 prefixlen 64 scopeid 0x20<link>
ether 42:01:0a:92:00:04 txqueuelen 1000 (Ethernet)
RX packets 239 bytes 49027 (47.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 218 bytes 26649 (26.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 80 bytes 4000 (3.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 80 bytes 4000 (3.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
-
eth0
- 1番目のイーサネットインタフェース
-
ppp0
- 1番目のPPPインタフェース
-
lo
- ループバックインタフェース
最近の命名規則は違う模様: https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
-
enp5s0
en
: ethernetp5
: PCI 5番バスs0
: PCI 0番スロット
ネットワークインタフェースの設定
ifconfig: 設定確認・設定
- レガシーコマンド
ifconfig lo
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 82 bytes 4168 (4.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 82 bytes 4168 (4.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ネットマスクに/32を設定してみる
sudo ifconfig lo netmask 255.255.255.255
ping -c 1 127.0.0.2
127.0.0.1/32から127.0.0.2/32へは疎通できなくなる
PING 127.0.0.2 (127.0.0.2) 56(84) bytes of data.
C-c C-c
--- 127.0.0.2 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
/30で再設定
sudo ifconfig lo netmask 255.255.255.252
ping -c 1 127.0.0.2
疎通
PING 127.0.0.2 (127.0.0.2) 56(84) bytes of data.
64 bytes from 127.0.0.2: icmp_seq=1 ttl=64 time=0.070 ms
--- 127.0.0.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.070/0.070/0.070/0.000 ms
- ifup: ネットワークインタフェース有効化
- ifdown: ネットワークインタフェース無効化
sudo ifdown lo
ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1460
inet 10.146.0.4 netmask 255.255.255.255 broadcast 10.146.0.4
inet6 fe80::4001:aff:fe92:4 prefixlen 64 scopeid 0x20<link>
ether 42:01:0a:92:00:04 txqueuelen 1000 (Ethernet)
RX packets 2456 bytes 27496548 (26.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2200 bytes 174271 (170.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
127.0.0.1の疎通は無くなる
ping -c 1 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
C-c C-c
--- 127.0.0.1 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
ifconfig {up|down}
でも有効化/無効化可能
sudo ifconfig lo up
ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1460
inet 10.146.0.4 netmask 255.255.255.255 broadcast 10.146.0.4
inet6 fe80::4001:aff:fe92:4 prefixlen 64 scopeid 0x20<link>
ether 42:01:0a:92:00:04 txqueuelen 1000 (Ethernet)
RX packets 3344 bytes 27709354 (26.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3023 bytes 258110 (252.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 88 bytes 4672 (4.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 88 bytes 4672 (4.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
MACアドレス
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1460
inet 10.146.0.4 netmask 255.255.255.255 broadcast 10.146.0.4
inet6 fe80::4001:aff:fe92:4 prefixlen 64 scopeid 0x20<link>
ether 42:01:0a:92:00:04 txqueuelen 1000 (Ethernet)
RX packets 3344 bytes 27709354 (26.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3023 bytes 258110 (252.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ether 42:01:0a:92:00:04
これ
IPエイリアシング
sudo ifconfig eth0:0 192.168.1.1 netmask 255.255.255.0 up
ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1460
inet 10.146.0.4 netmask 255.255.255.255 broadcast 10.146.0.4
inet6 fe80::4001:aff:fe92:4 prefixlen 64 scopeid 0x20<link>
ether 42:01:0a:92:00:04 txqueuelen 1000 (Ethernet)
RX packets 3413 bytes 27726676 (26.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3087 bytes 265461 (259.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1460
inet 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255
ether 42:01:0a:92:00:04 txqueuelen 1000 (Ethernet)
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 88 bytes 4672 (4.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 88 bytes 4672 (4.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
仮想ネットワークインタフェースを作成して異なるIPアドレスを振ることができる
【補】macOSなんかではこう
sudo ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.0
127.0.0.1
以外の127.*.*.*
でローカルループバックしたいときに使用する
- 同じポート番号でサーバーを複数動かしたい場合とか
6.1.2 ARP
arp
: ARPキャッシュ確認・編集
arp
Address HWtype HWaddress Flags Mask Iface
gateway ether 42:01:0a:92:00:01 C eth0
-n
: numeric
- 名前を逆引きしない
- ネットワーク系コマンド全般で使える
arp -n
Address HWtype HWaddress Flags Mask Iface
10.146.0.1 ether 42:01:0a:92:00:01 C eth0
6.1.3 ネットワーク管理コマンド
ping/ping6
2秒intervalで3 count、numeric
ping -c 3 -i 2 -n google.com
PING google.com (216.58.220.110) 56(84) bytes of data.
64 bytes from 216.58.220.110: icmp_seq=1 ttl=122 time=1.67 ms
64 bytes from 216.58.220.110: icmp_seq=2 ttl=122 time=1.88 ms
64 bytes from 216.58.220.110: icmp_seq=3 ttl=122 time=1.77 ms
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 1.677/1.778/1.887/0.098 ms
ping6
: IPv6
ping -6
と同じ- 勉強環境ではIPv6でインターネットへの疎通がなかったのでローカルループバックで遊ぶ
ping6 -c 1 localhost
PING localhost(localhost (::1)) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.091 ms
--- localhost ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.091/0.091/0.091/0.000 ms
traceroute
traceroute
-bash: traceroute: command not found
ないので入れる
yum provides traceroute
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* epel: d2lzkl7pfhq30w.cloudfront.net
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
3:traceroute-2.0.22-2.el7.x86_64 : Traces the route taken by packets over an
: IPv4/IPv6 network
Repo : base
sudo yum install -y traceroute
traceroute --version
Modern traceroute for Linux, version 2.0.22
Copyright (c) 2008 Dmitry Butskoy, License: GPL v2 or any later
lpic.jp
のサーバまでの経路を調べる
traceroute lpic.jp
traceroute to lpic.jp (163.44.187.20), 30 hops max, 60 byte packets
1 209.85.241.8 (209.85.241.8) 2.768 ms 2.865 ms 4.786 ms
2 as7506.ix.jpix.ad.jp (210.171.224.65) 4.595 ms 4.634 ms 4.867 ms
3 150.95.5.62 (150.95.5.62) 5.218 ms 6.580 ms 5.191 ms
4 150.95.5.134 (150.95.5.134) 5.657 ms 5.036 ms 5.027 ms
5 unused-133-130-015-158.interq.or.jp (133.130.15.158) 11.764 ms 12.397 ms 11.687 ms
6 www7.conoha.ne.jp (163.44.187.20) 4.217 ms !X 3.291 ms !X 2.250 ms !X
ICMPパケットを使用するので、途中でICMPに応答しないホストがいると正常動作しない
-i
: interface指定
sudo traceroute -i eth0:0 lpic.jp
(同じ)
tcpdump
tcpdump --version
-bash: tcpdump: command not found
ないので入れる
yum provides tcpdump
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp-srv2.kddilabs.jp
* epel: d2lzkl7pfhq30w.cloudfront.net
* extras: ftp-srv2.kddilabs.jp
* updates: ftp-srv2.kddilabs.jp
14:tcpdump-4.9.2-4.el7_7.1.x86_64 : A network traffic monitoring tool
Repo : base
sudo yum install -y tcpdump
tcpdump --version
tcpdump version 4.9.2
libpcap version 1.5.3
OpenSSL 1.0.2k-fips 26 Jan 2017
tcpdumpを実行すると、ネットワークデバイスはpromiscuous(無差別)モードで動作する。つまり、自分宛以外のパケットも受け取る
自分宛てのICMPを監視してみる
sudo tcpdump -nli lo icmp &
ping -c 1 localhost > /dev/null
10:32:53.593709 IP 127.0.0.1 > 127.0.0.1: ICMP echo request, id 2837, seq 1, length 64
10:32:53.593740 IP 127.0.0.1 > 127.0.0.1: ICMP echo reply, id 2837, seq 1, length 64
自分宛ての80番HTTPアクセスを監視してみる
sudo python -m SimpleHTTPServer 80 &
sudo tcpdump -Xli lo port 80 &
curl http://localhost > /dev/null 2&>1
HTTPサーバー(Python)のstdout
127.0.0.1 - - [19/Dec/2020 10:42:36] "GET / HTTP/1.1" 200 -
tcpdumpのstdout
10:42:36.438054 IP6 localhost.60654 > localhost.http: Flags [S], seq 3516837790, win 43690, options [mss 65476,sackOK,TS val 6017904 ecr 0,nop,wscale 7], length 0
0x0000: 6000 0000 0028 0640 0000 0000 0000 0000 `....(.@........
0x0010: 0000 0000 0000 0001 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0001 ecee 0050 d19e af9e ...........P....
0x0030: 0000 0000 a002 aaaa 0030 0000 0204 ffc4 .........0......
0x0040: 0402 080a 005b d370 0000 0000 0103 0307 .....[.p........
10:42:36.438080 IP6 localhost.http > localhost.60654: Flags [R.], seq 0, ack 3516837791, win 0, length 0
0x0000: 6000 0000 0014 0640 0000 0000 0000 0000 `......@........
0x0010: 0000 0000 0000 0001 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0001 0050 ecee 0000 0000 .........P......
0x0030: d19e af9f 5014 0000 001c 0000 ....P.......
10:42:36.438183 IP localhost.40822 > localhost.http: Flags [S], seq 1402775929, win 43690, options [mss 65495,sackOK,TS val 6017904 ecr 0,nop,wscale 7], length 0
0x0000: 4500 003c 7a09 4000 4006 c2b0 7f00 0001 E..<z.@.@.......
0x0010: 7f00 0001 9f76 0050 539c a979 0000 0000 .....v.PS..y....
0x0020: a002 aaaa fe30 0000 0204 ffd7 0402 080a .....0..........
0x0030: 005b d370 0000 0000 0103 0307 .[.p........
10:42:36.438207 IP localhost.http > localhost.40822: Flags [S.], seq 3495335718, ack 1402775930, win 43690, options [mss 65495,sackOK,TS val 6017904 ecr 6017904,nop,wscale 7], length 0
0x0000: 4500 003c 0000 4000 4006 3cba 7f00 0001 E..<..@.@.<.....
0x0010: 7f00 0001 0050 9f76 d056 9726 539c a97a .....P.v.V.&S..z
0x0020: a012 aaaa fe30 0000 0204 ffd7 0402 080a .....0..........
0x0030: 005b d370 005b d370 0103 0307 .[.p.[.p....
10:42:36.438222 IP localhost.40822 > localhost.http: Flags [.], ack 1, win 342, options [nop,nop,TS val 6017904 ecr 6017904], length 0
0x0000: 4500 0034 7a0a 4000 4006 c2b7 7f00 0001 E..4z.@.@.......
0x0010: 7f00 0001 9f76 0050 539c a97a d056 9727 .....v.PS..z.V.'
0x0020: 8010 0156 fe28 0000 0101 080a 005b d370 ...V.(.......[.p
0x0030: 005b d370 .[.p
10:42:36.438330 IP localhost.40822 > localhost.http: Flags [P.], seq 1:74, ack 1, win 342, options [nop,nop,TS val 6017905 ecr 6017904], length 73: HTTP: GET / HTTP/1.1
0x0000: 4500 007d 7a0b 4000 4006 c26d 7f00 0001 E..}z.@.@..m....
0x0010: 7f00 0001 9f76 0050 539c a97a d056 9727 .....v.PS..z.V.'
0x0020: 8018 0156 fe71 0000 0101 080a 005b d371 ...V.q.......[.q
0x0030: 005b d370 4745 5420 2f20 4854 5450 2f31 .[.pGET./.HTTP/1
0x0040: 2e31 0d0a 5573 6572 2d41 6765 6e74 3a20 .1..User-Agent:.
0x0050: 6375 726c 2f37 2e32 392e 300d 0a48 6f73 curl/7.29.0..Hos
0x0060: 743a 206c 6f63 616c 686f 7374 0d0a 4163 t:.localhost..Ac
0x0070: 6365 7074 3a20 2a2f 2a0d 0a0d 0a cept:.*/*....
10:42:36.438340 IP localhost.http > localhost.40822: Flags [.], ack 74, win 342, options [nop,nop,TS val 6017905 ecr 6017905], length 0
0x0000: 4500 0034 4457 4000 4006 f86a 7f00 0001 E..4DW@.@..j....
0x0010: 7f00 0001 0050 9f76 d056 9727 539c a9c3 .....P.v.V.'S...
0x0020: 8010 0156 fe28 0000 0101 080a 005b d371 ...V.(.......[.q
0x0030: 005b d371 .[.q
10:42:36.439854 IP localhost.http > localhost.40822: Flags [P.], seq 1:18, ack 74, win 342, options [nop,nop,TS val 6017906 ecr 6017905], length 17: HTTP: HTTP/1.0 200 OK
0x0000: 4500 0045 4458 4000 4006 f858 7f00 0001 E..EDX@.@..X....
0x0010: 7f00 0001 0050 9f76 d056 9727 539c a9c3 .....P.v.V.'S...
0x0020: 8018 0156 fe39 0000 0101 080a 005b d372 ...V.9.......[.r
0x0030: 005b d371 4854 5450 2f31 2e30 2032 3030 .[.qHTTP/1.0.200
0x0040: 204f 4b0d 0a .OK..
10:42:36.439873 IP localhost.40822 > localhost.http: Flags [.], ack 18, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 0
0x0000: 4500 0034 7a0c 4000 4006 c2b5 7f00 0001 E..4z.@.@.......
0x0010: 7f00 0001 9f76 0050 539c a9c3 d056 9738 .....v.PS....V.8
0x0020: 8010 0156 fe28 0000 0101 080a 005b d372 ...V.(.......[.r
0x0030: 005b d372 .[.r
10:42:36.439915 IP localhost.http > localhost.40822: Flags [P.], seq 18:55, ack 74, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 37: HTTP
0x0000: 4500 0059 4459 4000 4006 f843 7f00 0001 E..YDY@.@..C....
0x0010: 7f00 0001 0050 9f76 d056 9738 539c a9c3 .....P.v.V.8S...
0x0020: 8018 0156 fe4d 0000 0101 080a 005b d372 ...V.M.......[.r
0x0030: 005b d372 5365 7276 6572 3a20 5369 6d70 .[.rServer:.Simp
0x0040: 6c65 4854 5450 2f30 2e36 2050 7974 686f leHTTP/0.6.Pytho
0x0050: 6e2f 322e 372e 350d 0a n/2.7.5..
10:42:36.439925 IP localhost.40822 > localhost.http: Flags [.], ack 55, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 0
0x0000: 4500 0034 7a0d 4000 4006 c2b4 7f00 0001 E..4z.@.@.......
0x0010: 7f00 0001 9f76 0050 539c a9c3 d056 975d .....v.PS....V.]
0x0020: 8010 0156 fe28 0000 0101 080a 005b d372 ...V.(.......[.r
0x0030: 005b d372 .[.r
10:42:36.439967 IP localhost.http > localhost.40822: Flags [P.], seq 55:92, ack 74, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 37: HTTP
0x0000: 4500 0059 445a 4000 4006 f842 7f00 0001 E..YDZ@.@..B....
0x0010: 7f00 0001 0050 9f76 d056 975d 539c a9c3 .....P.v.V.]S...
0x0020: 8018 0156 fe4d 0000 0101 080a 005b d372 ...V.M.......[.r
0x0030: 005b d372 4461 7465 3a20 5361 742c 2031 .[.rDate:.Sat,.1
0x0040: 3920 4465 6320 3230 3230 2031 303a 3432 9.Dec.2020.10:42
0x0050: 3a33 3620 474d 540d 0a :36.GMT..
10:42:36.439975 IP localhost.40822 > localhost.http: Flags [.], ack 92, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 0
0x0000: 4500 0034 7a0e 4000 4006 c2b3 7f00 0001 E..4z.@.@.......
0x0010: 7f00 0001 9f76 0050 539c a9c3 d056 9782 .....v.PS....V..
0x0020: 8010 0156 fe28 0000 0101 080a 005b d372 ...V.(.......[.r
0x0030: 005b d372 .[.r
10:42:36.440001 IP localhost.http > localhost.40822: Flags [P.], seq 92:141, ack 74, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 49: HTTP
0x0000: 4500 0065 445b 4000 4006 f835 7f00 0001 E..eD[@.@..5....
0x0010: 7f00 0001 0050 9f76 d056 9782 539c a9c3 .....P.v.V..S...
0x0020: 8018 0156 fe59 0000 0101 080a 005b d372 ...V.Y.......[.r
0x0030: 005b d372 436f 6e74 656e 742d 7479 7065 .[.rContent-type
0x0040: 3a20 7465 7874 2f68 746d 6c3b 2063 6861 :.text/html;.cha
0x0050: 7273 6574 3d41 4e53 495f 5833 2e34 2d31 rset=ANSI_X3.4-1
0x0060: 3936 380d 0a 968..
10:42:36.440009 IP localhost.40822 > localhost.http: Flags [.], ack 141, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 0
0x0000: 4500 0034 7a0f 4000 4006 c2b2 7f00 0001 E..4z.@.@.......
0x0010: 7f00 0001 9f76 0050 539c a9c3 d056 97b3 .....v.PS....V..
0x0020: 8010 0156 fe28 0000 0101 080a 005b d372 ...V.(.......[.r
0x0030: 005b d372 .[.r
10:42:36.440029 IP localhost.http > localhost.40822: Flags [P.], seq 141:162, ack 74, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 21: HTTP: Content-Length: 608
0x0000: 4500 0049 445c 4000 4006 f850 7f00 0001 E..ID\@.@..P....
0x0010: 7f00 0001 0050 9f76 d056 97b3 539c a9c3 .....P.v.V..S...
0x0020: 8018 0156 fe3d 0000 0101 080a 005b d372 ...V.=.......[.r
0x0030: 005b d372 436f 6e74 656e 742d 4c65 6e67 .[.rContent-Leng
0x0040: 7468 3a20 3630 380d 0a th:.608..
10:42:36.440046 IP localhost.40822 > localhost.http: Flags [.], ack 162, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 0
0x0000: 4500 0034 7a10 4000 4006 c2b1 7f00 0001 E..4z.@.@.......
0x0010: 7f00 0001 9f76 0050 539c a9c3 d056 97c8 .....v.PS....V..
0x0020: 8010 0156 fe28 0000 0101 080a 005b d372 ...V.(.......[.r
0x0030: 005b d372 .[.r
10:42:36.440066 IP localhost.http > localhost.40822: Flags [P.], seq 162:164, ack 74, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 2: HTTP
0x0000: 4500 0036 445d 4000 4006 f862 7f00 0001 E..6D]@.@..b....
0x0010: 7f00 0001 0050 9f76 d056 97c8 539c a9c3 .....P.v.V..S...
0x0020: 8018 0156 fe2a 0000 0101 080a 005b d372 ...V.*.......[.r
0x0030: 005b d372 0d0a .[.r..
10:42:36.440073 IP localhost.40822 > localhost.http: Flags [.], ack 164, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 0
0x0000: 4500 0034 7a11 4000 4006 c2b0 7f00 0001 E..4z.@.@.......
0x0010: 7f00 0001 9f76 0050 539c a9c3 d056 97ca .....v.PS....V..
0x0020: 8010 0156 fe28 0000 0101 080a 005b d372 ...V.(.......[.r
0x0030: 005b d372 .[.r
10:42:36.440100 IP localhost.http > localhost.40822: Flags [P.], seq 164:772, ack 74, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 608: HTTP
0x0000: 4500 0294 445e 4000 4006 f603 7f00 0001 E...D^@.@.......
0x0010: 7f00 0001 0050 9f76 d056 97ca 539c a9c3 .....P.v.V..S...
0x0020: 8018 0156 0089 0000 0101 080a 005b d372 ...V.........[.r
0x0030: 005b d372 3c21 444f 4354 5950 4520 6874 .[.r<!DOCTYPE.ht
0x0040: 6d6c 2050 5542 4c49 4320 222d 2f2f 5733 ml.PUBLIC."-//W3
0x0050: 432f 2f44 5444 2048 544d 4c20 332e 3220 C//DTD.HTML.3.2.
0x0060: 4669 6e61 6c2f 2f45 4e22 3e3c 6874 6d6c Final//EN"><html
0x0070: 3e0a 3c74 6974 6c65 3e44 6972 6563 746f >.<title>Directo
0x0080: 7279 206c 6973 7469 6e67 2066 6f72 202f ry.listing.for./
0x0090: 3c2f 7469 746c 653e 0a3c 626f 6479 3e0a </title>.<body>.
0x00a0: 3c68 323e 4469 7265 6374 6f72 7920 6c69 <h2>Directory.li
0x00b0: 7374 696e 6720 666f 7220 2f3c 2f68 323e sting.for./</h2>
0x00c0: 0a3c 6872 3e0a 3c75 6c3e 0a3c 6c69 3e3c .<hr>.<ul>.<li><
0x00d0: 6120 6872 6566 3d22 2e62 6173 685f 6869 a.href=".bash_hi
0x00e0: 7374 6f72 7922 3e2e 6261 7368 5f68 6973 story">.bash_his
0x00f0: 746f 7279 3c2f 613e 0a3c 6c69 3e3c 6120 tory</a>.<li><a.
0x0100: 6872 6566 3d22 2e62 6173 685f 6c6f 676f href=".bash_logo
0x0110: 7574 223e 2e62 6173 685f 6c6f 676f 7574 ut">.bash_logout
0x0120: 3c2f 613e 0a3c 6c69 3e3c 6120 6872 6566 </a>.<li><a.href
0x0130: 3d22 2e62 6173 685f 7072 6f66 696c 6522 =".bash_profile"
0x0140: 3e2e 6261 7368 5f70 726f 6669 6c65 3c2f >.bash_profile</
0x0150: 613e 0a3c 6c69 3e3c 6120 6872 6566 3d22 a>.<li><a.href="
0x0160: 2e62 6173 6872 6322 3e2e 6261 7368 7263 .bashrc">.bashrc
0x0170: 3c2f 613e 0a3c 6c69 3e3c 6120 6872 6566 </a>.<li><a.href
0x0180: 3d22 2e6c 6573 7368 7374 223e 2e6c 6573 =".lesshst">.les
0x0190: 7368 7374 3c2f 613e 0a3c 6c69 3e3c 6120 shst</a>.<li><a.
0x01a0: 6872 6566 3d22 2e73 7368 2f22 3e2e 7373 href=".ssh/">.ss
0x01b0: 682f 3c2f 613e 0a3c 6c69 3e3c 6120 6872 h/</a>.<li><a.hr
0x01c0: 6566 3d22 3122 3e31 3c2f 613e 0a3c 6c69 ef="1">1</a>.<li
0x01d0: 3e3c 6120 6872 6566 3d22 6364 2f22 3e63 ><a.href="cd/">c
0x01e0: 642f 3c2f 613e 0a3c 6c69 3e3c 6120 6872 d/</a>.<li><a.hr
0x01f0: 6566 3d22 6669 6c65 732f 223e 6669 6c65 ef="files/">file
0x0200: 732f 3c2f 613e 0a3c 6c69 3e3c 6120 6872 s/</a>.<li><a.hr
0x0210: 6566 3d22 6669 6c65 735f 7265 7374 6f72 ef="files_restor
0x0220: 6564 2f22 3e66 696c 6573 5f72 6573 746f ed/">files_resto
0x0230: 7265 642f 3c2f 613e 0a3c 6c69 3e3c 6120 red/</a>.<li><a.
0x0240: 6872 6566 3d22 6673 2f22 3e66 732f 3c2f href="fs/">fs/</
0x0250: 613e 0a3c 6c69 3e3c 6120 6872 6566 3d22 a>.<li><a.href="
0x0260: 696d 6167 652e 6973 6f22 3e69 6d61 6765 image.iso">image
0x0270: 2e69 736f 3c2f 613e 0a3c 2f75 6c3e 0a3c .iso</a>.</ul>.<
0x0280: 6872 3e0a 3c2f 626f 6479 3e0a 3c2f 6874 hr>.</body>.</ht
0x0290: 6d6c 3e0a ml>.
10:42:36.440108 IP localhost.40822 > localhost.http: Flags [.], ack 772, win 351, options [nop,nop,TS val 6017906 ecr 6017906], length 0
0x0000: 4500 0034 7a12 4000 4006 c2af 7f00 0001 E..4z.@.@.......
0x0010: 7f00 0001 9f76 0050 539c a9c3 d056 9a2a .....v.PS....V.*
0x0020: 8010 015f fe28 0000 0101 080a 005b d372 ..._.(.......[.r
0x0030: 005b d372 .[.r
10:42:36.440159 IP localhost.http > localhost.40822: Flags [F.], seq 772, ack 74, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 0
0x0000: 4500 0034 445f 4000 4006 f862 7f00 0001 E..4D_@.@..b....
0x0010: 7f00 0001 0050 9f76 d056 9a2a 539c a9c3 .....P.v.V.*S...
0x0020: 8011 0156 fe28 0000 0101 080a 005b d372 ...V.(.......[.r
0x0030: 005b d372 .[.r
10:42:36.440517 IP localhost.40822 > localhost.http: Flags [F.], seq 74, ack 773, win 351, options [nop,nop,TS val 6017907 ecr 6017906], length 0
0x0000: 4500 0034 7a13 4000 4006 c2ae 7f00 0001 E..4z.@.@.......
0x0010: 7f00 0001 9f76 0050 539c a9c3 d056 9a2b .....v.PS....V.+
0x0020: 8011 015f fe28 0000 0101 080a 005b d373 ..._.(.......[.s
0x0030: 005b d372 .[.r
10:42:36.440529 IP localhost.http > localhost.40822: Flags [.], ack 75, win 342, options [nop,nop,TS val 6017907 ecr 6017907], length 0
0x0000: 4500 0034 4460 4000 4006 f861 7f00 0001 E..4D`@.@..a....
0x0010: 7f00 0001 0050 9f76 d056 9a2b 539c a9c4 .....P.v.V.+S...
0x0020: 8010 0156 fe28 0000 0101 080a 005b d373 ...V.(.......[.s
0x0030: 005b d373 .[.s
クライアント側(curl側)エフェメラルポートが40822
であることなどがわかる
【補】TCP/IP PDUを読んでみる
10:42:36.440066 IP localhost.http > localhost.40822: Flags [P.], seq 162:164, ack 74, win 342, options [nop,nop,TS val 6017906 ecr 6017906], length 2: HTTP
0x0000: 4500 0036 445d 4000 4006 f862 7f00 0001 E..6D]@.@..b....
0x0010: 7f00 0001 0050 9f76 d056 97c8 539c a9c3 .....P.v.V..S...
0x0020: 8018 0156 fe2a 0000 0101 080a 005b d372 ...V.*.......[.r
0x0030: 005b d372 0d0a .[.r..
この部分: IPパケットのヘッダ
0x0000: 4500 0036 445d 4000 4006 f862 7f00 0001 E..6D]@.@..b....
0x0010: 7f00 0001 ....
4
: IPv45
: IHL: IP Header Length. 20オクテット / 4オクテット = 500
: ToS: Type of Service0036
: パケット長。0x0036まで445d
: 識別子。パケットがフラグメント化された場合、再組み立てに使う-
4
: 上位3ビット:フラグ8
: 不使用4
: DF: Don’t Fragment2
: MF: More Fragments- 今回は要するに「フラグメント化されてないよ」ということ
-
4000
: 下位13ビット: フラグメントオフセット- 今回はフラグメント化されていないので全部0
40
: TTL-
06
: 上位プロトコル番号- 今回はTCPなので6
-
f862
: ヘッダチェックサム- IPv6で「L2でCRC取ってるしこれ要らなくね?」って消されたやつ
7f000001
: 送信元IPアドレス7f000001
: 宛先IPアドレス
この部分: TCPセグメントのヘッダ
0x0010: 0050 9f76 d056 97c8 539c a9c3 .P.v.V..S...
0x0020: 8018 0156 fe2a 0000 0101 080a 005b d372 ...V.*.......[.r
0x0030: 005b d372 .[.r
https://tools.ietf.org/html/rfc1323
-
0050
: 送信先ポート番号- 10進数の80番なので16進数で
0x0050
- 10進数の80番なので16進数で
-
9f76
: 宛先ポート番号- 10進数の40822番なので16進数で
0x9f76
- 10進数の40822番なので16進数で
d05697c8
: シーケンス番号539ca9c3
: 確認応答番号-
8
: データオフセット。TCPヘッダの長さを表す- 32オクテット/4オクテット=8
-
018
: 予約6ビット + コントロールフラグ6ビット- 今回は
0b011000
: ACK,PSH
- 今回は
-
0156
: ウィンドウサイズ- 輻輳制御とかのアレ
- win 342 に対応している
fe2a
: チェックサム-
0000
: 緊急ポインタ- 今回はURGフラグが立っていないので使われていない 以下オプション
01
: nop-
01
: nop- 4オクテット単位にするためのヤツ
-
080a 006bd372 006bd372
- TCP Timestamps
08
: kind. TCPオプション8番0a
: length. 10オクテット006bd372
: val 6017906 に対応。Timestamp Value006bd372
: ecr 6017906 に対応。Timestamp Echo Reply
この部分: HTTPのデータ。ヘッダとボディの区切りの改行(CRLF)
0x0030: 0d0a ..
Wireshark
GUIでパケットキャプチャできるやつ
netstat
netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 lpic2-study-1.asi:47750 syd09s06-in-f10.1:https ESTABLISHED
tcp 0 0 lpic2-study-1.asi:40460 metadata.google.in:http ESTABLISHED
tcp 0 0 lpic2-study-1.asi:47752 syd09s06-in-f10.1:https ESTABLISHED
tcp 0 0 lpic2-study-1.asia-:ssh softbank060150194:59882 ESTABLISHED
tcp 0 0 lpic2-study-1.asi:40458 metadata.google.in:http ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 5 [ ] DGRAM 8210 /run/systemd/journal/socket
unix 20 [ ] DGRAM 8212 /dev/log
unix 2 [ ] DGRAM 11879 /run/systemd/shutdownd
...
-l
: listening 接続待ち状態にあるソケット表示
netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:http 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 localhost:smtp [::]:* LISTEN
udp 0 0 0.0.0.0:bootpc 0.0.0.0:*
udp 0 0 localhost:323 0.0.0.0:*
udp6 0 0 localhost:323 [::]:*
raw6 0 0 [::]:ipv6-icmp [::]:* 7
...
HTTP,SSH,SMTP等か動いていることがわかる
- さっき起動したpythonのSimpleHTTPServer
-n
: numeric
netstat -ln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
...
-c
, --continuous
: 1秒ごとにリアルタイムで表示
-i
, --interfaces
: ネットワークインタフェースごとの統計情報表示
netstat -i
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1460 13251 0 0 0 12344 0 0 0 BMRU
eth0:0 1460 - no statistics available - BMRU
lo 65536 344 0 0 0 344 0 0 0 LRU
-r
, --route
: ルーティングテーブル表示
netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default gateway 0.0.0.0 UG 0 0 0 eth0
gateway 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
lpic2-study-1.a 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
ss
manによれば socket statistics の略っぽい
netstatとだいたい同じ
-
-i
と-r
は異なる-i
,--info
-r
,--resolve
nc
netcatの意
nc
-bash: nc: command not found
yum provides nc
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* epel: d2lzkl7pfhq30w.cloudfront.net
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
2:nmap-ncat-6.40-19.el7.x86_64 : Nmap's Netcat replacement
Repo : base
Matched from:
Provides : nc
sudo yum install -y nmap-ncat
nc --version
Ncat: Version 7.50 ( https://nmap.org/ncat )
telnetとかと同じ感じ
nc localhost 25
220 lpic2-study-1.localdomain ESMTP Postfix
ポートスキャンなどに用いる
-v
,--verbose
: verbose-z
: Zero-I/O
nc -vz localhost 1-1000
勉強用centos7環境だと:1を見に行ってエラッた時点で終わっちゃう
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connection to ::1 failed: Connection refused.
Ncat: Trying next address...
Ncat: Connection refused.
ubuntuだと範囲指定でポートスキャンできる
nc -vz localhost 1-1000
nc: connect to localhost port 1 (tcp) failed: Connection refused
nc: connect to localhost port 2 (tcp) failed: Connection refused
nc: connect to localhost port 3 (tcp) failed: Connection refused
...
nc: connect to localhost port 21 (tcp) failed: Connection refused
Connection to localhost 22 port [tcp/ssh] succeeded!
nc: connect to localhost port 23 (tcp) failed: Connection refused
...
ip
ifconfig
, route
, arp
等を統合したようなヤツ
yum provides ip
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* epel: d2lzkl7pfhq30w.cloudfront.net
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
google-compute-engine/filelists | 4.1 kB 00:00:00
iproute-4.11.0-30.el7.x86_64 : Advanced IP routing and network device configuration tools
Repo : base
Matched from:
Filename : /usr/sbin/ip
iproute-4.11.0-25.el7_7.2.x86_64 : Advanced IP routing and network device configuration tools
Repo : @anaconda
Matched from:
Filename : /usr/sbin/ip
ss
など共々iproute
パッケージで入ってくるらしい
link
サブコマンド: データリンク層の情報表示
- 要するに
ifconfig
的なやつ
ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1460 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 42:01:0a:92:00:04 brd ff:ff:ff:ff:ff:ff
-s
: ステータス表示
- linkサブコマンドの場合、ネットワークインタフェースごとの統計情報表示
netstat -i
と同じ感じ
ip -s link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1460 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 42:01:0a:92:00:04 brd ff:ff:ff:ff:ff:ff
+ RX: bytes packets errors dropped overrun mcast
+ 31637814 15219 0 0 0 0
+ TX: bytes packets errors dropped carrier collsns
+ 1716084 14316 0 0 0 0
addr
サブコマンド: IPアドレスの情報
ifconfig
と同じような情報- 以下、
show
省略
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1460 qdisc mq state UP group default qlen 1000
link/ether 42:01:0a:92:00:04 brd ff:ff:ff:ff:ff:ff
inet 10.146.0.4/32 brd 10.146.0.4 scope global noprefixroute dynamic eth0
valid_lft 3562sec preferred_lft 3562sec
inet 192.168.1.1/24 brd 192.168.1.255 scope global eth0:0
valid_lft forever preferred_lft forever
inet6 fe80::4001:aff:fe92:4/64 scope link noprefixroute
valid_lft forever preferred_lft forever
route
サブコマンド: ルーティングテーブル
netstat -rn
と同じような情報
ip route
default via 10.146.0.1 dev eth0 proto dhcp metric 100
10.146.0.1 dev eth0 proto dhcp scope link metric 100
10.146.0.4 dev eth0 proto kernel scope link src 10.146.0.4 metric 100
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.1
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.1 metric 100
- 他のネットワーク系コマンドと異なり、デフォルトでnumeric
-r
,-resolve
オプションをつけて明示的に名前の逆引きをするとnetstat -r
相当になる
ip -resolve route
default via gateway dev eth0 proto dhcp metric 100
gateway dev eth0 proto dhcp scope link metric 100
lpic2-study-1.asia-northeast1-b.c.lpic2-study.internal dev eth0 proto kernel scope link src 10.146.0.4 metric 100
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.1
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.1 metric 100
neigh
サブコマンド: ARPキャッシュ
arp
と同じような情報
ip -r neigh
gateway dev eth0 lladdr 42:01:0a:92:00:01 REACHABLE
add
: 指定した対象にパラメータ設定
- eth0にIPエイリアシング
sudo ip addr add 192.168.1.2/24 dev eth0
ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1460 qdisc mq state UP group default qlen 1000
link/ether 42:01:0a:92:00:04 brd ff:ff:ff:ff:ff:ff
inet 10.146.0.4/32 brd 10.146.0.4 scope global noprefixroute dynamic eth0
valid_lft 2690sec preferred_lft 2690sec
inet 192.168.1.1/24 brd 192.168.1.255 scope global eth0:0
valid_lft forever preferred_lft forever
+ inet 192.168.1.2/24 scope global secondary eth0
+ valid_lft forever preferred_lft forever
inet6 fe80::4001:aff:fe92:4/64 scope link noprefixroute
valid_lft forever preferred_lft forever
ip
コマンドでadd
したIPエイリアスはifconfig
だと出てこない模様
ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1460
inet 10.146.0.4 netmask 255.255.255.255 broadcast 10.146.0.4
inet6 fe80::4001:aff:fe92:4 prefixlen 64 scopeid 0x20<link>
ether 42:01:0a:92:00:04 txqueuelen 1000 (Ethernet)
RX packets 16382 bytes 31882835 (30.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 15387 bytes 1880210 (1.7 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1460
inet 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255
ether 42:01:0a:92:00:04 txqueuelen 1000 (Ethernet)
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 495 bytes 36114 (35.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 495 bytes 36114 (35.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
labelをつけるとifconfigでも出てくる
sudo ip addr add 192.168.1.3/24 dev eth0 label eth0:2
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1460
inet 10.146.0.4 netmask 255.255.255.255 broadcast 10.146.0.4
inet6 fe80::4001:aff:fe92:4 prefixlen 64 scopeid 0x20<link>
ether 42:01:0a:92:00:04 txqueuelen 1000 (Ethernet)
RX packets 16583 bytes 31927873 (30.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 15583 bytes 1904155 (1.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1460
inet 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255
ether 42:01:0a:92:00:04 txqueuelen 1000 (Ethernet)
eth0:2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1460
inet 192.168.1.3 netmask 255.255.255.0 broadcast 0.0.0.0
ether 42:01:0a:92:00:04 txqueuelen 1000 (Ethernet)
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 503 bytes 36594 (35.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 503 bytes 36594 (35.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
6.1.4 ルーティングの設定
route
コマンド
- 引数なし:
netstat -r
とほぼ同じ
route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default gateway 0.0.0.0 UG 100 0 0 eth0
gateway 0.0.0.0 255.255.255.255 UH 100 0 0 eth0
lpic2-study-1.a 0.0.0.0 255.255.255.255 UH 100 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
ルーティングテーブル追加
デフォルト経路
- 行き先がどこかわからなかったらとりあえず
172.16.0.1
に投げる
route add default gw 172.16.0.1
ネットワーク経路
192.168.3.0/24
に行きたかったら172.16.0.1
に投げる
route add -net 192.168.3.0 netmask 255.255.255.0 gw 172.16.0.1
ホスト経路
- /32宛のやつ
ip route add
もだいたい同じ
ip route add default via 172.16.0.1
route add 192.168.3.0/24 via 172.16.0.1
6.1.5 無線ネットワークの設定
勉強環境は無線デバイスがないので実際には遊べてない
wireless-tools
パッケージ
yum provides iwconfig
しても手がかりなし
yum provides iwconfig
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* epel: d2lzkl7pfhq30w.cloudfront.net
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
No matches found
天下り的だがググったところwireless-tools
パッケージで入るらしい
sudo yum install -y wireless-tools
which iwconfig
which iwlist
/usr/sbin/iwconfig
/usr/sbin/iwlist
iwconfig
ifconfigのwireless版
-
設定確認・設定更新
- WEPキーやESSIDを設定できる
wpa_passphrase
WPA/WPA2の設定
- 【補】現在ではWPA3もある
wpa_supplicant
無線LANに接続
dhclient
ネットワーク情報取得
iw
iw --version
-bash: iw: command not found
yum provides iw
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp-srv2.kddilabs.jp
* epel: d2lzkl7pfhq30w.cloudfront.net
* extras: ftp-srv2.kddilabs.jp
* updates: ftp-srv2.kddilabs.jp
iw-4.3-2.el7.x86_64 : A nl80211 based wireless configuration tool
Repo : base
sudo yum install -y iw
iw --version
iw version 4.3
iwを動かそうとすると、nl80211
が無いぞと言われる
iw --help
nl80211 not found.
cfg80211
カーネルモジュールをインストール
sudo modprobe cfg80211
iw --help
Usage: iw [options] command
Options:
--debug enable netlink debugging
--version show version (4.3)
Commands:
help [command]
Print usage for all or a specific command, e.g.
"help wowlan" or "help wowlan enable".
event [-t] [-r] [-f]
Monitor events from the kernel.
-t - print timestamp
-r - print relative timstamp
-f - print full frame for auth/assoc etc.
features
commands
list all known commands and their decimal & hex value
phy
list
List all wireless devices and their capabilities.
phy <phyname> info
Show capabilities for the specified wireless device.
dev
List all network interfaces for wireless hardware.
...
iwlist
無線インタフェースの情報取得