K.Mandla's blog of Linux experiences

Solving eth0 eth1 eth2 eth3 eth4 …

I occasionally swap network cards in my Thinkpad either as a troubleshooting measure or just to see if one is working better than another. I have a custom kernel in that machine, running under Crux that has support for about four different cards, and depending on which one is inserted, the kernel adjusts automatically.

The problem with that arrangement though, was that each time the card was swapped, a new interface name was given to it. The original Xircom-based card started out as eth0, the Linksys WPC11 was eth1, the ASIX-based wired card was eth2, and so forth.

Which is an okay arrangement, except the network script for Crux required me to change the interface name manually each time I tried a different card. And after reinserting the original card one more time and getting eth5, I decided that was enough of that nonsense.

I managed to track down the culprit — udev — and further track down its persistent rules file, which is at /etc/udev/rules.d/70-persistent-net.rules on that machine. It’s fairly easy to decipher: There is roughly a line apiece for the MAC address and the name assigned to it, and so forth. Why I had two lines for the same card but with different names … is beyond me.

Anyway, it was easy enough to comment out the offending lines in that file, and after rebooting, the sequence started over again at eth0. One last edit of the networking script, and I could at least use the Xircom card without running it as eth5.😐

I think, if I understand it right, that the ifrename utility uses /etc/iftab to assign names; I suppose I might have just pointed everything at “eth0” since there’s no chance of having more than one interface in that machine (technically). I’ll give that a try sometime, and see if it works.