Today, when I configure a network for a server with the operating system OracleLinuxServerrelease5.7, I encountered the problem of backing up the ifcfg-eth0 configuration file, causing the NIC to be unable to bind an IP address. I think this is an interesting case. I would like to record it for your reference.
Today, when I configure a network for an Oracle Linux Server release 5.7 Server, I encountered the problem of backing up the ifcfg-eth0 configuration file, which caused the NIC to be unable to bind an IP address. I think this is an interesting case. I would like to record it for your reference to avoid making similar mistakes in the future.
The network is not configured when the system is installed. after the system is installed, the system administrator will learn about the IP address, subnet mask, and Gateway information before configuring the network. Back up a configuration file before modifying the ifcfg-eth0 Nic configuration file to avoid the failure to restore to the original configuration due to improper modification. This is also the cause of the incident.
- [root@localhost ~]# cd /etc/sysconfig/network-scripts/
- [root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-eth0_bak
- [root@localhost network-scripts]# more ifcfg-eth0_bak
- # Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
- DEVICE=eth0
- BOOTPROTO=dhcp
- HWADDR=00:50:56:92:56:05
- ONBOOT=yes
Next, add IP addresses and subnet masks,
- [root@localhost network-scripts]# vi ifcfg-eth0
- # Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
- DEVICE=eth0
- BOOTPROTO=static
- #BROADCAST=192.168.7.255
- HWADDR=00:50:56:92:56:05
- IPADDR=192.168.7.222
- NETMASK=255.255.255.0
- ONBOOT=yes
- TYPE=Ethernet
After adding the Gateway information in the configuration file/etc/sysconfig/network, restart the network service. The result is as follows:
- [root@localhost network-scripts]# more /etc/sysconfig/network
- NETWORKING=yes
- GATEWAY=192.168.7.1
- NETWORKING_IPV6=no
- HOSTNAME=localhost.localdomain
So through the setup command, enter the graphical configuration interface, the results are as follows, because the backup file name is ifcfg-eth0_bak, the results of Linux system will be considered as another Nic configuration information, as a result, the IP address cannot be bound to the NIC (because this configuration file does not exist ).
- [root@localhost ~]# setup
So rename the backup file to the bak_ifcfg-eth0, restart the network service, OK, Nic bound to the IP address, the network is smooth.
- [root@localhost network-scripts]# mv ifcfg-eth0_bak bak_ifcfg-eth0
- [root@localhost network-scripts]# service network restart
- Shutting down interface eth0: [ OK ]
- Shutting down loopback interface: [ OK ]
- Bringing up loopback interface: [ OK ]
- Bringing up interface eth0: [ OK ]
- [root@localhost network-scripts]#
At the same time I also saw some netizens encountered a similar problem on the Internet: http://www.linuxfly.org/post/291/, Linux configuration file modification must be careful, sometimes it is afraid of a space will lead to the result of reverse.