24

I add some a line dns-nameservers 8.8.8.8 in my /etc/network/interfaces. I want to reload this config without reboot.

However, when I tried: sudo service networking restart
I got a Unit networking.service not found error

sudo /etc/init.d/networking restart
I got /etc/init.d/networking: command not found

How can I fix this? I use Ubuntu Server 18.04.2 LTS

2 Answers 2

33

Things have changed over time. Dependent on your installation, you want to check the service names with

systemctl list-unit-files | grep -i network

And, most likely in your case, it's

systemctl restart NetworkManager
7
  • 2
    Unit NetworkManager.service not found on Ubuntu 18.04 server.
    – Kaz
    Commented Dec 24, 2020 at 23:17
  • @Kaz What's your output of systemctl list-unit-files | grep -i network? Commented Dec 26, 2020 at 18:59
  • Like this: pastebin.com/raw/1pmmHw9G
    – Kaz
    Commented Dec 26, 2020 at 19:20
  • 4
    @Kaz Yeah, thanks. Then your networking is managed without NetworkManager and solely by systemd-networkd. In your case it's systemctl restart systemd-networkd then. Commented Dec 27, 2020 at 17:19
  • 2
    An Ubuntu update on 20.10 changed it for me today apparently from network-manager to NetworkManager Commented Feb 11, 2021 at 9:42
2

Since version 15.04, Ubuntu comes with systemd as default instead of initd. systemd-networkd exactly

Use systemctl restart networking

2
  • 7
    Results in Unit networking.service not found on Ubuntu 18.04 server.
    – Kaz
    Commented Dec 24, 2020 at 23:16
  • Here's what work for me, on Ubuntu 20 server, and no interfaces file nor interface.d folder, so create an interfaces file with auto eth0 iface eth0 net dhcp then disabled unattended upgrades systemctl disable --now unattended-upgrades, then reboot
    – pingle60
    Commented Jun 18 at 16:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .