0

Apologies if this has been answered before, I searched and couldn't find a solution.

I have setup my ubuntu 16.04 desktop with a static IP. However on startup it is not able to resolve hostnames. Surprising if I manually restart the network service with:

sudo /etc/init.d/networking restart

It fixes my DNS issue. But I have to do this every time on startup.

I think the issue is with how my resolve.conf file is being auto-written on boot.

For example on boot up it has:

ow@ubuntu002:~$ cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
dns-nameservers 8.8.8.8 8.8.4.4

And after sudo /etc/init.d/networking restart:

ow@ubuntu002:~$ cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4
dns-nameservers 8.8.8.8 8.8.4.4

Appreciate any help with this. I can't help but try to get to the root cause of this.

EDIT:

@Simon Sudler: yes I modified /etc/network/interfaces as well as /etc/NetworkManager/NetworkManager.conf. It was based on online tutorials.

Here is the content of my interfaces file:

ow@ubuntu002:~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto enp0s31f6
iface enp0s31f6 inet static
address 192.168.0.101
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8 8.8.4.4
ow@ubuntu002:~$ 

@oscar1919: I tried your solution and it fixed the issue!

Thank you both for your help.

1 Answers1

0

You can install a package resolvconf, which will modify the way /etc/resolv.conf is built up at system boot. sudo apt install resolvconf
You can then create or modify a file /etc/resolvconf/resolv.conf.d/tail. If you put in this file a line nameserver 8.8.8.8, this line will be added at the end of /run/resolvconf/resolv.conf at boot. /etc/resolv.conf will now be a symbolic link to this file.
(see also here (DNS set to systemd's 127.0.0.53 - how to change permanently?)

oscar1919
  • 1,707