Depending on your datacenter allotment of IP addresses, you may be required to use the xenserver hypervisor as a gateway in order to provide different IP subnets to your underlying virtual machines.
Our particular installation uses our datacenter “gateway/primary” IP as the xenserver management interface IP address on xenbr0. All other datacenter IP allotments will require us to route via our primary IP address that’s connected to datacenter’s gateway. (Essentially our primary IP is our VLAN gateway). We’ve turned IP forwarding on and enlisted strict iptables on the hypervisor itself.
Turn on IP Forwarding
To turn on ip forwarding within xenserver, edit /etc/sysctl.conf and change net.ipv4.ip_forward = 0 to a value of 1
Edit IP Tables for IP Forwarding
Add the following line to /etc/sysconfig/iptables after “-A RH-Firewall-1-INPUT -i lo -j ACCEPT”. If your management ip is publicly facing like ours, you may wish to implement additional firewall rules; such as deny management and SSH ports from unknown ip addresses.
-A RH-Firewall-1-INPUT -i xenbr0 -o xenbr0 -j ACCEPT
Adding Additional Aliases
Once your hypervisor is connected and routing properly to the main datacenter gateway, you’ll simply add a network alias via the command shell. You’ll find the configuration under /etc/sysconfig/network-scripts. A gateway entry should not be required since it’s an alias of your main interface.
# nano /etc/sysconfig/network-scripts/ifcfg-xenbr0:1
DEVICE=xenbr0:1 ONBOOT=yes BOOTPROTO=none NETMASK=255.255.255.248 IPADDR=2.2.2.2
This is our auto configured management interface ifcfg-xenbr0. Which was configured via the physical terminal xsconsole.
# DO NOT EDIT: This file (ifcfg-xenbr0) was autogenerated by interface-reconfigure XEMANAGED=yes DEVICE=xenbr0 ONBOOT=no TYPE=Bridge DELAY=0 STP=off PIFDEV=eth0 BOOTPROTO=none NETMASK=255.255.255.224 IPADDR=1.1.1.123 GATEWAY=1.1.1.100 MTU=1500
Apply and restart the necessary services
Some of you may wish to restart the physical machine which is just fine, however if this is a production system you may not want the downtime.
# sysctl -p # ifup xenbr0:1 # service iptables restart
We have to add a new alias and use up one of our IP’s each time we’re provided a different subnet of addresses (our datacenter provides a minimum of 2ip’s for this purpose, you can’t just order one). The virtual machines would use a gateway of the IP address assigned to the subnet as an alias.
For instance, if we request an additional IP from our datacenter we’re provided the 2 IP’s at minimum. (Let’s say 4.4.4.55 and 4.4.4.56). One of these will be eaten up as an alias/gateway, while the other will be used on a VM. It doesn’t matter which we use for either, but lets keep it simple and use the first/lower 4.4.4.55 as the alias on xenbr0 and 4.4.4.56 as the ip on the VM.
When we set up 4.4.4.55 as an alias following the instructions in this post, the VM can be assigned the ip address 4.4.4.56 using the gateway of 4.4.4.55 in order to get internet connectivity.
Pingback: Installing XenServer and Virtual Hosts in a Routed Network | synyx - Blog