ä½ã®è©±ãã¨ããã¨
RHEL7/CentOS7ã§ã¯æå°æ§æã§ã¤ã³ã¹ãã¼ã«ããã¨ãifconfigãrouteãnetstatãarpãªã©ã®ãããã¯ã¼ã¯é¢é£ã®ã³ãã³ãã使ãã¾ãããããã¯ã次ã®ã³ãã³ãã§ãnet-toolsãããã±ã¼ã¸ãå°å ¥ããã¨è§£æ±ºãã¾ãã
# yum -y install net-tools
ããããªããï¼
RHEL7/CentOS7ã§ã¯ãnet-toolsããdeprecatedï¼å»æ¢äºå®ï¼ãã¨ãã¦ãããä»å¾ã¯ãiproute2ããã±ã¼ã¸ã«å«ã¾ãããipããssããªã©ã®ã³ãã³ãã使ç¨ãããã¨ãæ¨å¥¨ããã¦ãã¾ãã
ã»ã客ããã®RHEL7ãµã¼ãã¼ã®ã¡ã³ããé ¼ã¾ãããnet-toolsãå
¥ã£ã¦ãªãã£ãï¼
ã»ããã¼ãã¾ã ifconfigã¤ãã£ã¦ãã®ã¼ããã¨è¥ãååã«å·ããç®ã§è¦ãããï¼
ã»ãªã©ãªã©
ã¨ãã£ãäºæ ã«åãã¦ãRHEL7/CentOS7ãå°å ¥ããéã«ã¯ãiproute2ã使ãããªãç·´ç¿ããã¦ããã¾ãããã
â»ãdeprecatedï¼å»æ¢äºå®ï¼ãã¨ãã表ç¾ã«éå°åå¿ãèµ·ããªãããã«è£è¶³ãã¦ããã¾ãã
RHELã¯ç¹å®ã¡ã¸ã£ã¼ãã¼ã¸ã§ã³ã«ããã¦ãç¹å¥ãªçç±ããªãããããæ¢åã®ããã±ã¼ã¸ãéä¸ã§åé¤ãããã¨ã¯ããã¾ãããRHEL7.0ã«å ¥ã£ã¦ããnet-toolsãããRHEL7.1ã§çªç¶ãªããªãï¼ãã¨ãããããªäºã¯ãæããã¯ãªãã§ããããï¼RHEL8ã§å梱ãããªããªãå¯è½æ§ã¯ããã¾ãããï¼
ãã ãã
ã»ä»å¾ã®æ©è½è¿½å ãªã©ã¯ãiproute2ã®æ¹ã§å®æ½ããã¦ãããï¼ä¾ãã°ãnetnsã®ç®¡çã«ã¯ãipã³ãã³ããå¿ è¦ã§ããï¼
ã»æå°æ§æã§net-toolsãå ¥ããªãã¾ã¾éç¨ããããµã¼ãã¼ãå°ãªãããåºã¦ããå¯è½æ§ããããã¨ããäºãèãã¦ãä»ããiproute2ã¸ã®ç§»è¡ãé²ãã¦ããã®ãããã§ãããã
ãã£ããã¨ãã対æ¯
ã¾ãã¯ãã®ããããè¦ãã¦ããã¾ãããã
net-tools | iproute2 |
---|---|
ifconfig | ip a(addr), ip l(link) |
route | ip r(route) |
netstat | ss |
netstat -i | ip -s l(link) |
arp | ip n(neighbor) |
ã³ãã³ãå¥ã®å¯¾æ¯
ç§ã®å®é¨ç°å¢ã§ã¯ãeth0ããRHEL7ã®ãµã¼ãã¼ï¼ä»®æ³ãã·ã³ï¼ã«ãã°ã¤ã³ãã¦ããã®ã§ãå®é¨ç¨ã«eth1ã追å ãã¦ããã¾ããæ°è¦ã«è¿½å ããeth1ã«ã¢ãã¬ã¹ãã»ããããã¨ãã«ã¯ãnmcliã³ãã³ãã使ãã¾ãã
# nmcli c add type eth ifname eth1 con-name eth1 # nmcli c mod eth1 ipv4.method manual ipv4.addresses "192.168.122.69/24 192.168.122.1" # nmcli c down eth1 # nmcli c up eth1
æåã®ã³ãã³ãã®ãcon-nameãã«ã¯ä»»æã®æ¥ç¶åãæå®ã§ãã¾ãããããã§ã¯ãããã¤ã¹åã¨åããeth1ããæå®ãã¦ãã¾ããnmcliã«ã¤ãã¦ã¯ä¸è¨ãåç §ã
ã»NetworkManagerの設定変更、nmtuiとnmcliについてまとめたよ!
ããã§ã¯ã以ä¸ã«ãå¾æ¥ã®å ¸åã³ãã³ãã¨ãããã«å¯¾å¿ããæ°ããã³ãã³ãã並ã¹ã¦ããã¾ãã
ã»ç¹å®ããã¤ã¹ã®ç¶æ 確èª
# ifconfig eth0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.122.70 netmask 255.255.255.0 broadcast 192.168.122.255 inet6 fe80::5054:ff:fe41:c632 prefixlen 64 scopeid 0x20<link> ether 52:54:00:41:c6:32 txqueuelen 1000 (Ethernet) RX packets 1539 bytes 2117655 (2.0 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 194 bytes 28160 (27.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 # ip a show dev eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:41:c6:32 brd ff:ff:ff:ff:ff:ff inet 192.168.122.70/24 brd 192.168.122.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::5054:ff:fe41:c632/64 scope link valid_lft forever preferred_lft forever
ã»ããã¤ã¹ã®up/down
# ifconfig eth1 up # ifconfig eth1 down # ip l set eth1 up # ip l set eth1 down
ããã¯ãå ã»ã©ã®nmcliã®æ¹ãããããç¥ãã¾ããã
# nmcli c down eth1 # nmcli c up eth1
ããã§æå®ãããeth1ãã¯ããã¤ã¹åã§ã¯ãªãã¦ãå ã«æå®ãããæ¥ç¶åãã§ãã®ã§ãã注æä¸ãããããã¤ã¹ã«å¯¾ããIPã¢ãã¬ã¹ãªã©ã®å²ãå½ã¦ãnmcliã§ããã®ãããã§ãããã
ã»ã«ã¼ãã£ã³ã°ãã¼ãã«ã®ç¢ºèª
# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.122.1 0.0.0.0 UG 1024 0 0 eth0 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 # ip r default via 192.168.122.1 dev eth0 proto static metric 1024 192.168.122.0/24 dev eth0 proto kernel scope link src 192.168.122.70 192.168.122.0/24 dev eth1 proto kernel scope link src 192.168.122.69
ã»ããã©ã«ãã²ã¼ãã¦ã§ã¤ã®è¿½å ãåé¤
# route add default gw 192.168.122.1 # route del default gw 192.168.122.1 # ip route add default via 192.168.122.1 # ip route del default via 192.168.122.1
ã»ããã¤ã¹ãã¨ã®ãã±ããå¦çæ°
# 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 1500 6375 0 0 0 1723 0 0 0 BMRU eth1 1500 2095 0 0 0 126 0 0 0 BMRU lo 65536 1040 0 0 0 1040 0 0 0 LRU # ip -s l 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 RX: bytes packets errors dropped overrun mcast 82260 1040 0 0 0 0 TX: bytes packets errors dropped carrier collsns 82260 1040 0 0 0 0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 52:54:00:41:c6:32 brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 3861081 6396 0 0 0 0 TX: bytes packets errors dropped carrier collsns 237222 1733 0 0 0 0 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 52:54:00:a2:e8:73 brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 1478655 2098 0 0 0 0 TX: bytes packets errors dropped carrier collsns 20043 126 0 0 0 0
ã»TCPã½ã±ããã®ç¶æ 確èª
# netstat -nat Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 192.168.122.70:22 192.168.122.1:34328 ESTABLISHED tcp6 0 0 ::1:25 :::* LISTEN tcp6 0 0 :::80 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN # ss -nat State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 *:22 *:* ESTAB 0 0 192.168.122.70:22 192.168.122.1:34328 LISTEN 0 100 ::1:25 :::* LISTEN 0 128 :::80 :::* LISTEN 0 128 :::22 :::*
ã»UDPã½ã±ããã®ç¶æ 確èª
# netstat -nau Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State udp 0 0 0.0.0.0:123 0.0.0.0:* udp 0 0 0.0.0.0:53481 0.0.0.0:* udp 0 0 0.0.0.0:5353 0.0.0.0:* udp 0 0 127.0.0.1:323 0.0.0.0:* udp6 0 0 :::123 :::* udp6 0 0 ::1:323 :::* # ss -nau State Recv-Q Send-Q Local Address:Port Peer Address:Port UNCONN 0 0 *:123 *:* UNCONN 0 0 *:53481 *:* UNCONN 0 0 *:5353 *:* UNCONN 0 0 127.0.0.1:323 *:* UNCONN 0 0 :::123 :::* UNCONN 0 0 ::1:323 :::*
ã»ARPãã¼ãã«ã®ç¢ºèª
# arp -n Address HWtype HWaddress Flags Mask Iface 192.168.122.71 ether 52:54:00:a5:2c:75 C eth0 192.168.122.1 ether 02:13:97:c1:47:ec C eth0 # ip n 192.168.122.71 dev eth0 lladdr 52:54:00:a5:2c:75 REACHABLE 192.168.122.1 dev eth0 lladdr 02:13:97:c1:47:ec REACHABLE
ã»ARPãã¼ãã«ã®ç¡å¹å
# arp -d 192.168.122.71 -i eth0 # ip n flush 192.168.122.71 dev eth0 # ip n del 192.168.122.71 dev eth0ãï¼âã¨ã³ããªã¼ãåé¤ï¼
ã¨ããããä»æ¥ã¯ããã¾ã§ï¼