Network KVM virtual machine's configuration

Network kvm virtual machine's configuration has two modes: Bridge mode and NAT mode.

The difference between the two modes as follows:
. 1) NAT modes: user mode also, by the NAT data packets by way of the host interface transfer can access the public network, but can not access the virtual machine from the outside network, it is generally not used.
2) Bridge: Bridge is the mode that allows the virtual machine as a separate host has the same network, external machines can directly access the virtual machine, but need card support, general wired LAN support.

A, NAT mode configuration

nat mode configuration is relatively simple, just after starting the virtual machine, change the virtual machine's network adapter configuration file, "ONBOOT" configuration item default "no" was changed to "yes" can be realized ping the external network, not here write more, (which is achieved by means of firewall rules and rule iPtables KVM server, shut down the firewall does not affect the server's KVM virtual machine ping outside the network, but its default configuration iptables must exist, otherwise, the virtual machine can not ping Extranet).

Two, bridge mode configuration

Bridge either of two modes, the first more complicated, is not recommended, before my blog: Centos7 deploy KVM virtualization platform Detailed have written, reference may be made here to write the second method is relatively simple one way.

[root@kvm ~]#  systemctl stop NetworkManager    #停止此服务
[root@kvm ~]# virsh iface-bridge ens33 br0    #执行此命令时,若提示以下信息,不用在意,因为其已经存在了
使用附加设备 br0 生成桥接 ens33 失败
已启动桥接接口 br0
[root@kvm ~]# ls /etc/sysconfig/network-scripts/ | grep br0   
ifcfg-br0        #确定有此文件就行
[root@kvm ~]# virsh destroy test01     #关闭虚拟机
域 test01 被删除
[root@kvm ~]# virsh edit test01      #编辑虚拟机的配置文件,定位到interface
<interface type='bridge'>      #将此处改为bridge
 <mac address='52:54:00:a9:cc:5f'/>      #删除Mac地址这行
      <source bridge='br0'/>          #将此处更改为这样
#保存退出即可

At this point it is configured, running virtual machine, change LAN configuration file it, pay attention : the virtual machine configuration and kvm gateway host is the same, they are now in the same network segment, the virtual machine's network adapter configuration file as follows:

Network KVM virtual machine's configuration

Save and exit and restart network services, virtual machines can communicate with each other and the external network! ! ! Self-test it!

-------- end of this article so far, thanks for reading --------

Guess you like

Origin blog.51cto.com/14154700/2441473