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

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

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

Use systemctl restart networking

1