使用如下命令 创建 桥接需要 的 桥:
[root@s14 ~]# brctl addbr br0
[root@s14 ~]# brctl addif br0 em2
[root@s14 ~]# ifconfig up br0
[root@s14 ~]# ifconfig br0
up
如果主机环境中没有dhcp使用如下3条命令
[root@s14 ~]# ifconfig em2 0.0.0..0
[root@s14 ~]# ifconfig br0 172.16.90.14 netmask 255.255.255.0
[root@s14 ~]# route add default gw 172.16.72.1
否则直接使用如下命令
[root@s14 ~]# dhclient br0
em2 替换为本机的物理网卡,br0为最后建好的桥
另外需要在虚拟机中关闭libvertd(如果有开启的话):
shell> /etc/init.d/libvirtd stop
shell> chkconfig libvirtd off
配置虚拟机的网络配置文件:
shell> vi /etc/sysconfig/network-scripts/ifcfg-eth0
内容为:
DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="52:54:00:59:C9:47" [替换为原配置文件中的值]
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"
UUID="cd704b25-343a-410c-a0dc-22d7b6f76e00" [替换为原配置文件中的值]
如果想为虚拟机分配固定ip,同样编辑ifcfg-eth0文件为:
DEVICE="eth0"
BOOTPROTO="static"
HWADDR="C8:1F:66:DE:79:22" [替换为原配置文件中的值]
IPV6INIT="no"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="e30d42e8-42ad-4e11-91e3-0f0f9e7c8d33" [替换为原配置文件中的值]
IPADDR=172.16.90.12
NETMASK=255.255.255.0
GATEWAY=172.16.90.1
转载请注明转自高孝鑫的博客
[root@s14 ~]# brctl addbr br0
[root@s14 ~]# brctl addif br0 em2
[root@s14 ~]# ifconfig up br0
[root@s14 ~]# ifconfig
如果主机环境中没有dhcp使用如下3条命令
[root@s14 ~]# ifconfig em2 0.0.0..0
[root@s14 ~]# ifconfig br0 172.16.90.14 netmask 255.255.255.0
[root@s14 ~]# route add default gw 172.16.72.1
否则直接使用如下命令
[root@s14 ~]# dhclient br0
em2 替换为本机的物理网卡,br0为最后建好的桥
另外需要在虚拟机中关闭libvertd(如果有开启的话):
shell> /etc/init.d/libvirtd stop
shell> chkconfig libvirtd off
配置虚拟机的网络配置文件:
shell>
内容为:
DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="52:54:00:59:C9:47"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"
UUID="cd704b25-343a-410c-a0dc-22d7b6f76e00" [替换为原配置文件中的值]
如果想为虚拟机分配固定ip,同样编辑ifcfg-eth0文件为:
DEVICE="eth0"
BOOTPROTO="static"
HWADDR="C8:1F:66:DE:79:22"
IPV6INIT="no"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="e30d42e8-42ad-4e11-91e3-0f0f9e7c8d33" [替换为原配置文件中的值]
IPADDR=172.16.90.12
NETMASK=255.255.255.0
GATEWAY=172.16.90.1
转载请注明转自高孝鑫的博客