I am using Ubuntu 12.04.
My /etc/network/interfaces
file consists of:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.58
gateway 192.168.1.1
network 192.168.1.0
broadcast 192.168.1.255
dns-nameservers 66.212.63.228 66.212.48.10
I ran the command: /etc/init.d/networking restart
Which responded with:
*Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
*Reconfiguring network interfaces...
RTNETLINK answers: File exists
Failed to bring up eth0
[ OK ]
Next I ran ping google.com and received:
ping: unknown host google.com
I am not sure if my interfaces refreshed. How do I properly configure my network with my static DNS addresses?
Best Answer
As the questioner gives the contents of his
/etc/network/interfaces
I infer that he is using ifup to configure interfaces. But since he may actually be using NetworkManager, I will discuss that as well.If you are using ifup then DNS settings go in
/etc/network/interfaces
. For each interface you adddns-*
options appropriate for the nameserver(s) available over that interface. E.g., if a nameserver at address 1.2.3.4 is available over interface eth0, then adddns-nameservers 1.2.3.4
to theiface eth0
stanza.If you are using NetworkManager then settings are entered in the Connection Editor (network indicator | Edit Connections...) in the IPv4 Settings tab.
Doing
/etc/init.d/networking restart
to reconfigure interfaces is deprecated. If you are usingifup
then firstifdown
each active network interface, thenifup
each interface. If you are using NetworkManager then, first, disable networking using the indicator (top of the desktop); then open a terminal and runand then enable networking using the indicator.
Or you can just reboot.
Regarding the fact that
/etc/init.d/networking restart
resulted inThis means that ifupdown thinks that
eth0
is already up. Useifdown --force eth0
to causeifupdown
to stop believing that it has already configured the interface.Regarding the "deprecated" message, this message is no longer printed in Ubuntu 12.10 but you should still note that initscripts are "on their way out". To restart a service
foo
, useservice foo restart
orrestart foo
. Note also that if you want to reconfigure your interfaces it is better to ifdown them one by one than to rely on restarting "networking".