Can't start CentOS 7 "network" service

263,334

Solution 1

In Centos7.0 disabling NetworkManager will leave a dhcp client running configured for NetworkManager. This causes the error message RTNETLINK answers: File exists when the network service is started.

The stale dhclient process has the additional "benefit" that when the lease expires your dhclient will choke, since it cannot reach NetWorkManager, thus removing your IP address.

If you grep for it, you will see that it points to a NetWorkManager configuration file.

[root@host ~]# ps -ef | grep dhc
root      1865   792  0 Apr28 ?        00:00:00 /sbin/dhclient -d -sf \
 /usr/libexec/nm-dhcp-helper -pf /var/run/dhclient-eno1.pid -lf\
 /var/lib/NetworkManager/dhclient-c96e56d3-a4c9-4a87-85ca-93dc0ca268f2-eno1.lease\
 -cf /var/lib/NetworkManager/dhclient-eno1.conf eno1

So what you can do is kill the dhclient and only then start your network service.

Solution 2

An IP conflict will also cause this error. Try: systemctl stop network, then ifup eth0.

Solution 3

I too faced this today on a CentOS 7.2 cloned virtual machine. This is how I fixed it.

systemctl disable NetworkManager
systemctl enable network

Find MAC address of the interface through command /sbin/ifconfig -a and append that in /etc/sysconfig/network-scripts/ifcfg-<interface_name>. You can use the below commands for the first interface.

nic_file=`ls /etc/sysconfig/network-scripts/ifcfg-e*`
ifconfig -a | grep ether | awk '{ print $2 }' | sed 's/.*/HWADDR=&/' >> ${nic_file}

Then fire reboot to restart the server

Solution 4

It seems this happens also if you manually configure an interface that isn't connected to the network.

Solution 5

as it has been already identified - this error pops up with any issue while setting up network: IP conflict, routing issues, etc.

Look at your gateway settings to confirm your gateways are set properly and things are what they need to be with /etc/syscofig/network and each of the /etc/sysconfig/network-scripts/ifcfg-* look for duplicate IP, routes set via /etc/sysconfig/network-scripts/route-* if memory serves me right gateways now can be set in both ifcfg-* and route-* files. So confirm there's no duplication or overlap.

Share:
263,334

Related videos on Youtube

Gazel
Author by

Gazel

IT professional

Updated on September 18, 2022

Comments

  • Gazel
    Gazel almost 2 years

    I Can't start CentOS 7 "network" service after disabling and removing "NetworkManager" service. When I check the network service status, it comes up with the following error:

    #systemctl status network.service
    network.service - LSB: Bring up/down networking
       Loaded: loaded (/etc/rc.d/init.d/network)
       Active: failed (Result: exit-code) since Fri 2015-01-16 22:30:46 GMT; 38s ago
      Process: 4857 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)
    
    Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
    Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
    Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
    Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
    Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
    Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
    Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
    Jan 16 22:30:46 localhost.localdomain systemd[1]: network.service: control process exited, code=exited status=1
    Jan 16 22:30:46 localhost.localdomain systemd[1]: Failed to start LSB: Bring up/down networking.
    Jan 16 22:30:46 localhost.localdomain systemd[1]: Unit network.service entered failed state.
    

    In earlier CenOS it didn't seem to give any problems when switching from the "NetworkManager" service to the network service. Any ideas as to what causes the problem and how to fix it?

    Note: I used yum erase to remove network manage service.

    Here is additional info as asked:

    /etc/sysconfig/network-script/ifcfg-enp8s0
    TYPE=Ethernet
    BOOTPROTO=dhcp
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    NAME=enp8s0
    UUID=453a07fe-1b07-4f29-bc32-f2168e50706a
    ONBOOT=yes
    HWADDR=XXXXXXXXXXX
    MACADDR=XXXXXXXXXX
    PEERDNS=yes
    PEERROUTES=yes
    IPV6_PEERDNS=yes
    IPV6_PEERROUTES=yes
    

    /etc/hosts
    127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
    

    /etc/resolv.conf
    ; generated by /usr/sbin/dhclient-script
    search customer.marples.midcity.lan
    nameserver 10.241.128.1
    
    • Mosh Pit
      Mosh Pit over 9 years
      Since I cannot post a comment because of my low reputation, I'm posting this as an answer, which it is NOT intended to be. <br/> <br/> Can you post the following: <br/> <br/> /etc/sysconfig/network-script/ifcfg-eth0<br/> /etc/hosts<br/> /etc/resolv.conf<br/> <br/> You might want to check your configured routes for that specific NIC (found in /etc/sysconfig/network-scripts/route-<interface>), since this might cause similar errors. <br/> <br/> Did you try ifdown eth0 and ifup eth0 instead of systemctl (re)start network? Did you disable/uninstall Network Manager using yum remove
    • Gazel
      Gazel over 9 years
      Hi, thanks for resupplying. I've updated my question info above, have a look. Yes I did used yum erase to remove the NetworkManager service. I have not tried the ifdown eth0 and ifup eth0, hoever My network connection is still up and running despite removing the networkmanager service and inability to start the network service.
    • Mosh Pit
      Mosh Pit over 9 years
      You have HWADDR=XXXXXXXXXXX AND MACADDR=XXXXXXXXXX in your interface config. This seems to be wrong, since it looks like it's intended to be the same. Try one of the things I recommended (commenting this part in your config), restart and try again. Is this CentOS 7 box SELinux enforcing? Are you running this system on a hardware or in a virtual environment? hosts and resolv.conf look good so far.
    • Gazel
      Gazel over 9 years
      Originally I spoofed the MAC in the NetworkManager's GUI, so it added the fake MACADDR in addition to the real HWADDR, so that's why it's there. Should i remove the MACADDR line? The SELinux status reads enabled. Im running it on a hardware.
    • Mosh Pit
      Mosh Pit over 9 years
      Try commenting HWADDR and/or MACADDR, tho I think taking out MACADDR should be sufficient. Restart the whole box and look if network is coming up properly. Also, if you don't use IPv6, take that crap out there. You could also check your HWADDR by using cat /sys/class/net/ens192/address to make sure it's setup properly.
    • Gazel
      Gazel over 9 years
      I've commented out all IPV6 lined and both MAC lines, rebooted the box, no luck so far, still fails to start the service. Oh, and I did use yum erase to remove network manager service.
    • Mosh Pit
      Mosh Pit over 9 years
      Try just commenting MACADDR, leave HWADDR as it is, but check it first with cat /sys/class/net/<interface>/address. Did you install net-tools?
    • Gazel
      Gazel over 9 years
      /sys/class/net/enp8s0/address contains the spoofed MACADDR, and it's read only file. Also commenting out MACADDR didn't fix the prolem.
    • Gazel
      Gazel over 9 years
      I've just read about yum erase vs purge and I thing I should have used purge, as it does not leave any service config files, as opposed to erase. I think I'll give it a go, install back and then yum purge the NetworkManager service.
    • Mosh Pit
      Mosh Pit over 9 years
      Sounds worth a try. Report back when you're done.
    • Mosh Pit
      Mosh Pit over 9 years
      Did you get it up and running now? If so, I'm curious what the problem was in the end and how you figured it out!
    • Gazel
      Gazel over 9 years
      I didn't have much time to play with Centos 7 so I just went back to 6, and that is a fix for now.
  • MichaelZ
    MichaelZ over 8 years
    Yup, killing dhclient fixed the issue for me. Thanks
  • onlyanegg
    onlyanegg over 8 years
    I also don't have enough reputation to comment, but I wanted to support Hans's answer and add that I had to change the bootproto to "none" in my ifcfg files. The dhclient was only getting called when trying to restart networking, and killing the dhclient process didn't help, because another would spawn in it's place. Modifying the ifcfg files solved my problem.