×


Failed to restart network service CentOS error

Are you trying to fix Failed to restart network.service CentOS error ?

This guide is for you.

Network scripts are deprecated in Red Hat Enterprise Linux 8 and no longer provided by default.
In Red Hat Enterprise Linux 8, to run the ifup and the ifdown scripts, NetworkManager must be running.
By default, if we try to use legacy network.service unit file it will not be available and may end up showing the following error:

[root@rhel-8 ~]# systemctl restart network
Failed to restart network.service: Unit network.service not found.

Here at Ibmi Media, as part of our Server management Services, we regularly help our Customers to resolve RHEL / CentOS related errors.

How to fix Failed to restart network.service CentOS, RHEL 7 and RHEL 8 error ?

Red Hat Enterprise Linux 8 uses the default networking service, NetworkManager.
As it is a dynamic network control and configuration daemon to keep network devices and connections up and active when they are available.
Before going into the steps for fixing this issue we will see some basic commands.

1. Starting Network Service with NetworkManager
To start NetworkManager:

# systemctl start NetworkManager

To enable NetworkManager automatically at boot time:

# systemctl enable NetworkManager

2. Start Network Service without NetworkManager
If we use NM_CONTROLLED=no in ifcfg file, then we will be unable to bring up interfaces with 'ifup' command.
The basic installation of RHEL 8 provides a new version of the ifup and ifdown scripts which call the NetworkManager service through the nmcli tool.
The custom commands in /sbin/ifup-local, ifdown-pre-local and ifdown-local scripts are not executed.

How to fix "Failed to restart network.service: Unit network.service not found" in RHEL 8 ?

On the RHEL system, we must have an active subscription to RHN.
However, we can configure a local offline repository using which "yum" package manager and install the provided rpm and its dependencies.
i. We can use the following commands to install deprecated network-scripts:

# yum install network-scripts

ii. Let us see the content of network-scripts rpm:

[root@rhel-8 ~]# rpm -ql network-scripts-10.00.1-1.el8.x86_64 | grep "/etc/rc.d/init.d/network"
/etc/rc.d/init.d/network

The ifup and ifdown scripts link will be installed with legacy network-scripts.

iii. Calling the legacy network-scripts shows a warning about their deprecation:

[root@rhel-8 ~]# ifup eth0
WARN : [ifup] You are using 'ifup' script provided by 'network-scripts', which are now deprecated.
WARN : [ifup] 'network-scripts' will be removed in one of the next major releases of RHEL.
WARN : [ifup] It is advised to switch to 'NetworkManager' instead - it provides 'ifup/ifdown' scripts as well.
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)


iv. After that we can use systemctl to restart the network service:

[root@rhel-8 ~]# systemctl restart network
[root@rhel-8 ~]# systemctl is-active network
active


How to fix "Failed to restart network.service: Unit network.service not found" in RHEL 7 ?

This error can be seen in RHEL 7 based systems due to any network configuration or network interface issues.
Following are the steps to fix "Failed to restart network.service: Unit network.service not found" in RHEL 7.

i. First, we need to check the network interface status.
For example, suppose the network interface is eth1. So we need to run ifconfig eth1 command to check the status of interface eth1:

[root@localhost ~]# ifconfig eth1
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.150 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::a00:27ff:fe1d:8e54 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:1d:8e:54 txqueuelen 1000 (Ethernet)
RX packets 105385 bytes 129825301 (123.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 28452 bytes 4965590 (4.7 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ii. Now, we can bring down the interface using ifdown eth1 and bring up again using ifup eth1 command:

[root@localhost ~]# ifdown eth1
[root@localhost ~]# ifup eth1

iii. Next, we can restart the network and check if the network is active or not:

[root@localhost ~]# systemctl restart network
[root@localhost ~]# systemctl is-active network
active

iv. Now if we check the network status, we can see that network service is up and running:

[root@localhost ~]# systemctl status network
● network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network; generated)
Active: active (exited) since Mon 2021-03-08 07:01:58 EDT; 23min ago
Docs: man:systemd-sysv-generator(8)
Process: 1068 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS)

Mar 7 19:43:30 localhost.localdomain systemd[1]: Starting LSB: Bring up/down networking...
Mar 7 19:43:30 localhost.localdomain network[1068]: WARN : [network] You are using 'network' service provided by 'network-scripts', which are now deprecated.
Mar 7 19:43:30 localhost.localdomain network[1089]: You are using 'network' service provided by 'network-scripts', which are now deprecated.
Mar 7 19:43:30 localhost.localdomain network[1068]: WARN : [network] 'network-scripts' will be removed in one of the next major releases of RHEL.
Mar 7 19:43:30 localhost.localdomain network[1090]: 'network-scripts' will be removed in one of the next major releases of RHEL.
Mar 7 19:43:30 localhost.localdomain network[1068]: WARN : [network] It is advised to switch to 'NetworkManager' instead for network management.
Mar 7 19:43:30 localhost.localdomain network[1091]: It is advised to switch to 'NetworkManager' instead for network management.
Mar 7 19:43:30 localhost.localdomain network[1068]: Bringing up loopback interface: [ OK ]
Mar 7 19:43:30 localhost.localdomain network[1068]: Bringing up interface eth1: [ OK ]
Mar 7 19:43:30 localhost.localdomain systemd[1]: Started LSB: Bring up/down networking.


[Still, stuck with Failed to restart network service CentOS error? – We can help you. ]


Conclusion

This article covers methods to fix 'Failed to restart network.service' on both RHEL 7 and RHEL 8. You can use "NetworkManager.service" as the default networking service in RHEL 8.
Red Hat Enterprise Linux 8 uses the default networking service, NetworkManager, which is a dynamic network control and configuration daemon to keep network devices and connections up and active when they are available.

If any of these scripts are required, the installation of the deprecated network scripts in the system is still possible with the following command:

# yum install network-scripts

In RHEL 7 /etc/rc.d/init.d/network was owned by initscripts but with RHEL 8 this tool is part of network-scripts rpm.

Also, you can restart you network by issuing following command:

sudo systemctl restart NetworkManager.service


You can also stop and start it by issuing:

sudo systemctl stop NetworkManager.service
sudo systemctl start NetworkManager.service