This question already has an answer here:
I'm a Linux novice experimenting with setting up a DNS cache server on a Pine64 on Ubuntu 16.04. I'm trying to set up a static IP-address with a a local Bind9 DNS-server. I've followed this great tutorial, and looked at several others.
However, I'm having trouble with getting the changes in
/etc/resolv.conf to stick. /: When I reboot, the settings in
/etc/network/interfaces are not written to
This is my
# interfaces(5) file used by ifup(8) and ifdown(8) # Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d # Disable wlan1 by default (8723bs has two intefaces) iface wlan1 inet manual # Loopback interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.0.18 netmask 255.255.255.0 gateway 192.168.0.1 dns-nameservers 192.168.0.18 dns-search green.intra
This is my
# run resolvconf? RESOLVCONF=yes # startup options for the server OPTIONS="-4 -u bind"
From those two files, I was under the impression that the
/etc/resolv.conf should become this (automatically, upon booting):
# 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 192.168.0.18 search green.intra
...but instead it becomes this:
# 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 220.127.116.11 nameserver 18.104.22.168 search home
If I add my desired settings to
/etc/resolv.conf, everything works as I expect, until I reboot.
What am I doing wrong?
Edit: I have RTFM in trying to figure this out:
As suggested in the answer to the proposed duplicate question, using
service networking restart might not be reliable in this situation. Instead, I tried the following:
ubuntu@pinex:~$ sudo ifdown -v eth0 Reading directory /etc/network/interfaces.d Parsing file /etc/network/interfaces.d/eth0 ifdown: interface eth0 not configured
ubuntu@pinex:~$ sudo ifdown -v eth0 Reading directory /etc/network/interfaces.d Parsing file /etc/network/interfaces.d/eth0 ifdown: interface eth0 not configured ubuntu@pinex:~$ sudo ifup -v eth0 Reading directory /etc/network/interfaces.d Parsing file /etc/network/interfaces.d/eth0 Configuring interface eth0=eth0 (inet) /bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d run-parts: executing /etc/network/if-pre-up.d/wpasupplicant /sbin/dhclient -1 -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases -I -df /var/lib/dhcp/dhclient6.eth0.leases eth0 Internet Systems Consortium DHCP Client 4.3.3 Copyright 2004-2015 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/eth0/36:c9:e3:f1:b8:05 Sending on LPF/eth0/36:c9:e3:f1:b8:05 Sending on Socket/fallback DHCPREQUEST of 192.168.0.18 on eth0 to 255.255.255.255 port 67 (xid=0x79b015c0) DHCPACK of 192.168.0.18 from 192.168.0.1 RTNETLINK answers: File exists bound to 192.168.0.18 -- renewal in 5280 seconds. /bin/run-parts --exit-on-error --verbose /etc/network/if-up.d run-parts: executing /etc/network/if-up.d/000resolvconf run-parts: executing /etc/network/if-up.d/bind9 run-parts: executing /etc/network/if-up.d/openssh-server run-parts: executing /etc/network/if-up.d/upstart run-parts: executing /etc/network/if-up.d/wpasupplicant Configuring interface eth0=eth0 (inet) /bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d run-parts: executing /etc/network/if-pre-up.d/wpasupplicant /bin/ip addr add 192.168.0.18/255.255.255.0 broadcast 192.168.0.255 dev eth0 label eth0 RTNETLINK answers: File exists Failed to bring up eth0.
... which led me to the answer (see below).