1

Seems that I can't change resolv.conf: changes are reset after reboot or disabling/enabling Wi-Fi. It contains nameserver 127.0.0.1, and I can't connect to any site. When I manually change it to nameserver 8.8.8.8, everything works.

What I've tried:

  1. Changing /etc/resolvconf/resolv.conf.d/base. Currently it contains

    nameserver 8.8.8.8 
    nameserver 8.8.4.4
    
  2. Editing /etc/dhcp/dhclient.conf

    It had the lines

    request subnet-mask, broadcast-address, time-offset, routers,
            dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers, netbios-scope,
            interface-mtu,rfc3442-classless-static-routes, ntp-servers, 
            domain-name-servers, dhcp6.name-servers, netbios-name-servers;
    

    I removed the last three, added line

    prepend domain-name-servers 8.8.8.8, 8.8.4.4;
    

    and ran /etc/init.d/networking restart, but it didn't help either.

Zanna
  • 70,465
  • Thanks for your answers, but, as I've said, I tried to change resolf.conf.d/head, tail and base. sudo resolvconf -u takes no effect on content of resolv.conf and only produces a warning: "/etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /run/resolvconf/resolv.conf". In Wi-Fi settings for network I'm using I've set 'Automatic (DHCP)' and entered 8.8.8.8, 8.8.4.4 as DNS. – user3447843 Feb 17 '18 at 22:37
  • Solution with echo 8.8.8.4 >> /etc/resolv.conf on startup seems to work, but only until I reconnect to network. – user3447843 Feb 17 '18 at 22:42

1 Answers1

2

Install resolvconf: sudo apt-get install resolvconf and once done edit /etc/resolvconf/resolv.conf.d/base and put your nameservers in it:

nameserver 8.8.8.8 
nameserver 8.8.4.4

Once done, run sudo resolvconf -u

That should do it, alternatively, you can use a "workaround" (I would not unless I have to) and edit /etc/rc.local and put the following two lines:

echo 8.8.8.4 >> /etc/resolv.conf
echo 8.8.8.4 >> /etc/resolv.conf

That would append the lines to /run/systemd/resolve/stub-resolv.conf because /etc/resolv.conf is a symbolic link to /run/systemd/resolve/stub-resolv.conf.

But for that to run, the /etc/rc.local file must exist with the right content + permissions:

-rwxr-xr-x 1 root root 658 Feb 11 17:31 /etc/rc.local

In case yours does not exist (and I wouldn't expect it to), create one with the following content and make sure you change the permissions as shown above:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

echo 8.8.8.4 >> /etc/resolv.conf
echo 8.8.8.4 >> /etc/resolv.conf

exit 0

I hope this helps.

Just for the record:

tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=1637540k,mode=755

/run is a tmpfs which means any changes done to any path within/run are wiped out once you reboot your system.

marko
  • 928