[Nottingham] Two interfaces...a discussion from Wednesday

David Luff daveluff at ntlworld.com
Tue Mar 22 21:45:41 GMT 2005


Robert Postill writes:

> Hi,
> While at the pub on Wednesday I vaguely recall having a chat about
> naming of NICs (I believe it was Dave but my memory's a little hazy).
> The problem was that on boot-up the NICs were being assigned the wrong
> interface (eth0, eth1 etc).  Afterwards the NICs had their setting
> reassigned to the correct setting in what was described as a "kludgey
> script".  

Hi Robert,

Yes, it was me.  My memory on what I'd done with the NICs was a bit hazy I believe, but I've now had a poke around, and here is the kludge in all it's very ugly glory:

The Debian interface configuration is in /etc/network/interfaces, I basically have two versions of this named /etc/network/new_interfaces and /etc/network/old_interfaces.  The contents of these are:

***********************************

dave at DJBC:/etc/network
$ cat new_interfaces
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.

auto lo
iface lo inet loopback

auto eth1
iface eth1 inet static
        address 192.168.0.1
        network 192.168.0.0
        netmask 255.255.255.0
        broadcast 192.168.0.255
#       gateway 192.168.0.1
auto eth0
iface eth0 inet dhcp
        hostname DJBC

***********************************

dave at DJBC:/etc/network
$ cat old_interfaces
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.

auto lo
iface lo inet loopback

#auto eth1
#iface eth1 inet static
#       address 192.168.0.1
#       network 192.168.0.0
#       netmask 255.255.255.0
#       broadcast 192.168.0.255
#       gateway 192.168.0.1
auto eth0
iface eth0 inet dhcp
        hostname DJBC

************************************

I.e. eth1 is commented out in old interfaces.  In /etc/rc2.d I have a link to a script that contains the following:

dave at DJBC:/etc/init.d
$ cat interface_hack
cp /etc/network/new_interfaces /etc/network/interfaces
/sbin/ifup eth1
cp /etc/network/old_interfaces /etc/network/interfaces

So, basically, ifup is called at run level 0 with old_interfaces in place, which has all mention of eth1 commented out.  Then during run-level 2, new_interfaces is copied into place, eth1 is brought up, and finally old_interfaces is put back into place ready for the next boot.  Without this kludge, the ifup during run-level 0 called from /etc/init.d/networking would always try to bring up the wrong interface whatever I tried, IIRC.

> Well this week I was low on enthusiasm and high on caffine, so
> I decided to do a little nosing around...
> 
> < big snip >
> 
> Right, now I can sleep, if only I can find the horse tranquilisers...
> 

Eek, thanks for posting all that!  I guess I'll have to do some reading now.  I'll see if I can get it fixed before the lan party.

Cheers - Dave



More information about the Nottingham mailing list