注:以下Xen版本为4.4.0
Xen网络配置有两种,一是网桥,二是NAT。
1、网桥
①修改文件 /etc/network/interfaces:
auto xenbr0
iface xenbr0 inet dhcp
bridge_ports eth0
②在虚拟机配置文件中:
vif = ['bridge = xenbr0']
2、NAT
①修改文件 /etc/network/interfaces:
auto xenbr0
iface xenbr0 inet static
bridge_ports none
bridge_stp no
address 10.0.0.1
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
②修改文件 /etc/sysctl.conf:
添加:net.ipv4.ip_forward = 1
终端执行:sysctl -p /etc/sysctl.conf
③ 终端执行:
sudo iptables-save > /etc/iptables-rules
修改文件 /etc/network/interfaces:
添加: pre-up iptables-restore < /etc/iptables-rules
post-down iptables-save > /etc/iptables-rules
④修改DomU,假如位win7:
修改ipv4为静态地址10.0.0.2 gw 10.0.0.1
修改虚拟机配置文件:
vif=['bridge=xenbr0,ip=10.0.0.2']
关闭虚拟机里的防火墙!