Have you tried including the MAC addresses in the different ifcfg-ethX files for the various ethernet devices? Additionally you can control which device get's which ethX handle through udev's 60-net.rules
file.
For example
# /etc/sysconfig/network-scripts/ifcfg-eth0
# Intel Corporation 82573E Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=00:30:48:56:A6:2E
IPADDR=10.10.10.15
NETMASK=255.255.255.192
ONBOOT=yes
Then in the file /etc/udev/rules.d/60-net.rules
:
KERNEL=="eth*", SYSFS{address}=="00:30:48:56:A6:2E", NAME="eth0"
I believe this information is used to keep the devices configured consistently from boot to boot.
Configuring more than one ethX device
To deal with more devices simply setup each devices corresponding /etc/sysconfig/network-scripts/ifcfg-ethX
file, and add another line to the 60-net.rules
file.
KERNEL=="eth*", SYSFS{address}=="00:30:48:56:A6:2E", NAME="eth0"
KERNEL=="eth*", SYSFS{address}=="00:30:48:56:A6:2F", NAME="eth1"
The above is how you do it in CentOS 5.X. The file changes in CentOS 6.x to 70-persistent-net.rules
, and the format is slightly different too:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="54:52:00:ff:ff:dd", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
References
Assuming that you have just installed your debian 9 stretch.
1) For reverting back the old names for the interfaces do:
nano /etc/default/grub
edit the line GRUB_CMDLINE_LINUX=""
to GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
then launch a grub-mkconfig for apply the changes inside the bootloader
grub-mkconfig -o /boot/grub/grub.cfg
You need a reboot after that.
2) For renaming the interfaces use:
Start by creating / editing the /etc/udev/rules.d/70-persistent-net.rules file.
nano /etc/udev/rules.d/70-persistent-net.rules
And insert inside lines like:
# interface with MAC address "00:0c:30:50:48:a1" will be assigned "eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:30:50:48:a1", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# interface with MAC address "00:0c:30:50:48:ab" will be assigned "eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:30:50:48:ab", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
If you want to assign for example a name like wan0 to eth0 you can use given my example:
# interface with MAC address "00:0c:30:50:48:a1" will be assigned "eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:30:50:48:a1", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="wan0"
After the next reboot or using service networking restart you should see the changes applied.
EXTRA: Remember that after all this modifications you have to edit your /etc/network/interfaces file replacing the old interfaces names with the new ones!
EXTRA: If you want to know what MAC address your interfaces have, just do a
ip addr show
and look under the link/ section.
Best Answer
The articles you found are somewhat outdated. There is now an easy method to assign names to network interfaces, through Udev.
On Debian and derivatives (including Ubuntu), look out for a file called
/etc/udev/rules.d/70-persistent-net.rules
. This file is created by/lib/udev/rules.d/75-persistent-net-generator.rules
with the help of the script/lib/udev/write_net_rules
. Each time udev sees a new network device, it will assign it a new number and append that number to/etc/udev/rules.d/70-persistent-net.rules
. That way, interface numbers are persistent across reboots, and will persist after a reinstallation if you restore/etc
.(If your distribution doesn't ship these files, look for them in the Debian package.)
If you want to give a meaningful name to an interface and you have
/etc/udev/rules.d/70-persistent-net.rules
, all you need to do is to edit that file and change"eth0"
to"ethLan"
. Runudevadm trigger --sysname eth0
to rename the existing device after you've edited the file (I think this requires shutting down the interface). If you don't have that file, you can write the one-line matching yourself (the complicated scripts that Debian adds are only to do this automatically):