Network faults caused by Linux backup of ifcfg-eth0 files

Source: Internet
Author: User
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.

 
 
  1. [root@localhost ~]# cd /etc/sysconfig/network-scripts/ 
  2. [root@localhost network-scripts]# cp ifcfg-eth0  ifcfg-eth0_bak 
  3. [root@localhost network-scripts]# more ifcfg-eth0_bak 
  4. # Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) 
  5. DEVICE=eth0 
  6. BOOTPROTO=dhcp 
  7. HWADDR=00:50:56:92:56:05 
  8. ONBOOT=yes

Next, add IP addresses and subnet masks,

 
 
  1. [root@localhost network-scripts]# vi ifcfg-eth0 
  2. # Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) 
  3. DEVICE=eth0 
  4. BOOTPROTO=static 
  5. #BROADCAST=192.168.7.255 
  6. HWADDR=00:50:56:92:56:05 
  7. IPADDR=192.168.7.222 
  8. NETMASK=255.255.255.0 
  9. ONBOOT=yes 
  10. TYPE=Ethernet 

After adding the Gateway information in the configuration file/etc/sysconfig/network, restart the network service. The result is as follows:

 
 
  1. [root@localhost network-scripts]# more  /etc/sysconfig/network 
  2. NETWORKING=yes 
  3. GATEWAY=192.168.7.1 
  4. NETWORKING_IPV6=no 
  5. 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 ).

 
 
  1. [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.

 
 
  1. [root@localhost network-scripts]# mv ifcfg-eth0_bak  bak_ifcfg-eth0 
  2. [root@localhost network-scripts]# service network restart 
  3. Shutting down interface eth0:  [  OK  ] 
  4. Shutting down loopback interface:  [  OK  ] 
  5. Bringing up loopback interface:  [  OK  ] 
  6. Bringing up interface eth0:  [  OK  ] 
  7. [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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.