Slackware Linux uses udev to decide how to manage the recognized devices in your /dev/ directory. Also any hotplug devices are also handled by udev for loading the appropriate kernel modules and create(or enable) a /dev node for mounting purposes. Udev is doing quite well, except in 2 cases:
- You need eth1 to actually be eth0 and eth2 to become eth1.
This is one of the cases, in which you have e.g. 1GBps NIC and want it to be exactly eth0 and 2 more that you need for your home network set. You already have the scripts to create NAT and they point to eth0 by default. It’s faster to switch NIC names than to rewrite the scripts.
- Your motherboard died and you want your hard drive moved to another system so you keep working.
In this case, most if not all the new motherboard components will be recognized by udev but there will be one difference in one specific file at /etc/udev/rules.d/ this file is called 70-persistent-net.rules and is responsible for mapping the network cards by their manufacturing address (MAC address).
The file looks like this:
# PCI device 0x10ec:0x8139 (8139too) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:40:95:30:c5:7e", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # PCI device 0x10ec:0x8139 (8139too) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:06:4f:29:49:f0", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" # PCI device 0x10ec:0x8139 (8139too) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:01:6c:e2:ff:d2", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
And if you want the NICs remaped, the only thing that needs to be done is to set the option NAME in the end of each line to whatever you want your NICs to be set. This is about the first scenario.
The second scenario, when you place the hard drive to a new system with similar configuration, you will see the udev will actually displace the NICs. If your old system had eth0, eth1 and eth2 – now your system will have eth3, eth4 and eth5. Old/original NICs places will be kept (as if your broken machine will revive 😉 hahaha 😀 )
You need to set them back to point to eth0, eth1 and eth2 and no system reconfiguration will be needed (except in the case where your Video card is different, than you need to reconfigure X.org).
That’s basicly it. Modify /etc/udev/rules.d/70-persistent-net.rules and restart the udev process.
bash-4.1# /etc/rc.d/rc.udev restart
The next step is to make your configuration go back to what it was. It’s actually one command only if you have not changed anything else:
bash-4.1# /etc/rc.d/rc.inet1 restart
That way, your network should be back to what it was.
One Response to “How to remap your network cards in Slackware.”
Sorry, the comment form is closed at this time.
Thanks, migrated hdd to a new motherboard and everything was great except networking. Appreciate the info.