2018-03-12 Linux 宅必备
## 1. 修改网卡名称
### 1.1 查看需要修改的网卡mac地址
```
[root@WProAP-TESTLICENSE ~]# ifconfig -a | grep -i --color hwaddr
eth0 Link encap:Ethernet HWaddr 00:18:FE:26:CB:A2
```
### 1.2 修改网卡名称
新建udev绑定文件,如已存在该文件则在上面修改
[image:59 size:orig]
注意先备份文件
```
# vi /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x14e4:0x1680 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="b8:ac:6f:65:31:e5", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
```
### 1.3 重启系统
```
reboot
```
## 2. 修改mac地址
注意:该变更在重启后失效,如需固定需要在/etc/rc.d/rc.local文件中放入该命令
```
ifconfig ethX down
ifconfig ethX hw ether aa:bb:cc:dd:ee:ff
ifconfig ethX up
```
或者
```
ip set link dev ethX brd aa:bb:cc:dd:ee:ff
```
##参考文档:
[https://www.cyberciti.biz/faq/howto-linux-rename-ethernet-devices-named-using-udev/](https://www.cyberciti.biz/faq/howto-linux-rename-ethernet-devices-named-using-udev/)