The situation is that I have an Ubuntu box with multiple ethernet ports, which I'd like to behave as if connected to the computer through a switch. I can achieve this easily with a bridge. In /etc/network/interfaces
:
iface br0 inet static
bridge_ports regex eth.*
address 192.168.1.1
netmask 255.255.255.0
Under this config, another device can plug into any of the ports and ping this box at 192.168.1.1.
Now, the second part is that I'd like one of the ports to have an IP alias, whereby it also tries to get a DHCP address. I can do this on eth0 without the bridge, like so:
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
iface eth0:0 inet dhcp
Now the trick is, how would I combine this with the software switch functionality? Because brctl operates at layer 2, I can't create eth0:0 once eth0 is part of br0. The only thing I can do is create it as br0:0:
iface br0 inet static
bridge_ports regex eth.*
address 192.168.1.1
netmask 255.255.255.0
iface br0:0 inet dhcp
This actually does almost exactly what I'd like, but with one weird problem: When the ethernet ports are disconnected or there's no DHCP server, the bridge doesn't get its proper static IP---or it'll get it, but not until a minute or two after the bootup is otherwise complete.
So my question is, what's up with the delay? Can I get rid of it somehow?
Alternatively, is there a better way I could accomplish what I want here? The ideal thing would be a daemon which would periodically poll for DHCP, and when it gets an IP assigns, puts it on the alias instead of the main interface.
Thanks.