固定无线网卡interface名称为wlan0

来源:互联网 发布:nginx自动跳转首页 编辑:程序博客网 时间:2024/05/22 21:36

需求:即使插入不同型号的无线网卡,生成的节点名称永远是wlan0,限制系统只能使用一个无线网卡,并且节点名称不变
1)rm /etc/udev/rules.d/70-persistent-net.rules

2)vi /lib/udev/write_net_rules,修改成如下

write_rule() {    local match="$1"    local name="$2"    local comment="$3"     if [ ${name:0:4} = "wlan" ]; then        name=wlan0    fi    {    if [ "$PRINT_HEADER" ]; then        PRINT_HEADER=        echo "# This file was automatically generated by the $0"        echo "# program, run by the persistent-net-generator.rules rules file."        echo "#"        echo "# You can modify it, as long as you keep each rule on a single"        echo "# line, and change only the value of the NAME= key."    fi    echo ""    [ "$comment" ] && echo "# $comment"    echo "SUBSYSTEM==\"net\", ACTION==\"add\"$match, NAME=\"$name\""    } >> $RULES_FILE}
0 0