Alpine Linux Custom Interface names

This article is a copy of this article and shows how to rename/change name of a network interface.

Alpine Linux uses busybox mdev to manage devices in /dev. mdev reads /etc/mdev.conf and according to mdev documentation one can define a command to be executed per device definition. The command which is going to be used to change network interface name is nameif.

/etc/mdev.conf configuration

-SUBSYSTEM=net;DEVPATH=.*/net/.*;.*     root:root 600 @/sbin/nameif -s

Here we tell mdev to call nameif for devices found in /sys/class/net/.

# ls -d -C -1 /sys/class/net/eth*

nameif configuration

nameif itself reads /etc/mactab' by default. Example line for a network interface with following hwaddr

# cat /sys/class/net/eth0/address

would be

# grep 90:e2:ba:04:28:c0 /etc/mactab 
dmz0 90:e2:ba:04:28:c0


To use renamed network interface without reboot, just call nameif while the network interface is down.

# nameif -s

And finally reboot...