配置网卡
cd /etc/sysconfig/network-scripts/
cp ifcfg-eth0 ifcfg-br0
分别编辑eth0和br0
ifcfg-eth0改成如下:
DEVICE=eth0
HWADDR=00:0C:29:55:A7:0A
TYPE=Ethernet
UUID=2be47d79-2a68-4b65-a9ce-6a2df93759c6
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
BRIDGE=br0
ifcfg-br0改成如下:
DEVICE=br0
#HWADDR=00:0C:29:55:A7:0A
TYPE=Bridge
#UUID=2be47d79-2a68-4b65-a9ce-6a2df93759c6
BOOTPROTO=static
IPADDR=192.168.11.17
NETMASK=255.255.255.0
GATEWAY=192.168.11.1
DNS1=202.106.0.20
说明: 我的虚拟机是桥接模式,所以设置br0的ip和我的真机同样的网段,包括网关也是我路由器的ip,大家可以根据自己的环境去配置,目的是为了让虚拟机可以上网。
/etc/init.d/network restart
查看网卡如下:
br0 Link encap:Ethernet HWaddr 00:0C:29:55:A7:0A
inet addr:192.168.11.17 Bcast:192.168.11.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe55:a70a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:141326 errors:0 dropped:0 overruns:0 frame:0
TX packets:90931 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:456024940 (434.8 MiB) TX bytes:10933593 (10.4 MiB)
eth0 Link encap:Ethernet HWaddr 00:0C:29:55:A7:0A
RX packets:341978 errors:0 dropped:0 overruns:0 frame:0
TX packets:90946 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:468848861 (447.1 MiB) TX bytes:10934699 (10.4 MiB)
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:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
virbr0 Link encap:Ethernet HWaddr 52:54:00:14:EF:D5
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0