[clug] /etc/network/interfaces

Andrew Janke a.janke at gmail.com
Tue Nov 27 04:06:16 GMT 2007


On Nov 27, 2007 2:57 PM, Mike Carden <mike.carden at gmail.com> wrote:
> On Nov 27, 2007 12:43 PM, Andrew Janke <a.janke at gmail.com> wrote:
> > Just wondering if anyone knows of a little app/script/tool that will rewrite
> > /etc/network/interfaces to a static version based upon what a DHCP
> > server gives it?
>
> I probably have entirely the wrong end of the stick here, but isn't
> this more usually done by setting a static IP for that mac address
> back at the DHCP server?

Hey at least you have a stick. :)

And you are right, I am handing out static IP's via MAC addresses in
/etc/dhcp3/dhcpd.conf with fixed-address statements.  ie:

      # worker bees
      host bill     { hardware ethernet XXXXXX; fixed-address 10.10.100.30;  }
      host ben      { hardware ethernet XXXXXXX; fixed-address 10.10.100.31;  }
      host donald   { hardware ethernet XXXXXXXX; fixed-address
10.10.100.32;  }
      host douglas  { hardware ethernet XXXXXXXXX; fixed-address
10.10.100.33;  }

I could of course just increase the default-lease-time statement (and
max-lease-time) but what I want is that when I install a machine for
the first time (either via FAI or manually with a CD) I can then "fix
it up" to how I want via cfengine2. As part of this I want to remove
any dependence whatsoever on external machines/services that I can.
DHCP being one of them.  It is fine that a machine gets its initial IP
address during the FAI install from DHCP but I want it to be static
after then. I do this currently with a little script in the FAI conf,
but of course this doesnt work if I use my cfengine stuff to "take
over" another machine on the network.

Hrm..  I suspect I will have to write something.  I essentially want
to turn this:

# /etc/network/interfaces
#
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

----

into this:

# /etc/network/interfaces
#
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
   address 10.10.100.1
   netmask 255.255.255.0
   gateway 10.10.100.5


and of course make the required changes in /etc/resolv/conf.

Problem being that I can handle this in the simple case but would
prefer to use something else that already exists if possible as I dont
want to have to handle all the permutations of the interfaces file! :)

ta


-- 
Andrew Janke   (a.janke at gmail.com || http://a.janke.googlepages.com/)
Canberra->Australia    +61 (402) 700 883


More information about the linux mailing list