配置网络
现在配置一个网桥,以便虚拟机可以访问网络。首先安装所需的工具:
[root@srv-easwy ~]# yum install bridge-utils
新创建一个文件/etc/sysconfig/network-scripts/ifcfg-br0,其内容为:
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
上面的文件配置此网桥以DHCP方式获取IP地址。接下来修改原来的网卡配置/etc/sysconfig/network-scripts/ifcfg-eth0,修改为:
DEVICE=eth0
HWADDR=B8:AC:6F:89:10:76
ONBOOT=yes
BRIDGE=br0
然后重启网络配置,查看一下:
[root@srv-easwy ~]# /etc/init.d/network restart
[root@srv-easwy ~]# ifconfig
br0 Link encap:Ethernet HWaddr B8:AC:6F:89:10:76
inet addr:172.23.5.50 Bcast:172.23.5.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3242738 errors:0 dropped:0 overruns:0 frame:0
TX packets:702638 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1057883287 (1008.8 MiB) TX bytes:448735998 (427.9 MiB)
eth0 Link encap:Ethernet HWaddr B8:AC:6F:89:10:76
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3445641 errors:0 dropped:0 overruns:0 frame:93
TX packets:670754 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1201230368 (1.1 GiB) TX bytes:239453000 (228.3 MiB)
Interrupt:177 Memory:f3de0000-f3df0000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:63582 errors:0 dropped:0 overruns:0 frame:0
TX packets:63582 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:154537675 (147.3 MiB) TX bytes:154537675 (147.3 MiB)
virbr0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:1797 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:470443 (459.4 KiB)