# Put your custom commands here that should be executed once# the system init finished. By default this file does nothing.# exit 0#!/bin/sh /etc/rc.commonSTART=11# don't run within buildroot[-n"${IPKG_INSTROOT}"]&&return0#use busybox grep as GNU grep may be set differently and break the scriptgrep(){/bin/busybox'grep'$@}#shutting down all interfaces, then assigning temporary name to free up interface names#bridges and virtual interfaces are already excluded by /sys/class/net/*/device/uevent as only physical interfaces have thatforiin$(ls/sys/class/net/*/device/uevent|awk-F'/''{print $5}'|tr'\n'' ');domac_address=$(grep$i/etc/config/mac-static-interfaces|awk'{print $3}'|tr-d'"')if["$mac_address"!=''];theniplinkset"$i"down
iplinkset"$i"nameold"$i"fidoneforiin$(ls/sys/class/net/*/device/uevent|awk-F'/''{print $5}'|tr'\n'' ');domac_address=$(cat/sys/class/net/$i/address)interface_name=$(grep-i$mac_address/etc/config/mac-static-interfaces|awk'{print $2}')if["$interface_name"!=''];theniplinkset"$i"down
iplinkset"$i"name"$interface_name"iplinkset"$interface_name"up
/etc/init.d/networkrestart
fidoneexit0
编辑`/etc/rc.local`:
```bash
# 1. Put your custom commands here that should be executed once
# 2. the system init finished. By default this file does nothing.
# 3. exit 0
#!/bin/sh /etc/rc.common
START=11
# 5. don't run within buildroot
[ -n "${IPKG_INSTROOT}" ] && return 0
#use busybox grep as GNU grep may be set differently and break the script
grep(){
/bin/busybox 'grep' $@
}
#shutting down all interfaces, then assigning temporary name to free up interface names
#bridges and virtual interfaces are already excluded by /sys/class/net/*/device/uevent as only physical interfaces have that
for i in $( ls /sys/class/net/*/device/uevent | awk -F'/' '{print $5}' | tr '\n' ' ' ) ;
do
mac_address=$( grep $i /etc/config/mac-static-interfaces | awk '{print $3}' | tr -d '"' )
if [ "$mac_address" != '' ]; then
ip link set "$i" down
ip link set "$i" name old"$i"
fi
done
for i in $( ls /sys/class/net/*/device/uevent | awk -F'/' '{print $5}' | tr '\n' ' ' ) ;
do
mac_address=$( cat /sys/class/net/$i/address )
interface_name=$( grep -i $mac_address /etc/config/mac-static-interfaces | awk '{print $2}' )
if [ "$interface_name" != '' ]; then
ip link set "$i" down
ip link set "$i" name "$interface_name"
ip link set "$interface_name" up
/etc/init.d/network restart
fi
done
exit 0