Wondering how to fix ‘Failed to restart network.service’? We can help 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 Bobcares, we fix similar issues as a part of our Server Management Services. Today, let’s see how our Support Techs fix this for our customers.
- Troubleshoot
- Start Network Service without NetworkManager
- Fix “Failed to restart network.service: Unit network.service not found” in RHEL 8
- How to fix “Failed to restart network.service: Unit network.service not found” in RHEL 7
How to fix ‘Failed to restart network.service’ on RHEL 7 and RHEL 8
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.
Starting Network Service with NetworkManager
To start NetworkManager:
# systemctl start NetworkManager
To enable NetworkManager automatically at boot time:
# systemctl enable NetworkManager
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, wecan configure a local offline repository using which “yum” package manager and install the provided rpm and its dependencies.
We can use the following commands to install deprecated network-scripts:
# yum install network-scripts
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.
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)
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
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
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
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
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 the error? – We can help you]
Conclusion
To conclude we saw how our Support Techs fix ‘Failed to restart network.service’ on both RHEL 7 and RHEL 8
┌──(root㉿kali)-[~]
└─# service network-manager restart
Failed to restart network-manager.service: Unit network-manager.service not found.
I kali linux on virtual machine.
Any tips
Hi,
Our Experts can help you with the issue, we’ll be happy to talk to you on chat (click on the icon at right-bottom).
I can not fix my network kali please help me
Hi,
Please contact our support team via live chat(click on the icon at right-bottom)
i have the same issue
Hi Amine,
Please contact our support team via live chat(click on the icon at right-bottom).