XenServer编译IP地址,软路由支持2级网络!

By | September 22, 2013

使用Xenservser架设VPS,有的时候IDC分配的IP地址无法用于VPS.

是因为默认新加IP地址是路由到母机Xenserver的,如果需要VPS使用必须重路由设置,可以叫机房在路由上给你做设置,也可以自己在Xenserver上做软路由!

方法:SSH进入母机Xenserver. 复制粘贴如下代码

touch /etc/sysconfig/network-scripts/ifcfg-dummy0

echo “DEVICE=dummy0” >> /etc/sysconfig/network-scripts/ifcfg-dummy0
echo “BOOTPROTO=none” >> /etc/sysconfig/network-scripts/ifcfg-dummy0
echo “ONBOOT=yes” >> /etc/sysconfig/network-scripts/ifcfg-dummy0
echo “USERCTL=no” >> /etc/sysconfig/network-scripts/ifcfg-dummy0
echo “IPV6INIT=no” >> /etc/sysconfig/network-scripts/ifcfg-dummy0
echo “PEERDNS=yes” >> /etc/sysconfig/network-scripts/ifcfg-dummy0
echo “TYPE=Ethernet” >> /etc/sysconfig/network-scripts/ifcfg-dummy0
echo “IPADDR=192.250.241.1” >> /etc/sysconfig/network-scripts/ifcfg-dummy0
echo “NETMASK=255.255.255.0” >> /etc/sysconfig/network-scripts/ifcfg-dummy0
echo “DNS1=204.74.208.2” >> /etc/sysconfig/network-scripts/ifcfg-dummy0
echo “DNS2=204.74.213.254” >> /etc/sysconfig/network-scripts/ifcfg-dummy0
echo “ARP=yes” >> /etc/sysconfig/network-scripts/ifcfg-dummy0

ifup dummy0

其中的网关和掩码改为你自己IP嗦对应的.

 

然后再添加需软路由的IP,代码如下:

ip route add 192.250.241.2 dev xenbr0
ip route add 192.250.241.3 dev xenbr0
ip route add 192.250.241.4 dev xenbr0
ip route add 192.250.241.5 dev xenbr0
ip route add 192.250.241.6 dev xenbr0
ip route add 192.250.241.7 dev xenbr0
ip route add 192.250.241.8 dev xenbr0
ip route add 192.250.241.9 dev xenbr0

 

echo “ip route add 192.250.241.2 dev xenbr0” >> /etc/rc.local
echo “ip route add 192.250.241.3 dev xenbr0” >> /etc/rc.local
echo “ip route add 192.250.241.4 dev xenbr0” >> /etc/rc.local
echo “ip route add 192.250.241.5 dev xenbr0” >> /etc/rc.local
echo “ip route add 192.250.241.6 dev xenbr0” >> /etc/rc.local
echo “ip route add 192.250.241.7 dev xenbr0” >> /etc/rc.local
echo “ip route add 192.250.241.8 dev xenbr0” >> /etc/rc.local
echo “ip route add 192.250.241.9 dev xenbr0” >> /etc/rc.local

其中的IP地址就是你需要应用于子网络的IP,有多少就复制添加多少个!

OK!

Leave a Reply

Your email address will not be published.