0

I have a Ubuntu machine that has access to the internet but fails to resolve hostnames.

I tried to edit /etc/resolv.conf like suggested in various places. But I can't display its contents or edit it permanently.

The interface config

My Network config at /etc/network/interfaces looks like so:

# This file describes the network interfaces available on your
# system and how to activate them. For more information, see
# interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 46.101.158.60
        netmask 255.255.192.0
        gateway 46.101.128.1
        dns-nameservers 8.8.8.8 8.8.4.4

Nameservers

So I do have a dns record and it points to 8.8.8.8 and 8.8.4.4 respectively.

I can ping these two:

# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=124 time=0.965 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=124 time=0.538 ms

# ping 8.8.4.4
PING 8.8.4.4 (8.8.4.4) 56(84) bytes of data.
64 bytes from 8.8.4.4: icmp_seq=1 ttl=61 time=0.977 ms

Details

$ uname -a
Linux XYXY 3.13.0-57-generic #95-Ubuntu SMP Fri Jun 19 09:28:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Resolv.conf

The file is there in /etc.

# ls -lia /etc/resolv.conf 
655492 lrwxrwxrwx 1 root root 29 Jul  5 15:29 /etc/resolv.conf -> ../run/resolvconf/resolv.conf

However I can't show the contents of it.

# cat /etc/resolv.conf 
cat: /etc/resolv.conf: No such file or directory

Additionally I can't change the file:

# echo "nameserver 8.8.8.8" >  /etc/resolv.conf
-bash: /etc/resolv.conf: No such file or directory

Workaround

As an initial workaround I did add some hosts in /etc/hosts but this gets very tedious once I need more domains.

Internal Reference VS#284

7
  • Does your actual /etc/resolv.conf correspond to the entry in /etc/network/interfaces?
    – Jos
    Jul 5, 2018 at 14:19
  • best safe solution is to reboot the computer (@Jos probably not, he said "the file gets deleted automatically")
    – damadam
    Jul 5, 2018 at 14:21
  • I've never heard of /etc/resolv.conf not being present at any Linux system - it will be regenerated, but never completely removed. @Besi did you restart the networking service?
    – Jos
    Jul 5, 2018 at 14:23
  • I did reboot the machine. I did update the question regarding resolv.conf
    – Besi
    Jul 5, 2018 at 14:29
  • @Jos I can neither display nor edit the file (as root). See my updated question.
    – Besi
    Jul 5, 2018 at 14:36

1 Answer 1

0

I did resolve the issue by sym-linking the /etc/resolv.conf file with a file in my home folder:

ln -s /home/me/config/resolv.conf /etc/resolv.conf

And then adding the nameservers there:

nameserver 8.8.8.8
nameserver 8.8.4.4
1
  • 1
    I don't think this is a good idea: the link will be overwritten by the next update of resolvconf.
    – Jos
    Jul 5, 2018 at 15:17

You must log in to answer this question.

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