|
Tag: Redirect target changed |
(3 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
| This article shows how to rename/change name of a network interface.
| | #REDIRECT [[Mdev#Custom_network_interface_name]] |
| | |
| Alpine Linux uses ''busybox'' ''mdev'' to manage devices in ''/dev''. ''mdev'' reads ''/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''.
| |
| | |
| == ''/etc/mdev.conf'' configuration ==
| |
| <pre>
| |
| -SUBSYSTEM=net;DEVPATH=.*/net/.*;.* root:root 600 @/sbin/nameif -s
| |
| </pre>
| |
| | |
| Here we tell ''mdev'' to call ''nameif'' for devices found in ''/sys/class/net/''.
| |
| | |
| <pre>
| |
| # 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
| |
| </pre>
| |
| | |
| == ''nameif'' configuration ==
| |
| | |
| ''nameif'' itself reads ''/etc/mactab'' by default. Example line for a network interface with following hwaddr
| |
| | |
| <pre>
| |
| # cat /sys/class/net/eth0/address
| |
| 90:e2:ba:04:28:c0
| |
| </pre>
| |
| | |
| would be
| |
| | |
| <pre>
| |
| # grep 90:e2:ba:04:28:c0 /etc/mactab | |
| dmz0 90:e2:ba:04:28:c0
| |
| </pre>
| |
| | |
| == ramdisk rebuild ==
| |
| | |
| ''/etc/mdev.conf'' is part of ramdisk
| |
| | |
| <pre>
| |
| # grep /etc/mdev.conf /etc/mkinitfs/features.d/*.files
| |
| /etc/mkinitfs/features.d/base.files:/etc/mdev.conf
| |
| </pre>
| |
| | |
| thus we need to rebuild ramdisk
| |
| | |
| <pre>
| |
| # mkinitfs $(ls /lib/modules/)
| |
| ==> initramfs: creating /boot/initramfs-lts
| |
| </pre>
| |
| | |
| == finalization ==
| |
| | |
| To use renamed network interface without reboot, just call ''nameif'' while the network interface is down.
| |
| | |
| <pre>
| |
| # nameif -s
| |
| </pre>
| |
| | |
| And finally reboot...
| |
| | |
| [[Category:Networking]] | |