首先通过ifconfig -a查看所有网络设备的MAC地址。
Redhat系统的网络配置文件是/etc/sysconfig/network-scripts/ifcfg-eth*(*为数字)
DEVICE=eth0
ONBOOT=yes BOOTPROTO=static IPADDR=192.168.1.123 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 HWADDR=00:0C:29:85:9E:39 在此修改最后一行的MAC地址即可修改该eth*对应物理网卡,MAC地址可用ifconfig查看。(注,/etc/udev/rules.d/70_persistent-net.rules)
Debian和Ubuntu系统的网络设置文件都是/etc/network/interfaces
auto lo iface lo inet loopback #allow-hotplug eth0 auto eth0 iface eth0 inet static address 192.168.1.123 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 219.146.0.130 再修改/etc/udev/rules.d/z25_persistent-net.rules SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:0c:29:15:3a:48", NAME="eth0" # PCI device 0×1022:0×2000 (pcnet32) SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:0c:29:15:3a:52", NAME="eth1" 把上述不用的MAC地址那行注释掉,然后把需要保留的MAC地址那行修改NAME="eth*",这样保存重新启动后就OK了。SUSE系统的网络配置文件是/etc/sysconfig/network/ifcfg-eth-id-*(*为MAC地址)
BOOTPROTO='static' BROADCAST='' ETHTOOL_OPTIONS='' IPADDR='192.168.1.123' NETMASK='255.255.255.0' NETWORK='' REMOTE_IPADDR='' STARTMODE='auto'SUSE系统的网关配置文件是/etc/sysconfig/network/routes default 192.168.1.1 - - 再修改/etc/udev/rules.d/30-net_persistent_names.rules(OPENSUSE系统为70-persistent-net.rules文件) 参考Debian和Ubuntu系统的修改方法。
==========
DEVICE=eth0
NM_CONTROLLED=yes ONBOOT=yes TYPE=Ethernet BOOTPROTO=none IPADDR=172.16.82.1 PREFIX=21 GATEWAY=172.16.80.1 DNS1=8.8.8.8 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="system eth0" UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 USERCTL=no DOMAIN=172.16.80.1 HWADDR=52:54:00:13:31:5C