Network faults caused by CentOS backup ifcfg-eth * files

Source: Internet
Author: User

We all know that the files under/etc/sysconfig/network-scripts/ifcfg-eth * are used to describe network settings in LINUX. However, you may not know that, due to ifup and other scripts, copying an ifcfg-eth * file to another file may cause some unintentional problems. It is related to the user's fault report today. The following is an example.

I. Fault symptom
According to the user's description, there is only one network card on the machine, and a fixed IP address and network segment are configured. For example:

Reference # pwd
/Etc/sysconfig/network-scripts
# Cat ifcfg-eth0
DEVICE = eth0
ONBOOT = yes
BOOTPROTO = static
IPADDR = 192.168.1.104
NETMASK = 255.255.255.0
GATEWAY = 192.168.1.1
# Ifconfig
Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: F0: 98: 69
Inet addr: 192.168.1.104 Bcast: 192.168.1.255 Mask: 255.255.255.0
Inet6 addr: fe80: 20c: 29ff: fef0: 9869/64 Scope: Link
Up broadcast running multicast mtu: 1500 Metric: 1
RX packets: 3832 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 3243 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 FIG: 1000
RX bytes: 463579 (452.7 KiB) TX bytes: 431767 (421.6 KiB)
Interrupt: 177 Base address: 0x1400

Lo Link encap: Local Loopback
Inet addr: 127.0.0.1 Mask: 255.0.0.0
Inet6 addr: 1/128 Scope: Host
Up loopback running mtu: 16436 Metric: 1
RX packets: 0 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 0 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 txqueuelen: 0
RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B)
However, the route table displays:
Reference # route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0*255.255.255.0 U 0 0 0 eth0
192.168.1.0*255.255.255.0 U 0 0 0 eth0
Default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
It can be seen that there is an additional route to the 10.0.0.0 CIDR block. This route is the same as the network segment of the firewall route. As a result, when the client accesses the machine through the firewall, the system prompts that the connection is unavailable. This problem is not found on other machines with the same configuration.

Ii. troubleshooting
First, I suspect that someone manually adds a route and deletes it:
Reference # route del-net 10.0.0.0 netmask 255.255.255.0
# Route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0*255.255.255.0 U 0 0 0 eth0
Default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
Test with the client to ensure normal access.
Restart the server and find that the route for 10.0.0.0 is added again. This indicates that it is not manually added, but activated when the machine is started. Therefore, I analyze the script executed from the machine startup, but view/etc/rc. sysinit,/etc/rc. d/*,/etc/rc. no exception is found in scripts such as local.
Previous experiences tell me that it may be related to the/etc/sysconfig/network-scripts directory. Therefore, I execute:
Reference # grep '10. 0.0 '*
Ifcfg-eth0.081210: IPADDR = 10.0.0.1
Network-functions-ipv6: # test 10.0.0.0/8 (RFC 1918/private)
Okay, I found the problem. The ifcfg-eth0.081210 content is as follows:
Reference # cat/etc/sysconfig/network-scripts/ifcfg-eth0.081210
DEVICE = eth0
ONBOOT = yes
BOOTPROTO = static
IPADDR = 10.0.0.1
NETMASK = 255.255.255.0
Follow these steps to restart the network:
Reference # service network restart
Closing interface eth0: [OK]
Disable the loop interface: [OK]
Pop-up loop interface: [OK]
Pop-up page eth0: [OK]
Eth0.081210: [OK]
When the network is started, an eth0.081210 Nic is activated, and its DEVICE = eth0, ONBOOT = yes, and the network segment is 10.0.0.0/24. Therefore, an abnormal route exists in the routing table.

Iii. troubleshooting
Find the cause and solve the problem. Just delete the redundant configuration file. Run:
Reference # Music/etc/sysconfig/network-scripts/ifcfg-eth0.081210/tmp
# Service network restart
Closing interface eth0: [OK]
Disable the loop interface: [OK]
Pop-up loop interface: [OK]
Pop-up page eth0: [OK]
# Route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0*255.255.255.0 U 0 0 0 eth0
Default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
Iv. Cause
The reason is that the user made network adjustments in 20081210, during the period of Security, back up the original ifcfg-eth0 into a ifcfg-eth0.081210. When the network is started, after reading the content of the file, it is mistakenly thought that this is also a NIC and activated.
/Etc/rc. d/network is the configuration file of the network service, which includes:
Reference interfaces =$ (ls ifcfg * | \
LANG = C sed-e "$ __sed_discard_ignored_files "\
-E'/\ (ifcfg-lo \ | :\| ifcfg-. *-range \)/d '\
-E'/ifcfg-[A-Za-z0-9 \. _-] \ + $/{s/^ ifcfg-// g; s/[0-9]/&/} '| \
LANG = C sort-k 1, 1-k 2n | \
LANG = C sed's ///')
Visible, which also treats the ifcfg-eth0.081210 as a nic. This is the underlying cause of the fault.
Therefore, starting the network service depends on script execution and may cause some misjudgment problems. We recommend that you do not add unnecessary configuration files, especially files starting with ifcfg, in the network-scripts directory.

Iv. Test
A simple test is to create a virtual network card using this configuration file. There is a configuration file:
Reference # cat/etc/sysconfig/network-scripts/ifcfg-eth0.0
DEVICE = eth0: 0
ONBOOT = yes
BOOTPROTO = static
IPADDR = 10.0.0.1
NETMASK = 255.255.255.0
Restart the network:
Reference # service network restart
Closing interface eth0: [OK]
Disable the loop interface: [OK]
Pop-up loop interface: [OK]
Pop-up page eth0: [OK]
Pop-up page: eth0.0: [OK]
# Ifconfig eth0: 0
Eth0: 0 Link encap: Ethernet HWaddr 00: 0C: 29: F0: 98: 69
Inet addr: 10.0.0.1 Bcast: 10.0.0.255 Mask: 255.255.255.0
Up broadcast running multicast mtu: 1500 Metric: 1
Interrupt: 177 Base address: 0x1400
Do you understand? O (∩) O Haha ~


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.