CentOS 7.2最小安装后不能使用ifconfig,netstat等命令是因为默认没有安装net-tools包,安装好CentOS 7.2后连接网络,通过默认的yum源可以安装net-tools包,就可以使用上述命令了。
[email protected] ~]# ifconfig -bash: ifconfig: command not found [[email protected] ~]# ip add show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 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 1500 qdisc pfifo_fast state UP qlen 1000 link/ether fa:16:3e:41:78:4e brd ff:ff:ff:ff:ff:ff inet 10.128.71.238/24 brd 10.128.71.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::4130:c2bc:434f:5e29/64 scope link valid_lft forever preferred_lft forever 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether fa:16:3e:03:4f:42 brd ff:ff:ff:ff:ff:ff [[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1 [[email protected] ~]# systemctl restart network.service [[email protected] ~]# yum -y install net-tools Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/4): updates/7/x86_64/primary_db | 3.6 MB 00:00:00 (2/4): extras/7/x86_64/primary_db | 130 kB 00:00:00 (3/4): base/7/x86_64/group_gz | 156 kB 00:00:01 (4/4): base/7/x86_64/primary_db | 5.7 MB 00:00:08 Determining fastest mirrors * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.cn99.com Resolving Dependencies --> Running transaction check ---> Package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================== Package Arch Version Repository Size ====================================================================================================================================== Installing: net-tools x86_64 2.0-0.22.20131004git.el7 base 305 k Transaction Summary ====================================================================================================================================== Install 1 Package Total download size: 305 k Installed size: 917 k Downloading packages: warning: /var/cache/yum/x86_64/7/base/packages/net-tools-2.0-0.22.20131004git.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Public key for net-tools-2.0-0.22.20131004git.el7.x86_64.rpm is not installed net-tools-2.0-0.22.20131004git.el7.x86_64.rpm | 305 kB 00:00:00 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>" Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 Package : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1 Verifying : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1 Installed: net-tools.x86_64 0:2.0-0.22.20131004git.el7 Complete! [[email protected] ~]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.128.71.238 netmask 255.255.255.0 broadcast 10.128.71.255 inet6 fe80::4130:c2bc:434f:5e29 prefixlen 64 scopeid 0x20<link> ether fa:16:3e:41:78:4e txqueuelen 1000 (Ethernet) RX packets 13174 bytes 1492282 (1.4 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 393 bytes 63067 (61.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.20.238 netmask 255.255.255.0 broadcast 192.168.20.255 inet6 fe80::5a63:7ec4:60ee:3a0 prefixlen 64 scopeid 0x20<link> ether fa:16:3e:03:4f:42 txqueuelen 1000 (Ethernet) RX packets 15654 bytes 11702290 (11.1 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4383 bytes 328314 (320.6 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 1 (Local Loopback) RX packets 408 bytes 32936 (32.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 408 bytes 32936 (32.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [[email protected] ~]#
时间: 2024-10-22 07:49:40