Setting Network Interface Name on Raspbian
由于想把Raspberry Pi改造成无线中继,所以插了两个USB网卡上去。后来发现系统启动后,无线网卡的名称每次都不一定相同,以致启动桥接服务的shell脚本出错。但笔记本上的Lubuntu 12.10却是无线网卡每次的名称都不变。同样是基于Debian,Raspbian也应该可以实现无线网卡名称固定(其实就是跟MAC绑定网络接口名称)。翻查了资料,还是Debian的Wiki比较靠谱。见:http://wiki.debian.org/udev
最后还是比较懒,从Lubuntu 12.10上复制文件 /etc/udev/rules.d/70-persistent-net.rules 到Raspbian上,再改改来用就可以了。该文件修改如下:
## begin the file /etc/udev/rules.d/70-persistent-net.rules #################
# USB Ethernet (usb)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="aa:bb:cc:dd:ee:ff", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# USB device 0x0cf3:0x1006 (Mercury MW54U)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="aa:bb:cc:dd:ee:ff", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"
# USB device 0x0bda:0x8171 (Netcore NW338)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="aa:bb:cc:dd:ee:ff", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan1"
## end the file /etc/udev/rules.d/70-persistent-net.rules #################
其中aa:bb:cc:dd:ee:ff要替换成网卡对应的MAC码。