Today, when I was practicing under Linux, I saw two network cards under the ifconfig command, one is the l0 network card, and the other is eth1. At the beginning, it was l0 and eth0. I don’t know how it became eth1, so I became obsessive-compulsive and deleted all network card configurations. As a result, when I restarted the network service, it was a tragedy…
First of all, let’s talk about the reason why my network card changed from eth0 to eth1: it was due to the previous operation error, and I didn’t know this before, so I followed the online tutorial. As a result, I configured eth0 to eht0, and the system couldn’t find it. Later, due to the configuration failure, I configured it once, and the result became eth1. Until today, I found this error…
Because I couldn’t change eth0, I saw that there was a tutorial on the Internet, but it didn’t work.. (I don’t know why.) so I deleted all the network card configuration with one hand. The steps are as follows:
First, stop the network service
1./etc/sysconfig/network scripts directory, delete the network card configuration that you want to delete. I want to delete eth1, so RM – RF ifcfg-eth1, and so on
2./etc/sysconfig/Networking/devices directory, delete all files, simple and easy
3./etc/sysconfig/Networking/profiles/default directory, delete all files related to eth1
After starting the network service, there should be only one l0 network card left, and the service is stopped
Write network card configuration file
1./etc/sysconfig/network scripts directory, write the configuration file with VI, here I name it ifcfg-eth0 (my eth0 is finally coming back)
The configuration is as follows:
DEVICE=eth0
ONBOOT=yes
IPADDR=172.168.0.108
BOOTBROTO=none
NETMASK=255.255.255.0
PREFIX=24
Here is a simple write a few configuration, complete configuration I can not remember, there is no need to remember. I found a more complete configuration on the Internet, you can have a look
DEVICE=eth0 #Indicates the device name
NM_CONTROLLED=yes #network mamager's parameter, effective in real time, no need to reboot
ONBOOT=yes #Set to yes to enable network connection automatically on power on
IPADDR=192.168.21.129 #IP address
BOOTPROTO=none # set to none to disable DHCP, set to static to enable static IP address, set to dhcp to enable DHCP service
NETMASK=255.255.255.0 #subnet mask
DNS1=8.8.8.8 #the first dns server
TYPE=Ethernet #Network type is: Ethernet
GATEWAY=192.168.21.2 #set gateway
DNS2=8.8.4.4 #second dns server
IPV6INIT=no #Disable IPV6
USERCTL=no #Whether to allow non-root user to control the device, set to no, can only be changed by root user
HWADDR=00:0C:29:2C:E1:0F #Mac address of the NIC
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
NAME="System eth0" #Define the device name
After I started the network service, I reported the error of device eth0 does not see to be present, delaying initialization. After searching on the Internet, I found that it was caused by the MAC address mismatch. There are two solutions
1. 70 persistent in/etc/udev/rules. D directory- net.rules File, open, modify the MAC address inside, and ifcfg-eth0 can be the same
2. Delete/etc/udev/rules.d/70-persistent directly- net.rules File, then restart, simple and crude
After restart, we will find that the network service can start normally, and the current network card is l0 and eth0
Read More:
- [Solved] Job for network.service failed because the control process exited with error code. See “systemctl st
- [Solved] CentOS Network Card startup error: RTNETLINK answers: File exist
- Centos8 Could not restart the Network: Failed to restart network.service: Unit network.service not found
- Linux: Configure Network address through Netplan
- Linux Connect Error: network.service failed [How to Solve]
- [Solved] KVM Failed to Startup Error: error: Network not found: no network with matching name ‘default‘
- Virtual machine failed to start network service error: ob for network.service failed because the control process exited with error code
- [FAILED] Failed to start Raise network interfaces
- After Centos installation is complete, ifconfig: command not found
- [Solved] Docker Filed to Start Container: Error response from daemon: network XXX not found
- [Solved] websocket error in Linux service: / lib64 / libc. So. 6: version ` glibc_2.17‘ not found
- Solution to gzip: stdin: invalid compressed data — format violated error in decompressing. Tgz file under Linux
- [Nginx] solution: it can’t be accessed on the background API interface after HTTPS (access the specified port through the domain name)
- Service network restart reported an error and failed to restart [How to Solve]
- Job for network.service failed [How to Solve]
- [Solved] pxp_lib.h:19:10: fatal error: linux/pxp_device.h: No such file or directory
- Linux Nagios failed to log in to internal server error (Fixed)
- [Solved] Service network restart reported an error and failed to restart
- [Solved] Virtual machine Failed to restart network Error: Error:Failed to start LSB: Bring up/down networking
- [Solved] NIC cannot be generated vf, intel/mellanox, write error: Cannot allocate memory “not enough MMIO resources for SR-IOV”