<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Felipe Alfaro Solana &#187; XEN</title>
	<atom:link href="http://www.felipe-alfaro.org/blog/category/virtualization/xen/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.felipe-alfaro.org/blog</link>
	<description>A little bit of technology, security and networking with Linux, FreeBSD and Mac OS X, plus some personal opinions.</description>
	<lastBuildDate>Sun, 23 Oct 2011 16:46:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>NetBSD 3.1 as a domU/guest on Xen</title>
		<link>http://www.felipe-alfaro.org/blog/2007/02/04/netbsd-31-under-xen-303/</link>
		<comments>http://www.felipe-alfaro.org/blog/2007/02/04/netbsd-31-under-xen-303/#comments</comments>
		<pubDate>Sun, 04 Feb 2007 13:52:00 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[NetBSD]]></category>
		<category><![CDATA[XEN]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/2007/02/04/netbsd-31-under-xen-303/</guid>
		<description><![CDATA[Xen is one of the coolest pieces of software I have ever used. It allows me to partition my box into manageable pieces, for increased security and increased resource utilization. I have been playing extensively with Xen for more than a year and have also written some posts about it. NetBSD is a lean, mean, [...]]]></description>
			<content:encoded><![CDATA[<p>Xen is one of the coolest pieces of software I have ever used. It allows me to partition my box into manageable pieces, for increased security and increased resource utilization. I have been playing extensively with Xen for more than a year and have also written some posts about it.</p>
<p>NetBSD is a lean, mean, fast free, open source operating system and is nicely supported under Xen, has nice features like the PF packet filter and the pkgsrc ports-like collection and runs in nearly every single hardware architecture on earth. Because of this, I decided to run NetBSD 3.1 on Xen. NetBSD can run either as the privileged domain (called dom0) or as an unprivileged guest (called domU) domain. Since I was already running Linux under Xen as a domU, I am mostly interested in running NetBSD 3.1 as a domU guest on Xen. dom0 can be either Red Hat Enterprise Linux 5.0 or Fedora Core 6, but feel free to use any other Linux distribution as most of them are Xen-ready.</p>
<p>As far as I know, there are some restrictions between the Xen hypervisor + dom0 kernel and domU kernel:</p>
<ul>
<li>You cannot mix PAE-enabled and non-PAE kernels.
<p>For example, you cannot run a PAE-enabled dom0 kernel and/or PAE-enabled hypervisor and a non-PAE dom0/domU kernel.</p>
<p>This is currently a problem since Fedora Core 6 and Red Hat Enterprise Linux 5.0 both ship with a PAE-enabled Xen hypervisor and Xen-enabled kernels, but NetBSD does not currently ship a PAE-compatible, Xen-enabled kernel.
</li>
<li>You cannot mix 64-bit and 32-bit kernels.
<p>You cannot run a 64-bit Xen hypervisor and 64-bit dom0 kernel and a 32-bit domU kernel.
</li>
</ul>
<p>Since both Fedora Core 6 and Red Hat Enterprise Linux 5.0 ship by default with a PAE-enabled (36-bit addressable memory space) Xen hypervisor and dom0 Xen-enabled Linux kernel, the first thing that I had to do in order to run NetBSD 3.1 as domU under Xen was to recompile the Linux kernel and the Xen hypervisor with PAE support completely disabled. This is described next.</p>
<h2>Build Xen hypervisor and dom0 kernel without PAE</h2>
<p>You can skip to the next section if you already have a non-PAE, working Xen installation.</p>
<p>The first thing I had to do is to downl the SRPM (source RPM) for the latest Linux kernel, for example <a href="http://redhat.download.fedoraproject.org/pub/fedora/linux/core/updates/6/SRPMS/kernel-2.6.19-1.2895.fc6.src.rpm">kernel-2.6.19-1.2895.fc6.src.rpm</a>, then install it by running:</p>
<pre>
# rpm -i kernel-2.6.19-1.2895.fc6.src.rpm
</pre>
<p>In file <code>/usr/src/redhat/SPECS/kernel-2.6.spec</code> replace the following:</p>
<div>
<pre>
%ifarch i686
%define buildpae 1
# we build always xen HV with pae
%define xen_flags verbose=y crash_debug=y pae=y
%endif
</pre>
</div>
<p>with:</p>
<div>
<pre>
%ifarch i686
%define buildpae 0
# we build always xen HV with pae
%define xen_flags verbose=y crash_debug=y
%endif
</pre>
</div>
<p>This will cause the Xen hypervisor to be built without PAE support. Additionally, no PAE-enabled extra kernels will be built. The Xen kernel, however, uses its specific configuration file that has to be changed in order to disable PAE support. To disable PAE support for the Xen kernel, I reconfigured the kernel with no PAE support by running:</p>
<div>
<pre>
# rpmbuild -bp /usr/src/redhat/SPECS/kernel-2.6.spec
# cd /usr/src/redhat/BUILD/kernel-2.6.19/linux-2.6.19.i386
# cp configs/kernel-2.6.19-i686-xen.config .config
# make menuconfig
</pre>
</div>
<p>Make sure PAE is disabled by navigating to <code>Processor type and features</code>, then <code>High Memory Support</code> is set to either <code>off</code> or <code>4GB</code> (but not <code>64GB</code>).</p>
<p>Next, I copied the updated configuration file back to <code>/usr/src/redhat/SOURCES</code>, where it belongs. Also, we need to insert <code># i386</code> at the beginning of the file so that the RPM build process can derive the exact processor architecture from the config file when building the RPMs:</p>
<div>
<pre>
# cat &lt;(echo "# i386") .config &gt; ../../../SOURCES/kernel-2.6.19-i686-xen.config
</pre>
</div>
<p>The processor architecture is supplied to <code>make</code> during the build process in the form of <code>ARCH=i386</code>.</p>
<p>Now, let&#8217;s build the RPMs:</p>
<div>
<pre>
# rpmbuild -ba --target i686 ../../../SPECS/kernel-2.6.spec
</pre>
</div>
<p>We need to specify <code>i686</code> as the target architecture since Fedora and Red Hat don&#8217;t use <code>i386</code> anymore for kernels themselves &#8212; <code>i386</code> is now only used for some common RPMs like <code>kernel-headers</code>.</p>
<p>Once the RPMs have been built, check the files under <code>/usr/src/redhat/RPMS/i686</code>. At least there should be a file called <code>kernel-xen-2.6.19-1.2895.i686.rpm</code>. This RPM contains several files, but the ones that we are interested in are:</p>
<ul>
<li>/boot/config-2.6.19-1.2895xen
<p>Contains the kernel configuration. Make sure either <code>CONFIG_X86_PAE</code> is set to <code>n</code> or is undefined.</li>
<li>/boot/vmlinuz-2.6.19-1.2895xen
<p>The Linux Xen-enabled kernel.</li>
<li>/boot/xen.gz-2.6.19-1.2895
<p>The Xen hypervisor. In the most recent versions of Fedora Core and Red Hat Enterprise Linux, the Xen hypervisor and the Xen-enabled kernel are packaged in the same RPM. This is the right thing to do since both are tightly coupled.</li>
</ul>
<p>Install the new Xen kernel and hypervisor:</p>
<div>
<pre>
# rpm -ivh --force /usr/src/redhat/RPMS/i686/kernel-xen-2.6.19-1.2895.i686.rpm
</pre>
</div>
<p>Reboot:</p>
<div>
<pre>
# reboot
</pre>
</div>
<p>I assume the system will boot correctly and into the new Xen hypervisor and Xen-enabled Linux kernel. You can check that by running:</p>
<div>
<pre>
# uname -a
Linux xen 2.6.19-1.2895xen #1 SMP Sat Feb 3 16:56:34 CET 2007 i686 i686 i386 GNU/Linux
</pre>
</div>
<p>The next step is installing NetBSD 3.1 as a domU. This is covered next.</p>
<h2>Installing NetBSD 3.1</h2>
<p>The first step is preparing the Xen&#8217;s domU configuration file and its corresponding storage backend. Xen can use file-backed storage for a domU or block-backed storage (i.e. a disk partition or logical volume). Typically, block-backed storage is faster than file-backed storage, so I set up a 10GiB logical volume for NetBSD:</p>
<div>
<pre>
# lvcreate -n netbsd xen -L 10G
</pre>
</div>
<p>I also used NetBSD&#8217;s Internet-based installation since it&#8217;s the easiest way to get a working NetBSD installation and the NetBSD community have built Xen-enabled NetBSD kernels:</p>
<ul>
<li>netbsd-INSTALL_XEN3_DOMU
<p>A Xen-based, domU kernel used to install NetBSD.</li>
<li>netbsd-XEN3_DOMU
<p>A Xen-based, domU kernel used to run the installed system.</li>
</ul>
<p>Both files can be downloaded from <a href="ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-3.1/i386/binary/kernel">/pub/NetBSD/NetBSD-3.1/i386/binary/kernel</a>. Download and uncompress both of them:</p>
<div>
<pre>
# wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-3.1/i386/binary/kernel/netbsd-*XEN3_DOMU.gz
# zcat netbsd-INSTALL_XEN3_DOMU.gz > /boot/netbsd-INSTALL_XEN3_DOMU
# zcat netbsd-XEN3_DOMU.gz > /boot/netbsd-XEN3_DOMU
</pre>
</div>
<p>If you are running SELinux, you will need to relabel these files properly or <code>xm</code> will be unable to load them into memory:</p>
<div>
<pre>
# chcon root system_u:object_r:boot_t /boot/netbsd*
</pre>
</div>
<p>Next, create the Xen configuration file for NetBSD. In my case, it looked like this:</p>
<div>
<pre>
# cat /etc/xen/auto/netbsd
kernel = "/boot/netbsd-INSTALL_XEN3_DOMU"
memory = 256
name = "netbsd"
vif = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0' ]
disk = [ 'phy:/dev/xen/netbsd,hda,w' ]
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'
</pre>
</div>
<p>Now, we will install NetBSD by starting the domain:</p>
<div>
<pre>
# xm create -c /etc/xen/auto/netbsd
</pre>
</div>
<p>This will start the new domain and will attach to its console. You can follow the <a href="http://www.netbsd.org/guide/en/chap-exinst.html">Example Installation</a> NetBSD document to assist you in installing NetBSD and also <a href="http://wiki.xensource.com/xenwiki/NetBSDdomU">Xensource NetBSDdomU</a> Wiki page.</p>
<p>Once the installer has finished, do not reboot. At the end of the installation process, you&#8217;ll be brought back to the main install screen. Select <code>e: Utility menu</code>, then <code>a: Run /bin/sh</code>, then type the following at the shell:</p>
<div>
<pre>
mount /dev/xbd0a /mnt
cp -pR /dev/rxbd* /mnt/dev
cp -pR /dev/xbd* /mnt/dev
halt -p
</pre>
</div>
<p>This will copy the required special device files and shut down the guest. Now, you will have to modify the domain config file in order to use the standard NetBSD domU kernel, <code>/boot/netbsd-XEN3_DOMU</code>. Edit <code>/etc/xen/auto/netbsd</code> and replace:</p>
<div>
<pre>
kernel = "/boot/netbsd-INSTALL_XEN3_DOMU"
</pre>
</div>
<p>with:</p>
<div>
<pre>
kernel = "/boot/netbsd-XEN3_DOMU"
</pre>
</div>
<p>And boot the domain again:</p>
<div>
<pre>
# xm create -c /etc/xen/auto/netbsd
</pre>
</div>
<p>During boot, you will see some errors like:</p>
<p><code><br />
wsconscfg: /dev/ttyEcfg: Device not configured<br />
</code></p>
<p>This is due to the NetBSD guest only having access to one physical console. To kill those errors, edit <code>/etc/ttys</code> from within the NetBSD guest and turn off all terminals except <code>"console"</code>, like:</p>
<div>
<pre>
console "/usr/libexec/getty Pc"         vt100   on  secure
ttyE0   "/usr/libexec/getty Pc"         vt220   off secure
ttyE1   "/usr/libexec/getty Pc"         vt220   off secure
ttyE2   "/usr/libexec/getty Pc"         vt220   off secure
ttyE3   "/usr/libexec/getty Pc"         vt220   off secure
...
</pre>
</div>
<p>Also, comment out all screens in <code>/etc/wscons.conf</code>:</p>
<div>
<pre>
#screen 0       -       vt100
#screen 1       -       vt100
#screen 2       -       vt100
#screen 3       -       vt100
#screen 4       -       -
#screen 4       80x25bf vt100
</pre>
</div>
<p>That&#8217;s all. Now we have a fully functional NetBSD 3.1 domU guest running on Xen <img src='http://www.felipe-alfaro.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h2>References</h2>
<p>The information and instructions on this post are based on:</p>
<ol>
<li><a href="http://wiki.xensource.com/xenwiki/NetBSDdomU">NetBSDdomU</a> &#8212; How to install NetBSD as a domU on a Linux host.</li>
<li><a href="http://www.netbsd.org/guide/en/chap-exinst.html">Example Installation</a> &#8212; NetBSD example installation.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2007/02/04/netbsd-31-under-xen-303/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Xen network configuration and multiple VLANs (II)</title>
		<link>http://www.felipe-alfaro.org/blog/2006/08/21/xen-network-configuration-and-multiple-vlans-ii/</link>
		<comments>http://www.felipe-alfaro.org/blog/2006/08/21/xen-network-configuration-and-multiple-vlans-ii/#comments</comments>
		<pubDate>Mon, 21 Aug 2006 00:20:40 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[XEN]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/2006/08/21/xen-network-configuration-and-multiple-vlans-ii/</guid>
		<description><![CDATA[Since I first write my first attempt at trying to get VLAN support working under Xen, I&#8217;ve received some reports for people stating that it doesn&#8217;t work as expected. And they are right. At the end of the first article, I pointed out I was having problems with UDP traffic. In turn, it was worse [...]]]></description>
			<content:encoded><![CDATA[<p>Since I first write my first attempt at trying to get VLAN support working under Xen, I&#8217;ve received some reports for people stating that it doesn&#8217;t work as expected. And they are right.</p>
<p>At the end of the first article, I pointed out I was having problems with UDP traffic. In turn, it was worse than I ever expected, since it was affecting DNS name resolution, DHCP services and other services running as inside a domainU. This is the reason why I rethought the implementation and now have it working on a production machine acting, among as other things, as a DHCP server and DNS server.</p>
<p>In this second try I decided not to mess around with Xen&#8217;s default network configuration, so please undo all the changes you did so you end end up with a pristine Xen configuration. In this new scenario all the native traffic (tagged an untagged Ethernet frames) is being captured by Xen&#8217;s switch, <code>xenbr0</code>, and sent to the right network interface. If the traffic being received is a 802.11q tagged frame, the target will receive it tagged and thus will have to implement measures to untag and process it accordingly.</p>
<h2>Introduction</h2>
<p>So, let&#8217;s say we have the following logical network topology and virtual machines:</p>
<div>
<pre>
                   |
                  LAN
                   |
-------------------+----------------------------------
|                  |                                 |
|                peth0 ---- xen-br0                  |
|                              |                     |
|            -----------------------------           |
|            |                           |           |
|          vif0.0                     vif1.0         |
|            |                           |           |
|            |            +--------------+------------
|            |            |              |
|            |            |  ------------+------------
|            |            |  |           |           |
|           eth0          |  |          eth0         |
|            |            |  |           |           |
|     -------+-------     |  |     ------+-------    |
|     |             |     |  |     |            |    |
| eth0.1000      eth0.10  |  | eth0.2000     eth0.10 |
|     |             |     |  |     |            |    |
| VLAN 1000      VLAN 10  |  | VLAN 2000     VLAN 10 |
|     |             |     |  |     |            |    |
|    www           ssh    |  |    ftp          ssh   |
|                         |  |                       |
|        Domain0          |  |        DomainU        |
---------------------------  -------------------------
</pre>
</div>
<p>The Xen&#8217;s switch configuration can be seen with the following command:</p>
<div>
<pre>
root@xen:~# <b>brctl show</b>
bridge name  bridge id           STP enabled   interfaces
xenbr0       8000.feffffffffff   no            peth0
                                               vif0.0
                                               vif1.0
</pre>
</div>
<p>For each domain &#8212; this includes domain0 or any domainU &#8212; there is a <code>vif|X|.|Y|</code> interface attached to Xen&#8217;s bridge <code>xen-br0</code>, where <code>|X|</code> is the domain ID (0 for domain0 and a monotonically increasing number for every domainU). Then, we have every network interface card inside the domain, in the form of <code>eth|Y|</code>. Thus, if a domainU with ID #3 defines two network interfaces, <code>eth0</code> and <code>eth1</code>, there will two corresponding virtual network interfaces in domain0, named <code>vif3.0 and </code><code>vif3.1</code>.</p>
<p>Instead of trying to export VLAN interfaces to one or more domainUs, we export the whole, native (tagged or not) network interface to the domainU and, inside this domainU, we can configure VLAN subinterfaces if needed.</p>
<h2>Sample scenario</h2>
<p>Let&#8217;s say we want to offer the following services per VLAN:</p>
<ul>
<li>WWW server on VLAN 1000</li>
<li>FTP server on VLAN 2000</li>
<li>SSH access to administer the WWW sever, reachable only through the VLAN 10</li>
<li>SSH server to administer the FTP server, reachable only through the VLAN 10</li>
</ul>
<p>But we also want to partition the physical machine in two, so domain0 serves WWW traffic while domainU servers FTP traffic:</p>
<table border="1" cellpadding="20" cellspacing="0">
<tr>
<th align="center"></th>
<th align="center">WWW</th>
<th align="center">FTP</th>
<th align="center">SSH</th>
</tr>
<tr>
<td align="center"><b>domain0</b></td>
<td align="center">VLAN 1000</td>
<td align="center">-</td>
<td align="center">VLAN 10</td>
</tr>
<tr>
<td align="center"><b>domainU</b></td>
<td align="center">-</td>
<td align="center">VLAN 2000</td>
<td align="center">VLAN 10</td>
</tr>
</table>
<p>Thus, we need the following VLAN subinterfaces:</p>
<ul>
<li><code>eth0.10</code> and <code>eth0.1000</code> on domain0</li>
<li><code>eth0.10</code> and <code>eth0.2000</code> on domainU</li>
</ul>
<p>Configuring VLAN subinterfaces in domainU is straight forward. However, it&#8217;s a little bit more difficult for domain0.</p>
<h2>Configuring VLAN subinterfaces for domain0</h2>
<p>First of all, make sure you are using bridging for your Xen configuration. Make sure the following line is <strong>uncommented</strong> in /etc/xen/xend-config.sxp:</p>
<p><code>(network-script network-bridge)</code></p>
<p>And <strong>comment</strong> any other network-script configuration lines, like:</p>
<p><code>(network-script network-nat)</code></p>
<p>or</p>
<p><code>(network-script network-route)</code></p>
<p>It seems we can&#8217;t bring up VLAN subinterfaces before Xen&#8217;s network script is fired up since Xen&#8217;s network scripts perform some black magic on the network interfaces, mainly renaming <code>eth0</code> to <code>peth0</code> and bringing up a dummy interface named <code>eth0</code>. Any subinterface related to the original <code>eth0</code> seems to stop working after the renaming takes place.</p>
<p>Thus, I coded up an init script used to bring up the VLAN subinterfaces that gets invoked just after Xen&#8217;s network script has finished. Note that it&#8217;s targeted for RedHat-based distributions:</p>
<div>
<pre>
#!/bin/sh
#
# Init file for Network-VLAN
# STARTS AFTER XEN (which is S50 and K01)
#
# chkconfig: 2345 51 89
# description: VLAN networking

. /etc/init.d/functions

case "$1" in
start)
 echo -n $"Configuring VLAN interfaces:"

 if [ ! -f /var/lock/subsys/network-vlan ]; then
  (
  modprobe 8021q || exit 1
  vconfig add eth0 10 || exit 2
  ifconfig eth0.10 up 10.0.0.1 netmask 255.0.0.0 || exit 3
  vconfig add eth0 1000 || exit 2
  ifconfig eth0.1000 up 11.0.0.1 netmask 255.0.0.0 || exit 3
  ) > /dev/null 2>&#038;1

  RETVAL=$?
  [ "$RETVAL" = 0 ] &#038;&#038; ( success ;\\
    touch /var/lock/subsys/network-vlan ) || failure
 fi
 echo

 ;;

stop)
 echo -n $"Unconfiguring VLAN interfaces:"

 if [ -f /var/lock/subsys/network-vlan ]; then
  (
  ifconfig eth0.10 down &#038;&#038; vconfig rem eth0.10 ;
  ifconfig eth0.1000 down &#038;&#038; vconfig rem eth0.1000
  ) > /dev/null 2>&#038;1

  RETVAL=$?
  [ "$RETVAL" = 0 ] &#038;&#038; ( rm -f /var/lock/subsys/network-vlan ;\\
    success ) || failure
 fi
 echo
esac
</pre>
</div>
<p>Save this script as <code>/etc/init.d/network-vlan</code>, then run:</p>
<div>
<pre>
chmod +x /etc/init.d/network-vlan
chkconfig --add /etc/init.d/network-vlan
</pre>
</div>
<p>The script runs just after Xen&#8217;s init script has renamed the real Ethernet interface and has brought up a dummy interface called <code>eth0</code>. Then, the <code>network-vlan</code> script brings up two VLAN subinterfaces, one for VLAN 10 and another one for VLAN 1000, and then assigns each one its own IP address.</p>
<p>Additionally, these are the contents of <code>/etc/sysconfig/network-scripts/ifcfg-eth0</code>:</p>
<div>
<pre>
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
</pre>
</div>
<p>Note that <code>eth0</code> in this context refers to the real Ethernet interface, since Xen&#8217;s init script has not been ran yet. I didn&#8217;t configure any IP address for this interface since I only want to process tagged traffic. Beware that on many switches &#8212; i.e., Cisco 2960 and 3560 &#8212;, VLAN1 is, by default, the native VLAN and traffic on the native VLAN doesn&#8217;t get tagged.</p>
<h2>Configuring VLAN subinterfaces for domainU</h2>
<p>These are the contents of <code>/etc/sysconfig/network-scripts/ifcfg-eth0</code>:</p>
<div>
<pre>
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
</pre>
</div>
<p>I didn&#8217;t configure any IP address for this interface since I only want to process tagged traffic. Read the note above on untagged frames and native VLANs.</p>
<p>These are the contents of <code>/etc/sysconfig/network-scripts/ifcfg-eth0.10</code>:</p>
<div>
<pre>
DEVICE=eth0.10
BOOTPROTO=static
IPADDR=10.0.0.2
NETMASK=255.0.0.0
ONBOOT=yes
TYPE=Ethernet
VLAN=yes
</pre>
</div>
<p>These are the contents of <code>/etc/sysconfig/network-scripts/ifcfg-eth0.2000</code>:</p>
<div>
<pre>
DEVICE=eth0.2000
BOOTPROTO=static
IPADDR=12.0.0.1
NETMASK=255.0.0.0
ONBOOT=yes
TYPE=Ethernet
VLAN=yes
</pre>
</div>
<h2>Bonding</h2>
<p>For those who desire to use bonding, it seems some tweaking of the networking scripts is required. I recommend them to look at this post on <a href="http://lists.xensource.com/archives/html/xen-users/2006-04/msg00186.html">Bonding not working with network-bridge</a>.</p>
<h2>Conclusion</h2>
<p>I&#8217;m sure there are better ways to configure VLAN subinterfaces in domain0, but it was in a hurry and couldn&#8217;t find of a better way to get it done.</p>
<p>If anyone out there has a different way of achieving this, please let me know <img src='http://www.felipe-alfaro.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2006/08/21/xen-network-configuration-and-multiple-vlans-ii/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Xen network configuration and multiple VLANs</title>
		<link>http://www.felipe-alfaro.org/blog/2006/07/21/xen-network-configuration-and-multiple-vlans/</link>
		<comments>http://www.felipe-alfaro.org/blog/2006/07/21/xen-network-configuration-and-multiple-vlans/#comments</comments>
		<pubDate>Thu, 20 Jul 2006 21:50:10 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[VLAN]]></category>
		<category><![CDATA[XEN]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/2006/07/21/xen-network-configuration-and-multiple-vlans/</guid>
		<description><![CDATA[Xen networking is powerful enough to allow for extreme customization. Although the default networking configuration is usually more than enough for simple scenarios, it can fall short when trying to support multiple guests standing on different VLANs. In this short article, I describe the steps needed to configure Xen to attach itself to multiple VLANs [...]]]></description>
			<content:encoded><![CDATA[<p>Xen networking is powerful enough to allow for extreme customization. Although the default networking configuration is usually more than enough for simple scenarios, it can fall short when trying to support multiple guests standing on different VLANs.</p>
<p>In this short article, I describe the steps needed to configure Xen to attach itself to multiple VLANs using a one-bridge-per-VLAN network interface mapping, then attaching each Xen domainU on as many VLANs as needed.</p>
<p>In the sample scenario, we will use a Cisco Catalyst 3560G-24TS switch carrying traffic from five different VLANs:</p>
<ul>
<li>VLAN2 is the administrative VLAN used to administer all the networking gear and boxes.</li>
<li>VLAN10 carries Internet traffic coming from the first ISP.</li>
<li>VLAN20 carries Internet traffic coming from the second ISP.</li>
<li>VLAN100 carries the access network traffic.</li>
<li>VLAN200 carries the core network traffic.</li>
</ul>
<p>The final Xen configuration will provide five bridging network interfaces, one per VLAN. Each Xen domainU can freely attach to any of these bridging network interfaces in order to gain access to the traffic being carried by each VLAN.</p>
<p>The bridging interface, <code><em>|brname|</em></code> is named after the following convention: <code>xenbr<em>|vlan|</em></code>:</p>
<ul>
<li><code>xenbr2</code> is the bridging interface standing on VLAN2.</li>
<li><code>xenbr10</code> is the bridging interface standing on VLAN10.</li>
<li><code>xenbr20</code> is the bridging interface standing on VLAN20.</li>
<li><code>xenbr100</code> is the bridging interface standing on VLAN100.</li>
<li><code>xenbr200</code> is the bridging interface standing on VLAN200.</li>
</ul>
<p>Also, Xen creates an manages several virtual network interfaces, named in the form of <code>vif|X|.|Y|</code>, where <code>|X|</code> equals the Xen domain numeric ID and <code>|Y|</code> is a sequential interface index. Thus, starting up a Xen domainU given the following virtual network interface definition:</p>
<div>
<pre>
vif = [ 'mac=00:16:3e:00:00:44, bridge=xenbr10',
        'mac=00:16:e3:00:00:45, bridge=xenbr20' ]
</pre>
</div>
<p>Will cause the Xen domain to get assigned, let&#8217;s say, a domain ID of 2, and two virtual network interfaces named <code>vif2.0</code> &#8212; attached to <code>xenbr10</code> &#8212; and <code>vif2.1</code> &#8212; attached to <code>xenbr20</code>.</p>
<h2>Setting up the bridging interfaces:</h2>
<p>This can be done manually, by invoking <code>brctl addbr |brname|</code> in order to create a new bridging interface.</p>
<p>For example, the following commands will create five bridging interfaces, one for each supported VLAN:</p>
<div>
<pre>
brctl addbr xenbr2
brctl addbr xenbr10
brctl addbr xenbr20
brctl addbr xenbr100
brctl addbr xenbr200
</pre>
</div>
<p>or else can be automated to get done during system startup, by creating a file named <code>/etc/sysconfig/network-scripts/ifcfg-|brname|</code>, where <code>|brname|</code> is the name assigned to the bridging interface, like <code>/etc/sysconfig/network-scripts/ifcfg-xenbr2</code> (the configuration file for the bridging interface standing on VLAN2):</p>
<div>
<pre>DEVICE=xenbr2
BOOTPROTO=static
IPADDR=192.168.0.10
NETMASK=255.255.0.0
ONBOOT=yes
TYPE=Bridge
</pre>
</div>
<h2>Setting up the VLAN interfaces and add them up to the existing bridging interfaces:</h2>
<p>This can be done manually, by invoking <code>vconfig add |ifname| |vlan|</code> to configure VLAN number <code>|vlan|</code> by using 802.1q tagging on interface <code>|ifname|</code>. This will active a virtual interface named <code>|ifname|.|vlan|</code>:</p>
<ul>
<li>Any traffic sent to this interface will get tagged for VLAN <code>|vlan|</code>.</li>
<li>Any traffic received from interface <code>|ifname|</code> carrying an 802.1q VLAN tag matching <code>|vlan|</code> will be untagged and received by this interface.</li>
</ul>
<div>
<pre>
vconfig add eth0 2
vconfig add eth0 10
vconfig add eth0 20
vconfig add eth0 100
vconfig add eth0 200
</pre>
</div>
<p>This will add five new VLAN interfaces, one for every supported VLAN.</p>
<p>Once the VLAN interfaces are ready, we add them to their corresponding bridging interfaces by using <code>brctl addif |brname| |ifname|.|vlan|</code>:</p>
<pre>
<div>
brctl addif xenbr2 eth0.2
brctl addif xenbr10 eth0.10
brctl addif xenbr20 eth0.20
brctl addif xenbr100 eth0.100
brctl addif xenbr200 eth0.200
</div>
</pre>
<p>The process of adding up a new VLAN interface and then adding it up to an existing bridging interface can be configured using a single configuration file named <code>ifcfg-|ifname|.|vlan|</code>, like <code>/etc/sysconfig/network-scripts/ifcfg-eth0.2</code>:</p>
<pre>
<div>
DEVICE=eth0.2
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
VLAN=yes
BRIDGE=xenbr2
</div>
</pre>
<h2>Keeping Xen from reconfiguring the network:</h2>
<p>Since we have already configured the network manually, we don&#8217;t want Xen to mess up with the configuration. In order to keep Xen from reconfiguring the network, simply make sure none of the following lines appear <strong>uncommented</strong> in the file <code>/etc/xen/xend-config.sxp</code>:</p>
<div>
<pre>
(network-script network-bridge)
(network-script network-route)
(network-script network-nat)
</pre>
</div>
<h2>Additional notes:</h2>
<p>I have been experiencing a very strange behavior on Xen domainU guests while using this network configuration: it seems that UDP traffic gets stuck at the network stack  and does not flow through unless I load the <code>ip_conntrack.ko</code> kernel module.</p>
<p>Failing to load the <code>ip_conntrack.ko</code> kernel module, even with an unconfigured, empty firewall, allows ICMP and TCP traffic to flow from and to the guest network stack, but UDP traffic, like DNS queries, gets stuck and doesn&#8217;t even touch the physical network interface.</p>
<p>This is really strange, isn&#8217;t it?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2006/07/21/xen-network-configuration-and-multiple-vlans/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>XEN</title>
		<link>http://www.felipe-alfaro.org/blog/2005/08/18/xen/</link>
		<comments>http://www.felipe-alfaro.org/blog/2005/08/18/xen/#comments</comments>
		<pubDate>Thu, 18 Aug 2005 18:12:30 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[XEN]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/?p=29</guid>
		<description><![CDATA[Xen implements paravirtualization to allow for software partitioning. Xen is an hypervisor that allows running several partitions, called &#8220;domains&#8221;. Each domain is totally independent, virtualized and solated by the Xen hypervisor, which controls access to the hardware and shares the physical resources among all running domains. There are two domain classes: Privileged domain: has some [...]]]></description>
			<content:encoded><![CDATA[<p>Xen implements <em>paravirtualization</em> to allow for software partitioning.</p>
<p>Xen is an hypervisor that allows running several partitions, called <em>&#8220;domains&#8221;</em>. Each domain is totally independent, virtualized and solated by the <em>Xen hypervisor</em>, which controls access to the hardware and shares the physical resources among all running domains.</p>
<p>There are two domain classes:</p>
<ol>
<li><b>Privileged domain:</b> has some limited access to the hardware, and is used to provide for virtual driver support for all the non-privileged domains. There can only be one privileged domain running on a machine at any time and its called &#8220;domain0&#8243;.
<p>For example, the privileged domain has access to the video frame buffer and can run an accelerated X server, and has limited access to real devices, like eth0, hda, and so on.</li>
<li><b>Unprivileged domain:</b> has no direct hardware access, and all the I/O operations are virtualized by using virtual devices, like the virtual block device or virtual network device, which are in turn hooked to the privileged domain. There can be as many unprivileged domains as system resources allow for.
<p>Unprivileged domains don&#8217;t have a video frame buffer and, thus, all GUI support must get implented using software like VNCserver or FreeNX, then remotely controlling the session from another domain or machine.</li>
</ol>
<p>Xen selects a random hardware <acronym title="Layer 2, Medium Access Control">MAC</acronym> address if not specifically told to use a particular one. This causes problems with networking since the MAC address for the domain virtual interface (called <em>vif</em>) changes between domain reboots and switches and computers keep the corresponding entry on their ARP caches for a few minutes.</p>
<p>Let be A a virtual unprivileged domain running under Xen&#8217;s control. After A has started, any other domain or real machine, will be unable to talk to A until the moment A forces an ARP cache update by sending out a packet (for example, an ICMP packet).</p>
<p>I see two solutions to this problem:</p>
<ol>
<li><b>When domain A starts, it initiates an ARP cache refresh of other domains or machines.</b>
<p>This can be achieved by sending a gratuitious ARP cache on interface wakeup, which not every Linux distribution does, or send some ICMP echo request packets to force sending ARP requests. This can be easily implemented in init scripts.</li>
<li><b>Forcing domain A to use a fixed MAC address.</b>
<p>This can be achieved by using the following line in A domain configuration file:</p>
<p><code>vif = [ 'mac = XX:XX:XX:XX:XX:XX' ]</code></p>
<p>The latter solution is the easiest and, usually, the preferred one.</p>
<p><b>NOTE:</b> This also covered in the <a href="http://www.cl.cam.ac.uk/Research/SRG/netos/xen/faq.html#a2.1" title="Xen FAQ ">Xen FAQ</a>.
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2005/08/18/xen/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

