Skip to content

Instantly share code, notes, and snippets.

@metalefty
Last active July 1, 2021 05:10
Show Gist options
  • Save metalefty/80d793d4c58a0a81f7a8df97c5127ff5 to your computer and use it in GitHub Desktop.
Save metalefty/80d793d4c58a0a81f7a8df97c5127ff5 to your computer and use it in GitHub Desktop.
notify 100 {
match "system" "IFNET";
match "subsystem" "ue[0-9]+";
match "type" "ATTACH";
action "sh /etc/rename-netif.sh $subsystem";
};
00:11:22:33:44:55 eth0
66:77:88:99:aa:bb eth1
#!/bin/sh
netifmap=/etc/netifmap
dev=$1
if [ -z $dev ]; then
exit 1
fi
mac=$(ifconfig $dev | grep '^\s\+ether' | awk '{print $2}')
name=$(grep ^$mac $netifmap | awk '{print $2}')
if [ -n $name ]; then
ifconfig $dev name $name
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment