2012-04-20 71 views
0

Xen虛擬機管理程序有2種網絡配置模式,正如我在Virtual Manager中所見。 1路由的NAT 2。兩者都要求IP子網。但是,我想配置一個網絡,我可以分配任何IP而不是由Xen的DHCP分配。Xen配置主機專用適配器

我已經使用oracle虛擬框有一個選項,使用主機只適配器。我想以這種方式使用Xen。

在我要共享物理網絡接口到客戶機換言之(VM)

我使用的是在CentOS 6.2 x86_64的Xen管理程序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

+0

是否使用思傑公司的XenServer? – Robbietjuh 2012-04-20 21:56:21

回答

1

對於Xen,這僅僅是橋接網絡的一個特例。

您在CentOS Dom0上創建一個虛擬網橋,然後將您的虛擬機連接到該網橋。

從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中

alias dummy0 dummy 
options dummy numdummies=1 

要配置網絡的dummy0編輯/新建/ etc/sysconfig/network中的腳本/的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 

然後,您可以只是你的虛擬機連接到dummy0橋接設備

附加參考 http://wiki.xen.org/wiki/HostConfiguration/Networking