首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xen配置仅主机适配器

Xen配置仅主机适配器
EN

Stack Overflow用户
提问于 2012-04-21 05:49:21
回答 1查看 2.4K关注 0票数 0

正如我在Virtual Manager中看到的,Xen虚拟机管理程序有两种网络配置模式。%1 NAT %2已路由。两者都请求IP子网。但是,我想配置一个网络,在这个网络中,我可以分配任何IP,而不是被Xen的DHCP分配。

我使用过oracle Virtual Box,有一个使用仅主机适配器的选项。我想以这种方式使用Xen。

换句话说,我希望与来宾计算机(VM)共享物理网络接口

我在CentOS 6.2 x86_64上使用Xen Hypervisor 3.x

我做了以下工作来解决这个问题,这对我很有效。

代码语言:javascript
复制
Disabling Xen's network scripts
If using Xen it is recommended to disable its network munging by editing /etc/xen/xend-config.sxp and changing the line
(network-script network-bridge)

To be

(network-script /bin/true)

Disabling NetworkManager

As of the time of writing (Fedora 12), NetworkManager still does not support bridging, so it is necessary to use "classic" network initscripts for the bridge, and to explicitly mark them as independent from NetworkManager (the "NM_CONTROLLED=no" lines in the scripts below).

If desired, you can also completely disable the NetworkManager:

# chkconfig NetworkManager off
# chkconfig network on
# service NetworkManager stop
# service network start

Creating network initscripts

In the /etc/sysconfig/network-scripts directory it is neccessary to create 2 config files. The first (ifcfg-eth0) defines your physical network interface, and says that it will be part of a bridge:

# cat > ifcfg-eth0 <<EOF
DEVICE=eth0
HWADDR=00:16:76:D6:C9:45
ONBOOT=yes
BRIDGE=br0
NM_CONTROLLED=no
EOF

Obviously change the HWADDR to match your actual NIC's address. You may also wish to configure the device's MTU here using e.g. MTU=9000.

The second config file (ifcfg-br0) defines the bridge device:

# cat > ifcfg-br0 <<EOF
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
DELAY=0
NM_CONTROLLED=no
EOF

WARNING: The line TYPE=Bridge is case-sensitive - it must have uppercase 'B' and lower case 'ridge'

After changing this restart networking (or simply reboot)

# service network restart

Visit for more details

EN

回答 1

Stack Overflow用户

发布于 2012-04-22 06:08:32

对于Xen来说,这只是桥接网络的一个特例。

您可以在CentOS Dom0上创建一个虚拟网桥,然后将VM连接到该网桥。

从CentOS文档(http://www.centos.org/docs/5/html/5.2/Virtualization/sect-Virtualization-Virtualized_network_devices-Laptop_network_configuration.html)

创建dummy0网络接口并为其分配静态IP地址。

在我们的示例中,我选择了10.1.1.1,以避免在我们的环境中出现路由问题。要启用虚拟设备支持,请将以下行添加到/etc/modprobe.conf

代码语言:javascript
复制
alias dummy0 dummy
options dummy numdummies=1

要为dummy0配置网络,请编辑/create /etc/sysconfig/network-scripts/ifcfg-dummy0:

代码语言:javascript
复制
DEVICE=dummy0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
IPV6INIT=no
PEERDNS=yes
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=10.1.1.1
ARP=yes

然后,您只需将虚拟机连接到dummy0桥接设备

其他参考http://wiki.xen.org/wiki/HostConfiguration/Networking

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10254020

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档