2016年2月22日 星期一

[研究] ifconfig 不見了 (CentOS 7.2 最小安裝)

[研究] ifconfig 不見了 (CentOS 7.2 最小安裝)

2016-02-22

第一次使用 CentOS 7.2 最小安裝 (Minimal Install),發現沒有 ifconfig 指令,查了一下,原來改用 ip addr了。

[root@centos1 ~]# ifconfig
-bash: ifconfig: command not found

[root@centos1 ~]# 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: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:5b:fe:f1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.128.101/24 brd 192.168.128.255 scope global eno16777736
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe5b:fef1/64 scope link
       valid_lft forever preferred_lft forever


[root@centos1 ~]# ip 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
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:5b:fe:f1 brd ff:ff:ff:ff:ff:ff
[root@centos1 ~]#


[root@centos1 ~]# 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: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:5b:fe:f1 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    81527836   70562    0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    9750560    36116    0       0       0       0
[root@centos1 ~]#

查一下哪個套件包含 ifconfig
(有時候會無法查出,答案是 net-tools)

[root@centos1 ~]# yum provides ifconfig
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.cs.nctu.edu.tw
 * extras: centos.cs.nctu.edu.tw
 * updates: centos.cs.nctu.edu.tw
base/7/x86_64/filelists_db                               | 6.2 MB     00:00
extras/7/x86_64/filelists_db                             | 256 kB     00:00
updates/7/x86_64/filelists_db                            | 1.9 MB     00:00
No matches found

[root@centos1 ~]# yum provides ifconfig
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.aol.in
 * extras: centos.aol.in
 * updates: centos.aol.in
net-tools-2.0-0.17.20131004git.el7.x86_64 : Basic networking tools
Repo        : @base
Matched from:
Filename    : /usr/sbin/ifconfig


[root@centos1 ~]# yum whatprovides ifconfig
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.cs.nctu.edu.tw
 * extras: centos.cs.nctu.edu.tw
 * updates: centos.cs.nctu.edu.tw
No matches found
[root@centos1 ~]#

安裝 net-tools

[root@centos1 ~]# yum -y install net-tools

有 ifconfig 可以用了。

[root@centos1 ~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.128.101  netmask 255.255.255.0  broadcast 192.168.128.255
        inet6 fe80::20c:29ff:fe5b:fef1  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:5b:fe:f1  txqueuelen 1000  (Ethernet)
        RX packets 70949  bytes 81864876 (78.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 36313  bytes 9771242 (9.3 MiB)
        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 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@centos1 ~]# man  ifconfig
(... 略)
NOTE
       This  program  is obsolete!  For replacement check ip addr and ip link.
       For statistics use ip -s link.
(... 略)

這個程式已經過時了!改用 ip addr 和 ip link 取代檢查了。
對於統計數據可使用ip -s  link。

(完)



沒有留言:

張貼留言