`

oracle linux server 6.0修改网卡名称

 
阅读更多

修改网卡规则:先关闭网络服务,修改配置文件网卡的HWADDR值和/etc/udev/rules.d/70-persistent-net.rules文件中网卡的ATTR值一致,然后再修改/etc/udev/rules.d/70-persistent-net.rules中对应的网卡名称,最后再关闭和重启udev-post服务,再启动网卡,名称就会变成你修改的名称

[root@rac02 network-scripts]# ifconfig
eth4      Link encap:Ethernet  HWaddr 08:00:27:AF:C3:39 
          inet addr:192.168.1.109  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:feaf:c339/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4685 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3676 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:862105 (841.8 KiB)  TX bytes:526539 (514.1 KiB)

eth5      Link encap:Ethernet  HWaddr 08:00:27:16:DE:44 
          inet addr:10.10.10.2  Bcast:10.255.255.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe16:de44/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11 errors:0 dropped:0 overruns:0 frame:0
          TX packets:43 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:902 (902.0 b)  TX bytes:4874 (4.7 KiB)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:138 errors:0 dropped:0 overruns:0 frame:0
          TX packets:138 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:23382 (22.8 KiB)  TX bytes:23382 (22.8 KiB)
[root@rac02 network-scripts]# service network stop
Shutting down loopback interface:  [  OK  ]
[root@rac02 network-scripts]# more ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=none
IPADDR=192.168.1.109
PREFIX=24
GATEWAY=192.168.1.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=591e15c2-facf-4d92-bcc8-e27cb5137e0b
ONBOOT=yes
HWADDR=08:00:27:AF:C3:39
[root@rac02 network-scripts]# more ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=none
IPADDR=10.10.10.2
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth1"
UUID=79604f5c-c552-4289-9565-56669263a6de
ONBOOT=yes
HWADDR=08:00:27:16:DE:44
GATEWAY=192.168.1.1

[root@rac02 network-scripts]# vi /etc/udev/rules.d/70-persistent-net.rules

# PCI device 0x8086:0x100e (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:3e:83:3c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100e (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:c8:77:9d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:1b:21:05", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:5d:10:5b", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:af:c3:39", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:16:de:44", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
~


"/etc/udev/rules.d/70-persistent-net.rules" 11L, 585C written
[root@rac02 network-scripts]# source /etc/udev/rules.d/70-persistent-net.rules
-bash: ATTR{address}==08:00:27:af:c3:39,: command not found
-bash: ATTR{address}==08:00:27:16:de:44,: command not found
[root@rac02 network-scripts]# cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:af:c3:39", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:16:de:44", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

修改完毕以后
然后关闭udev服务,从新启动udev服务

service udev-post stop
service udev-post start

然后再从新启动网卡

ifup eth0
ifup eth1

[root@rac02 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:AF:C3:39 
          inet addr:192.168.1.109  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4926 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3864 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:885817 (865.0 KiB)  TX bytes:551779 (538.8 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:16:DE:44 
          inet addr:10.10.10.2  Bcast:10.255.255.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11 errors:0 dropped:0 overruns:0 frame:0
          TX packets:62 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:902 (902.0 b)  TX bytes:7629 (7.4 KiB)

[root@rac02 ~]#

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics