If you want to setup private network on xenserver and you only have one public IP that is set on interface xenbr0 interface (bridged from eth0) in sequence to make VMs to access the Internet we had to add an alias interface, as below :
#ifconfig xenbr0:0 172.0.0.1 netmask 255.255.255.0 up
We consider 172.0.0.0/24 our private LAN from where the VMs will get IPs. Furthermore we route all traffic from 172.0.0.0/24 to xenbr0 using :
#ip addr add 172.0.0.0/24 dev xenbr0
Now we have to add an VM and set an IP from the 172.0.0.0/24 range.
#iptables -t nat -A POSTROUTING -s 172.0.0.0/255.255.255.0 -j MASQUERADE
#iptables -I RH-Firewall-1-INPUT -s 172.0.0.0/24 -j ACCEPT
#service iptables save
#iptables -I RH-Firewall-1-INPUT -s 172.0.0.0/24 -j ACCEPT
#service iptables save
Then edit/modify /etc/sysctl.conf and enable ip_forward as below.
defaults
net.ipv4.ip_forward = 0
Change to
net.ipv4.ip_forward = 1
That’s it.
