Now that we understand how ifupdown configures interfaces, we can question whether or not it can solve our problems. For one, can we devise an interface configuration that works in the face of changing kernel interface names?. Recall that Linux assigns ethernet interfaces names using an integer sequence in the order if finds them. So, if eth0 is our docking station interface and eth1 is our PCMCIA ethernet card when both are installed, then for that kernel and module sequence, eth0 will be the PCMCIA card and eth1 will be undefined when the unit is out of the docking station. So a simple mapping won't work.
Fortunately, ifupdown comes with an example configuration and mapping script that addresses that problem. The part of the sample configuration that addresses this is:
auto eth0 eth1 mapping eth0 eth1 script /path/to/get-mac-addr.sh map 11:22:33:44:55:66 lan map AA:BB:CC:DD:EE:FF internetThe script, get-mac-addr.sh, is provided in the examples (as get-mac-address.sh) as well. It will take the list of MAC address/logical namepairs and select one of them based on the kernel name passed in $1. For our laptop, this mapping becomes:
mapping eth0 eth1 script /usr/local/sbin/get-mac-address.sh map 00:20:E0:64:0B:28 dock map 00:50:DA:EB:41:73 cardThis configuration has the added benefit of stability in the face of kernel and module-loading changes. This mapping will work no matter how the kernel names the physical interfaces.
Once selected, the logical names must correspond to actual configuration stanzas:
# configure PCMCIA via dhcp iface card inet dhcp # dock has a static address iface dock inet static address 10.177.100.97 netmask 255.255.255.0 gateway 10.177.100.1
This configuration successfully configures the interfaces regardless of the docked-undocked state of the laptop. Unfortunately, it doesn't completely address the problem. We still need a way to keep ifupdown from configuring the PCMCIA ethercard when docked.