UDEV 设置网卡

udevadm info -a -p $(udevadm info -q path -n /dev/sdb) 

网卡名字eth0,eth1修改
modprobe 中修改模块别名
使用 udev 的情况 

终于遇到udev了 .......

虚拟机中用原有的.VDI建了一个新的系统。可是只有eth2,思来想去,换来换去都无法改成eth0.自己新建了一个 10-local-rules 都不行

原来系统已经建好了一个文件:

后来发现在 /etc/udev/rules.d/70-persistent-net.rules 下有这些内容 :
# 3Com Corporation 3c905B 100BaseTX [Cyclone] (rule written by anaconda)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:01:02:8c:50:09", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# Intel Corporation 82567LM-3 Gigabit Network Connection (rule written by anaconda)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="88:88:88:88:87:88", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

使用 ip link
ip link set eth0 name eth2
ip link set eth1 name eth0
ip link set eth2 name eth1
禁止某个 IP 访问

如果不需要用复杂的 iptables,可以简单地在 route 里加上一条:
route add -host IP-A gw 127.0.0.1

 http://james23dier.iteye.com/blog/803198

原文地址:https://www.cnblogs.com/51linux/p/2185004.html