Today, CentOS 7 was installed on a PC, and the minimum installation mode was selected. After the installation was completed, the IP address of the PC was checked by using ifconfig immediately (DHCP has been installed on the LAN). An error message was displayed indicating that the ifconfig command was not found.

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

Echo $PATH = $PATH = $PATH = $PATH = $PATH = $PATH = $PATH

[root@centos1 ~]# echo $PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

As shown above, /usr/sbin, where the hypervisor is placed, already exists. /usr/sbin/ls = /usr/sbin/ls = /usr/sbin/

[root@centos1 ~]# ls /usr/sbin/

I’m still trying to find ifconfig.

[root@centos1 ~]# find / -name "ifconfig"

At this point, you should use a command instead of ifconfig. Search on Baidu, sure enough, has used IP command instead of ifconfig command. Common IP command parameters are listed below.

Ip [option] action object {link | addr | route... }# ip link show                           
#Display network interface information# ip link set eth0 upi                  
#Open the network card# ip link set eth0 down                  
#Close the network card# ip link set eth0 promisc on            
#The nic mixed mode is enabled# ip link set eth0 promisc offi          
#The mixed mode of the NETWORK adapter is disabled# ip link set eth0 txqueuelen 1200       
#The nic queue length is set# ip link set eth0 mtu 1400              
#The maximum transmission unit (MTU) of a NIC is set# ip addr show                           
#The IP address of the NIC is displayed# ip addr add 192.168.0.1/24 dev eth0    
#Set the IP address of eth0 to 192.168.0.1IP addr del 192.168.0.1/24 dev eth0    
#The IP address of the eth0 NIC is deleted# ip route list                                            
#Viewing Routing Information# IP route add 192.168.4.0/24 via 192.168.0.254 dev eth0 
#Set the gateway of network segment 192.168.4.0 to 192.168.0.254, and data is routed through eth0IP route add default via 192.168.0.254 dev eth0        
#Set the default gateway to 192.168.0.254# ip route del 192.168.4.0/24                              
#None Example Delete the gateway of the network segment 192.168.4.0# ip route del default                                     
#Deleting a Default Route
Copy the code

After entering the IP addr command, it is found that the ENP2s0 network adapter (the ENP2s0 is my network adapter here) has no IP address.

[root@centos1 ~]# ip addr

Since there is no IP address, go to /etc/sysconfig/network-scripts to see the configuration file name of the network adapter IP information.

[root@centos1 ~]# ls /etc/sysconfig/network-scripts/
ifcfg-enp2s0  ifdown-eth   ifdown-post    ifdown-Team      ifup-aliases  ifup-ipv6   ifup-post    ifup-Team      init.ipv6-global
ifcfg-lo      ifdown-ippp  ifdown-ppp     ifdown-TeamPort  ifup-bnep     ifup-isdn   ifup-ppp     ifup-TeamPort  network-functions
ifdown        ifdown-ipv6  ifdown-routes  ifdown-tunnel    ifup-eth      ifup-plip   ifup-routes  ifup-tunnel    network-functions-ipv6
ifdown-bnep   ifdown-isdn  ifdown-sit     ifup             ifup-ippp     ifup-plusb  ifup-sit     ifup-wireless
Copy the code

Seen from the results, before save network card IP information configuration file name was transformed by the previous ifcfg – eth0 ifcfg – enp2s0, if you still ifcfg – eth0, then modify the name of the configuration file is ok, I here has been changed to ifcfg – enp2s0, ok. Since the system has given him such a name, just modify the configuration file. Cat ifcfg-enp2s0 first

[root@centos1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp2s0
HWADDR=00:E0:69:01:6A:96
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp2s0
UUID=5b0a7d76-1602-4e19-aee6-29f57618ca01
ONBOOT=no
Copy the code

BOOTPROTO= DHCP, but ONBOOT=no, use vi to change ONBOOT=no to ONBOOT=yes, then use shutdown -r to restart CentOS. Network command restart network card, after the introduction, I here is the habitual use shutdown -r restart, vi is Linux text editor, similar to Windows notepad. Exe [notepad software], will not use friends please baidu VI).