This is perhaps an unusual request: I'm trying to get a Debian Linux box to always give itself a self-assigned IP address (i.e. 169.254.x.y) on boot. In particular, I want it to do that even when there is a DHCP server present on the LAN. That is, it should not request an IP address from the DHCP server.
From what I can see in the "man interfaces" text, there is an option for "manual", and an option for "dhcp". Manual assignment won't do, since I need multiple boxes to work on the same LAN without requiring any manual configuration... and "dhcp" does what I want, but only if there is no DHCP server on the LAN. (A requirement is that the functionality of these boxes should not be affected by the presence or absence of a DHCP server).
Is there a trick that I can use to get this behavior?
EDIT: By "no manual configuration", I mean that I should be able to take this box (headless) to any LAN anywhere, plug in the Ethernet cable, and have it do its thing. I shouldn't have to ssh to the box and edit files to get it working each time it is moved to a different LAN.
If you install the
avahi-autoipd
package, and run it with the--force-bind
option in a custom init or if-up.d script, you will always get a link-local address.You can then use
iface eth0 inet manual
in your interfaces(5) file, although you will need to edit/etc/network/if-up.d/avahi-autoipd
to addmanual
to the method lines.There is more information about avahi-autoipd on the Avahi wiki.
Personally, I would edit
/etc/network/if-up.d/avahi-autoipd
to with something like:You can then list interfaces as
iface eth0 inet linklocal
. The edits to be made to theif-down.d
script are left as an exercise to the reader.You may have missed this in
man interfaces
:So, you would have an
interfaces
section as such:Install
avahi-autoipd
, and that should do it.I think what you are looking for is zeroconf.
Nobody's mentioned it yet, so I'll just point out that, if you have control of how the machine boots, you can edit the default entry in GRUB's menu.lst (or whatever it's called this week) to add a "nodhcp" cheatcode to the arguments given the kernel at boot. That should at least keep the machine from sending out an initial IP request, though for how long I couldn't say as I've only really needed it when testing live-CDs (it's all static RFC1918 IP's on my LAN).
Posting for the sake of others Googling for this:
If you are using NetworkManager, As of July 2008 it includes support for avahi-autoipd. Just set BOOTPROTO=autoip in the interface's /etc/sysconfig/network-scripts/ifcfg-* file. NetworkManager will skip DHCP configuration of the interface and go straight to link-local IPv4LL addressing via autoipd.