linux - Xen 配置仅主机适配器

标签 linux centos virtualization xen

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

我使用过 oracle Virtual Box,有一个选项可以使用 Host-only 适配器。我想以这种方式使用 Xen。

换句话说,我想共享物理网络接口(interface)给 guest 机器(VM)

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

我做了以下工作来解决这个对我有用的问题。

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

最佳答案

对于 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 网络接口(interface)并为其分配一个静态 IP 地址。

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

alias dummy0 dummy
options dummy numdummies=1

为 dummy0 编辑/创建/etc/sysconfig/network-scripts/ifcfg-dummy0 配置网络:

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

然后您可以将您的 VM 连接到 dummy0 网桥设备

附加引用 http://wiki.xen.org/wiki/HostConfiguration/Networking

关于linux - Xen 配置仅主机适配器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10254020/

相关文章:

c++ - 如何调试在未处理的异常中终止的程序?

c++ - Makefile 无法找到 *.o 文件来生成 .exe

python - 将 tensorflow 作为守护进程运行并将所有输出通过管道传输到日志文件

MySQL无法启动

linux - bash - 脚本的命令行参数

python - wsgi_mod 无法在 CentO 上使用 python3.10 托管 Django

linux - 我应该使用哪个虚拟机管理程序?

linux - 我们可以在没有安装任何操作系统的情况下安装 KVM 吗?

linux - 具有无效控制字段的 VM 条目 (vmlaunch)