|
|
Line 1: |
Line 1: |
| {{Merge|mdev|This could be part of a "configuring mdev" section in the mdev article}}
| | #REDIRECT [[mdev]] |
| | |
| This article shows how to rename/change name of a network interface.
| |
| | |
| Alpine Linux uses {{pkg|busybox}} ''mdev'' by default to manage devices in {{path|/dev}}. ''mdev'' reads {{path|/etc/mdev.conf}} and according to [https://git.busybox.net/busybox/plain/docs/mdev.txt 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''.
| |
| | |
| == {{path|/etc/mdev.conf}} configuration ==
| |
| {{cat|/etc/mdev.conf|<nowiki>-SUBSYSTEM=net;DEVPATH=.*/net/.*;.* root:root 600 @/sbin/nameif -s</nowiki>}}
| |
| | |
| Here we tell ''mdev'' to call ''nameif'' for devices found in {{path|/sys/class/net/}}.
| |
| | |
| {{cmd|# ls -d -C -1 /sys/class/net/eth*
| |
| /sys/class/net/eth1
| |
| /sys/class/net/eth2
| |
| /sys/class/net/eth3
| |
| /sys/class/net/eth4
| |
| /sys/class/net/eth5
| |
| }}
| |
| | |
| == ''nameif'' configuration ==
| |
| | |
| ''nameif'' itself reads {{path|/etc/mactab}} by default. Example line for a network interface with following hwaddr
| |
| | |
| {{cmd|# cat /sys/class/net/eth0/address
| |
| 90:e2:ba:04:28:c0
| |
| }}
| |
| | |
| would be
| |
| | |
| {{cmd|# grep 90:e2:ba:04:28:c0 /etc/mactab
| |
| dmz0 90:e2:ba:04:28:c0
| |
| }}
| |
| | |
| == ramdisk rebuild ==
| |
| | |
| {{path|/etc/mdev.conf}} is part of ramdisk
| |
| | |
| {{cmd|# grep /etc/mdev.conf /etc/mkinitfs/features.d/*.files
| |
| /etc/mkinitfs/features.d/base.files:/etc/mdev.conf
| |
| }}
| |
| | |
| thus we need to rebuild ramdisk
| |
| | |
| {{cmd|<nowiki># mkinitfs $(ls /lib/modules/)
| |
| ==> initramfs: creating /boot/initramfs-lts
| |
| </nowiki>}}
| |
| | |
| == finalization ==
| |
| | |
| To use renamed network interface without reboot, just call ''nameif'' while the network interface is down.
| |
| | |
| {{cmd|# nameif -s}}
| |
| | |
| And finally reboot...
| |
| | |
| [[Category:Networking]] | |