vm centos 添加网卡 无配置文件 解决办法
[root@test ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:C8:41:FB
inet addr:192.168.10.51 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fec8:41fb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4545 errors:0 dropped:0 overruns:0 frame:0
TX packets:322 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:325875 (318.2 KiB) TX bytes:32017 (31.2 KiB)
eth1 Link encap:Ethernet HWaddr 00:0C:29:C8:41:05
inet addr:192.168.10.23 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fec8:4105/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4290 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:300479 (293.4 KiB) TX bytes:690 (690.0 b)
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:65536 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:240 (240.0 b) TX bytes:240 (240.0 b)
[root@test ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1 #生成一个ifcfg-eth1文件,可参考ifcfg-eth0,删除UUID的行
DEVICE=eth1
HWADDR=00:0c:29:c8:41:05
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.10.23
NETMASK=255.255.255.0
DNS2=202.96.134.133
GATEWAY=192.168.10.254
DNS1=10.0.0.3
IPV6INIT=no
USERCTL=no
[root@test ~]# service network restart
如果还是不行,往下看
[root@test ~]# 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:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:c8:41:05", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:c8:41:fb", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
[root@test ~]# rm -f /etc/udev/rules.d/70-persistent-net.rules
[root@test ~]# reboot