2015-04-04 Set Up XEN Network

Procedure

Create Bridges

Following the examples given in 2.1 Bridging, I used the following script to create all four (4) bridges:

cd /etc/sysconfig/network-scripts for bridge in 0 1 2 3 do nw=$(((bridge + 1))) bridgename="xenbr${bridge}" # ==== Create bridge cat <<DONE >ifcfg-${bridgename} # ----------------------------------------------------------------------------- # Bridge ${bridgename} # Generated $(date +"%F %T") # ----------------------------------------------------------------------------- # Device identification DEVICE="${bridgename}" UUID="$(uuidgen)" # Device options BOOTPROTO="static" TYPE="Bridge" ONBOOT="yes" DELAY="0" NM_CONTROLLED="no" # IPV4 Networking IPADDR="192.168.${nw}.100" NETMASK="255.255.255.0" GATEWAY="192.168.1.1" # DNS DNS1="192.168.1.252" DNS2="192.168.1.1" PEERDNS="yes" DOMAIN="yaocm.id.au" DONE done

The uuidgen command is used to generate a random UUID for this bridge.

Create Sub-Interfaces

Following the advice in Create sub interfaces on CentOS and Redhat, I used the following script to create sub-interfaces on eth1 to support three (3) bridges (except for xenbr0):

cd /etc/sysconfig/network-scripts for subif in 1 2 3 do bridge=${subif} ifname="eth1:${subif}" bridgename="xenbr${bridge}" # ==== Create subinterface cat <<DONE >ifcfg-${ifname} # ----------------------------------------------------------------------------- # Sub-interface #${subif} on eth1 to support bridge ${bridgename} # Generated $(date +"%F %T") # ----------------------------------------------------------------------------- # Device identification DEVICE="${ifname}" UUID="$(uuidgen)" $(grep HWADDR ifcfg-eth1) # Device options ONPARENT="yes" TYPE="Ethernet" MTU="9000" ONBOOT="yes" NM_CONTROLLED="no" # Bridge BRIDGE="${bridgename}" DONE done

The uuidgen command is used to generate a random UUID for this sub-interface. The grep command is used to copy the MAC address from the parent device (eth1).

Put xenbr0 onto bond0

I used the following command to put xenbr0 onto the bond0 interface:

cd /etc/sysconfig/network-scripts cat >>ifcfg-bond0 <<DONE # Bridge BRIDGE="xenbr0" DONE

Enable Routing

Following the advice in 2.3.1 Enabling Routing (All Distributions), and the documentation in networking/ip-sysctl.txt, I updated /etc/sysctl.conf with the following lines:

net.ipv4.ip_forward = 1 net.ipv4.conf.all.proxy_arp = 1

Then, I ran the following command to update the system configuration:

sysctl -p /etc/sysctl.conf

Restart Network

I used the following command to implement the new network configuration:

service network restart

The result is:

Shutting down interface bond0: bridge xenbr0 does not exist! [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface bond0: [ OK ] Bringing up interface xenbr0: [ OK ] Bringing up interface xenbr1: [ OK ] Bringing up interface xenbr2: [ OK ] Bringing up interface xenbr3: [ OK ]