1

I try to achieve a network configuration on my device, that it will always get an ip-address from dhcp if available on plug in of rj45. Most of the time the device will boot up without connection. In /etc/network/interfaces i put following:

allow-hotplug eth0
iface eth0 inet dhcp

I want to add a rule or behaviour, that when i connect this device to a network with no dhcp

(device <---> [USB LAN] pc)

that my device get a static ip address.

I tried to add Multiple IP addresses on one Interface to the interfaces right under the allow-hotplug entry:

auto eth0:1
iface eth0:1 inet static
address 10.0.0.2
netmask 255.255.255.0

All i get is 10.0.0.2 as ip on my device. I've heard about lease in /etc/dhcp/dhcpd.conf but i never used it before.

Could you please help me to get my head around this network configuration.

1 Answers1

0

There's no need to jump through hoops to accomplish this. All you really need is zeroconf Available in the Universe repository for all currently supported versions of Ubuntu.

zeroconf provides APIPA:

Short for Automatic Private IP Addressing, a feature of later Windows operating systems. With APIPA, DHCP clients can automatically self-configure an IP address and subnet mask when a DHCP server isn't available. When a DHCP client boots up, it first looks for a DHCP server in order to obtain an IP address and subnet mask. If the client is unable to find the information, it uses APIPA to automatically configure itself with an IP address from a range that has been reserved especially for Microsoft. The IP address range is 169.254.0.1 through 169.254.255.254. The client also configures itself with a default class B subnet mask of 255.255.0.0. A client uses the self-configured IP address until a DHCP server becomes available.

APIPA is meant for nonrouted small business environments, usually less than 25 clients.

Source: Memory and https://lists.debian.org/debian-russian/2005/11/msg00064.html

For further details regarding zeroconf see http://www.zeroconf.org/

(RFC 3927) specifies how IP hosts can assign addresses in the absence of outside configuration information. That means assigning addresses without depending on information entered by a human user, and without depending on information obtained over the network from a special server, such as a DHCP server.

You may also find this useful.

Elder Geek
  • 36,023
  • 25
  • 98
  • 183