0

My Raspbian server "forgets" it's hosts after resrtat.

The only solution that I have found is to manually run:

sudo sh -c 'echo "nameserver 8.8.8.8" >> /etc/resolv.conf'

However, it is erased on restart and requires me to input it again. I want to make this as unattended as possible.

Since I use it as both a print server and as a IRC core, it must have a static IP.

My current /etc/network/interfaces file looks like this:

auto lo

iface lo inet loopback
iface eth0 inet static

address 192.168.0.64
netmask 255.255.255.0
gateway 192.168.0.1

wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

address 192.168.0.64
netmask 255.255.255.0
gateway 192.168.0.1

I have attempted to add google dns server to this file at the end, but did not work.

Additionally, when my server starts, there is an error message:

[FAIL] Not running dhcpcd client because /etc/network/interfaces defines some interfaces that will use a DHCP client.

I am sure it is relates, but not sure how.

Please help me find a solution that will be a permanent fix, so that I can restart my server remotely without having to connect to it and manually run:

sudo sh -c 'echo "nameserver 8.8.8.8" >> /etc/resolv.conf'

Thank You!

0
0

First of all, you need to remove the excess from your file. Comment out everything from the wpa-roam (with a # symbol at the start of each line) onwards.


/etc/resolv.conf should not be changed by you on modern distros. The first couple of lines of the file on my Raspbian (and others) says:

# 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

Therefore, read man resolvconf to see how it's updated - it could be your network scripts, or Network Manager.

If you're not using Network Manager, then chances are you'll need to add the relevant stanza to /etc/network/interfaces:

auto lo
auto eth0

iface lo inet loopback

iface eth0 inet static
    address 192.168.0.64
    netmask 255.255.255.0
    gateway 192.168.0.1
    dns-nameservers 8.8.8.8

Note the dns-namservers entry.

If you're using Network Manager and a graphical desktop environment, then you can probably add the DNS servers in there.

If you're not using a graphical desktop environment but you are using Network Manager then the nmcli tool may help you configure your DNS resolvers:

$ sudo nmcli con mod eth0 ipv4.dns "8.8.8.8"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.