Site icon Mr. 沙先生

在 CentOS 7 中所不見的命令 – Round 1: ifconfig、route、netstat、traceroute

很好,最終還是要來體驗一下最新的 CentOS 7,雖然很早之前就使用過了,但是基於穩定性還是常用 CentOS 6,最近下定決心開始習慣 CentOS 7 的介面

 

此篇紀錄在 CentOS 6 中所常用的幾個工具將被淘汰,並且替代的工具

 

ifconfig 替換為 ip addr

#同ifconfig
$ ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    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: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:22:4d:80:7f:6a brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.10/24 brd 222.186.42.255 scope global enp1s0
       valid_lft forever preferred_lft forever
    inet6 fe80::222:4dff:fe80:7f6a/64 scope link 
       valid_lft forever preferred_lft forever

#查看介面傳輸狀態 -s 詳細
$ ip -s link

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   
    0          0        0       0       0       0      
    TX: bytes  packets  errors  dropped carrier collsns 
    0          0        0       0       0       0      
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:22:4d:80:7f:6a brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast   
    26232302   55435    0       0       0       0      
    TX: bytes  packets  errors  dropped carrier collsns 
    1338484    14020    0       0       0       0

 

netstat 替換為 ss

#同 netstat -tunpl
$ ss -tunpl

#檢視tcp連線
$ ss -t

#檢視udp
$ ss -u

 

traceroute/traceroute6 替換為 tracepath

$ tracepath 8.8.8.8

 

route 替換為 ip route

$ ip route

192.168.10.0/24 dev eth0  proto kernel  scope link  src 192.168.121.10 
169.254.0.0/16 dev eth0  scope link  metric 1003 
default via 192.168.10.254 dev eth0

 

arp 替換為 ip neighbor

$ ip neighbor
192.168.10.108 dev eth0 lladdr e0:ac:cb:66:2a:3c STALE
192.168.10.254 dev eth0 lladdr 10:7b:ef:47:ce:53 REACHABLE

 

 

 

 

在 CentOS 7 被淘汰的工具只是不在預設安裝所包含的,所以是可以利用 yum 把他安裝回來

Note:在 yum 中不知道套件的名稱,可以用 provides 和 list 直接搜尋 package 裡面的工具

$ yum provides */ifconfig

net-tools-1.60-110.el6_2.x86_64 : Basic networking tools
Repo        : base
Matched from:
Filename    : /sbin/ifconfig

 

Exit mobile version