Linux添加网卡

关闭虚拟机或者物理机,添加网卡。然后开机,查看网卡是否发现

root@radius ~]# more /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}=="d2:31:1f:6d:30:bc", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x10ec:0x8139 (8139cp)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="de:a0:69:bf:67:81", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

看到新添加的两块网卡分别是:eth1 和 eth2,并记录网卡的MAC地址复制eth0的配置文件配置新增加的网卡信息

[root@radius network-scripts]# cd /etc/sysconfig/network-scripts/
[root@radius network-scripts]# ls -l 
total 204
-rw-r--r--  1 root root   179 Mar  5 15:11 ifcfg-eth0
-rw-r--r--. 1 root root   254 Oct  7  2011 ifcfg-lo
lrwxrwxrwx. 1 root root    20 Feb 26 06:22 ifdown -> ../../../sbin/ifdown
-rwxr-xr-x. 1 root root   627 Oct  7  2011 ifdown-bnep
-rwxr-xr-x. 1 root root  5569 Oct  7  2011 ifdown-eth
-rwxr-xr-x. 1 root root   781 Oct  7  2011 ifdown-ippp
-rwxr-xr-x. 1 root root  4168 Oct  7  2011 ifdown-ipv6
lrwxrwxrwx. 1 root root    11 Feb 26 06:22 ifdown-isdn -> ifdown-ippp
-rwxr-xr-x. 1 root root  1481 Oct  7  2011 ifdown-post
-rwxr-xr-x. 1 root root  1064 Oct  7  2011 ifdown-ppp
-rwxr-xr-x. 1 root root   651 Oct  7  2011 ifdown-routes
-rwxr-xr-x. 1 root root  1370 Oct  7  2011 ifdown-sit
-rwxr-xr-x. 1 root root  1434 Oct  7  2011 ifdown-tunnel
lrwxrwxrwx. 1 root root    18 Feb 26 06:22 ifup -> ../../../sbin/ifup
-rwxr-xr-x. 1 root root 13445 Oct  7  2011 ifup-aliases
-rwxr-xr-x. 1 root root   859 Oct  7  2011 ifup-bnep
-rwxr-xr-x. 1 root root 10456 Oct  7  2011 ifup-eth
-rwxr-xr-x. 1 root root 11971 Oct  7  2011 ifup-ippp
-rwxr-xr-x. 1 root root 10683 Oct  7  2011 ifup-ipv6
lrwxrwxrwx. 1 root root     9 Feb 26 06:22 ifup-isdn -> ifup-ippp
-rwxr-xr-x. 1 root root   727 Oct  7  2011 ifup-plip
-rwxr-xr-x. 1 root root   954 Oct  7  2011 ifup-plusb
-rwxr-xr-x. 1 root root  2364 Oct  7  2011 ifup-post
-rwxr-xr-x. 1 root root  4154 Oct  7  2011 ifup-ppp
-rwxr-xr-x. 1 root root  1712 Oct  7  2011 ifup-routes
-rwxr-xr-x. 1 root root  3499 Oct  7  2011 ifup-sit
-rwxr-xr-x. 1 root root  2488 Oct  7  2011 ifup-tunnel
-rwxr-xr-x. 1 root root  3770 Oct  7  2011 ifup-wireless
-rwxr-xr-x. 1 root root  4623 Oct  7  2011 init.ipv6-global
-rwxr-xr-x. 1 root root  1125 Oct  7  2011 net.hotplug
-rw-r--r--. 1 root root 11736 Oct  7  2011 network-functions
-rw-r--r--. 1 root root 29853 Oct  7  2011 network-functions-ipv6

拷贝ifcfg-eth0为ifcfg-eth1并编辑

[root@radius network-scripts]# cp ifcfg-eth0 ifcfg-eth1
[root@radius network-scripts]# vi ifcfg-eth1

DEVICE="eth1"
BOOTPROTO="static"
IPADDR="192.168.1.31"
HWADDR="de:a0:69:bf:67:81"
IPV6INIT="no"
NETMASK="255.255.255.0"
NM_CONTROLLED="yes"
ONBOOT="yes"

保存,重启网卡即可

root@radius ~]# service network restart
Shutting down interface eth0:  [  OK  ]
Shutting down interface eth1:  [  OK  ]
Shutting down loopback interface:  [  OK  ]
Bringing up loopback interface:  [  OK  ]
Bringing up interface eth0:  [  OK  ]
Bringing up interface eth1:  [  OK  ]








你可能感兴趣的:(Linux添加网卡)