参考:
http://libvirt.org/formatnetwork.html#examplesNAT
This example is the so called "default" virtual network. It is provided and enabled out-of-the-box for all libvirt installations. This is a configuration that allows guest OS to get outbound connectivity regardless of whether the host uses ethernet, wireless, dialup, or VPN networking without requiring any specific admin configuration. In the absence of host networking, it at least allows guests to talk directly to each other.
NAT(Network Address Translation)表示共享主机的IP地址,虚拟机的IP被翻译为好像是宿主机的公有IP一样,即使这个宿主机只允许有一个公有IP, 那该宿主机上的多台虚拟机都可以访问物理网络,虚拟机上的请求根据宿主机的路由转发。NAT mode will mask all network activity as if it came from your Host OS, although the VM can access external resources.
<network>
<name>default</name>
<bridge name="virbr0" />
<forward mode="nat"/>
<ip address="192.168.122.1" netmask="255.255.255.0">
<dhcp>
<range start="192.168.122.2" end="192.168.122.254" />
</dhcp>
</ip>
<ip family="ipv6" address="2001:db8:ca2:2::1" prefix="64" />
</network>
This is a variant on the default network which routes traffic from the virtual network to the LAN without applying any NAT. It requires that the IP address range be pre-configured in the routing tables of the router on the host network. This example further specifies that guest traffic may only go out via the eth1
host network device.
效果近似于NAT,但是需要提前在物理网的路由器上配置该IP段的转发。例如下面IP段只能通过eth1转发出去。
<network>
<name>local</name>
<bridge name="virbr1" />
<forward mode="route" dev="eth1"/>
<ip address="192.168.122.1" netmask="255.255.255.0">
<dhcp>
<range start="192.168.122.2" end="192.168.122.254" />
</dhcp>
</ip>
<ip family="ipv6" address="2001:db8:ca2:2::1" prefix="64" />
</network>
This variant provides a completely isolated private network for guests. The guests can talk to each other, and the host OS, but cannot reach any other machines on the LAN, due to the omission of the forward
element in the XML description.
仅主机方式:宿主机上的多台guests相互可以通信,和宿主机也可以通信,但是和LAN上的其他机器不能通信(没有 forward字段)
<network>
<name>private</name>
<bridge name="virbr2" />
<ip address="192.168.152.1" netmask="255.255.255.0">
<dhcp>
<range start="192.168.152.2" end="192.168.152.254" />
</dhcp>
</ip>
<ip family="ipv6" address="2001:db8:ca2:3::1" prefix="64" />
</network>
Since 0.9.4 This shows how to use a pre-existing host bridge "br0". The guests will effectively be directly connected to the physical network (i.e. their IP addresses will all be on the subnet of the physical network, and there will be no restrictions on inbound or outbound connections).
该bridge可以是an existing host bridge 或者 an existing Open vSwitch bridge t
<network>
<name>host-bridge</name>
<forward mode="bridge"/>
<bridge name="br0"/>
</network>
qemu-system-x86_64 -hda /path/to/hda.img -net nic,macaddr=$macaddress -net tap
另外kvm还有一种方式:
qemu-system-x86_64 -hda /path/to/hda.img -net nic -net user
Use case:
- You want a simple way for your virtual machine to access to the host, to the internet or to resources available on your local network.
- You don't need to access your guest from the network or from another guest.
- You are ready to take a huge performance hit.
- Warning: User networking does not support a number of networking features like ICMP. Certain applications (like ping) may not function properly.
分享到:
相关推荐
Libvirt Qemu KVM 教程大全
Openstack Libvirt 介绍 Openstack Libvirt 介绍 Openstack Libvirt 介绍
虚拟化环境qemu 与libvirt的解析
libvirt
libvirt java绑定包 提供java API
libvirt开发基础资料(Foundations of Libvirt Development) 完整版
libvirt-java0.4.7
libvirt application development guide, python,libvirt应用开发指南python版
libvirt源码,用于安装,0.9.11
libvirt C语言应用开发指南。2020年9月版本,与2012年版本相比多了到2020-04-07的4个提交。
libvirt编译安装
libvirt-client-0.10.2-62.el6.x86_64.rpm libvirt-client-0.10.2-62.el6.x86_64.rpm
libvirt自用模板,为了便于理解在//后写了部分注释。可能会出现乱码,保存前删除掉就好。 libvirt配置我也不是很了解,这个只作为基础理解和使用。
Libvirt虚拟化技术介绍.pdf
Libvirt 网络管理 Bridge模式及NAT模式的简单介绍
libvirt-snmp 虚拟化网络管理接口工具,解包后编译,安装方法可以看http://blog.csdn.net/gg296231363/article/details/6927759
libvirt-0.9.7,一个很老的版本,希望有人用到。 Libvirt是用于管理虚拟化平台的开源的API,后台程序和管理工具。它可以用于管理KVM、Xen、VMware ESX,QEMU和其他虚拟化技术。这些API在云计算的解决方案中广泛使用
内核级虚拟化技术KVM(Kernel-based Virtual Machine)和管理工具libvirt 对kvm&libvirt的一个介绍ppt 课程作业所用
这是一个简单的 Libvirt 虚拟机管理器,使用 PHP 开发。它可以启动、关闭、强制结束或读取虚拟机信息,列出虚拟机列表等。这个项目是为了让开发者管理虚拟机更简单,更轻松。
编译后直接可用的libvirt-java.jar,java监控虚拟机的必要jar包