[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: unable to get /etc/resolv.conf and /etc/network/interfaces configured properly in wheezy



Mark Copper wrote:
> With resolvconf package installed and configured for dynamic
> generation of /etc/resolv.conf, I was *unable* to get any non-local
> nameservers written into /etc/resolv.conf.

Works for me.  What version of Debian are you using?  Stable Wheezy 7?
Other?  There have been recent changes and the problem may be version
specific.

> I tried a dns-nameservers line in the /etc/network/interfaces stanza
> for the network interface card,

Good.

> and I tried nameserver lines in the "base" resolvconf config file.

Not the expected way to go.

> Neither worked after a networking reload/restart.

Just to clarify.  You are on the system console.  You are not working
over the network to the machine, right?  You can restart networking as
you need?

> Documentation shown when going through dpkg-reconfigure for resolvconf
> says that a reboot is necessary to make sure all components work
> together as they should.

The documentation does say that.  Mostly because there are so many
different possibilities that it is impractical to document it.  And if
it were documented most humans would be too impatient to read it.
Saying to reboot the system is just easier and definitely covers the
task.

> In my case networking did not come back at all and I can no longer ssh in.

Ouch.  No networking.  But I assume you are on the console and can
restart networking?  Hopefully.

> I suppose the culprit is the change made to the interfaces file.
> 
> Previously, my file followed this format for multiple IP addresses on
> a single nic like this (cf
> https://wiki.debian.org/NetworkConfiguration):
> 
> auto eth0 eth0:1
> 
> iface eth0 inet static
>     address 192.168.1.42
>     netmask 255.255.255.0
>     gateway 192.168.1.1
>     dns-nameservers 8.8.8.8
> 
> auto eth0:1
>     allow-hotplug eth0:0
>     iface eth0:1 inet static
>     address 192.168.1.43
>     netmask 255.255.255.0

The indention in the above is confusing.  The indention does not
matter to the programs.  But it is bad indention for humans reading
it.  Always put the "auto", "allow-hotplug", "iface" lines at the same
left indention.  Then for humans it is nice to indent additional lines
associated with the "iface" line.  And you have "auto eth0:1" set
twice.  And you have eth0:1 set to allow-hotplug but you don't have
eth0 set to allow-hotplug.

Please see this excellent reference:

  http://www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_basic_syntax_of_etc_network_interfaces

> but both /etc/init.d/networking reload and restart had separate
> problems besides not solving my resolv.conf problem.

Problems such as?

> So I tried the newer format at the bottom of the same
> wiki.debian.org page like this:

That wiki section was updated just the other day to reflect
improvements in the ifupdown handling of multiple IP addresses.  The
new version will require some newish level of ifupdown that I don't
recall off the top of my head.  But the update came from the ifupdown
maintainer himself and so the information there should be authoritative.

> auto eth0
> allow-hotplug eth0
> iface eth0 inet static
>     address 192.168.1.42
>     netmask 255.255.255.0
>     gateway 192.168.1.1
>     dns-nameservers 8.8.8.8

All okay.  Should start upon hotplugging.  Should start at boot.

> iface eth0 inet static
>     address 192.168.1.43
>     netmask 255.255.255.0

This is missing "allow-hotplug eth0:1", "auto eth0:1", or both of those.
You will want to add one or both of those.

> Networking seemed OK reloading and restarting, but, sadly, not so when
> rebooting, apparently.

Can you debug why?  The first stansa should start 192.168.1.42 at boot
time okay.  At least it looks good to me.

> Probably I took a wrong turn somewhere when upgrading from squeeze
> and will have to rebuild the OS, but if anyone has an idea, I'd be
> grateful if they would share it.

I don't see a need to re-install.  This configuration file is very
small and the stock one from Stable Wheezy 7 is stock.  If you wanted
these modifications you would be in exactly the same situation.

Suggestion 1:

Remove resolvconf.  Where resolvconf rocks is on mobile devices with
dynamic IP addresses.  Since you are setting up a static IP address
there isn't much benefit from having resolvconf installed.  It is
simpler without.

Suggestion 2:

I suggest to simplify things in the interfaces file.  Simplify by
removing or commenting out the second IP address.  That leaves things
with a single IP address on the interface.  Then get everything
working as you like that way.  Then add back in the setting up of the
second IP address.  Spliting the problem up into smaller chunks and
debugging each separately is best.

  auto lo
  iface lo inet loopback

  auto eth0
  allow-hotplug eth0
  iface eth0 inet static
      address 192.168.1.42
      netmask 255.255.255.0
      gateway 192.168.1.1
      dns-nameservers 8.8.8.8

Suggestion 3:

Set up a local caching nameserver.  This has many advantages.  Every
libc program that needs to resolve names reads the /etc/resolv.conf
file.  Usually they read it once only and don't check to see if it is
updated.  That is why the reboot is suggested in the documentation.
Because long running daemons and other long running programs won't
usually get any updates to it until they are restarted.  A reboot
guarentees that all get the restart.

But if you have a local caching nameserver then the nameserver line
will be pointing to 127.0.0.1 and never change.  Since it never
changes long running programs never need to re-read that file.  Then
for reconfiguration it is configuration of the local caching
nameserver.  If you need to restart the nameserver after a
reconfiguration then restart it and every other program immediately
has the new configuration too because they are using the local
nameserver.  Make sense?

I prefer bind9 but there are a variety and other people prefer other
programs.

  apt-get install bind9

For bind9 that is it.  But for resolvconf we need one edit.  See the
resolvconf /usr/share/doc/resolvconf/README.gz file for details.

Change the /etc/bind/named.conf file from this:
  include "/etc/bind/named.conf.options";
To this:
  include "/var/run/bind/named.options";

Then if you want to add forwarders edit the
/etc/bind/named.conf.options file and edit the forwarders template
provided there and set up whatever forwarders you want.  Then restart
bind.  Restarting bind is a lot less intrusive then rebooting!

Suggestion 4:

Pretty much do all of the above.  Don't worry about resolvconf if you
are setting up a static system.  Simplify by setting up one IP address
first and then worry about adding a second IP address after you have
everything else the way you like it.  Install a local caching
nameserver and set up all of your forwarders using it.

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: