<?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>pixelchaos.net &#187; Networking</title>
	<atom:link href="http://www.pixelchaos.net/category/networking/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pixelchaos.net</link>
	<description>random bits for your terminal</description>
	<lastBuildDate>Tue, 29 Sep 2009 11:38:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>openais: an alternative to clvm with cman</title>
		<link>http://www.pixelchaos.net/2009/04/23/openais-an-alternative-to-clvm-with-cman/</link>
		<comments>http://www.pixelchaos.net/2009/04/23/openais-an-alternative-to-clvm-with-cman/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 17:24:29 +0000</pubDate>
		<dc:creator>jcl</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Xen]]></category>

		<guid isPermaLink="false">http://www.pixelchaos.net/?p=106</guid>
		<description><![CDATA[I&#8217;ve been battling lately with a lot of problems with cman, part of Red Hat Cluster Suite. Specifically, the fencing tool (fenced) is pretty much junk when you try to start using it with Xen dom0&#8217;s. After much searching and gnashing of teeth I happened upon this mailing list post. The promise there is that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been battling lately with a lot of problems with cman, part of Red Hat Cluster Suite. Specifically, the fencing tool (fenced) is pretty much junk when you try to start using it with Xen dom0&#8217;s. After much searching and gnashing of teeth I happened upon <a href="http://xen.markmail.org/message/xrrvmcl7bq6p4pvk?q=clvm+openais">this</a> mailing list post. The promise there is that you could take clvm and compile it against openais and get a cluster aware LVM which doesnt require the rest of Red Hat Cluster Suite (and its crappy documentation, crappy fencing, and general all around crappiness). A little more searching turned up <a href="http://h2o.glou.fr/post/2009/04/20/clvm-openais-on-Debian/Lenny">this</a> web site from Olivier Le Cam which pretty much did 90% of the work for me.</p>
<p>After some testing I&#8217;m happy to say it appears to work smashingly. What follows is a somewhat more complete version of how to achieve the same results on Debian Lenny. Enjoy :)</p>
<p><span id="more-106"></span><br />
The first thing that needs to be done is to get the debian sources for clvm and modify then to use openais. After that we will recompile new packages from that source, then set up openais on our cluster nodes.</p>
<p>Install all the dependencies we need to compile clvm</p>
<pre class="brush: plain;">
root@host:~# apt-get build-dep clvm
root@host:~# apt-get install libopenais-dev
</pre>
<p>Now download the source files and cd into our working directory</p>
<pre class="brush: plain;">
root@host:~# cd /usr/src/
root@host:/usr/src# apt-get source clvm
root@host:/usr/src# cd lvm2-2.02.39
</pre>
<p>Now we&#8217;ll modify a few files in the source:</p>
<ul>
<li> The first is debian/clvm.init. You&#8217;ll need to remove any references to cman or cluster.conf. You can download an already edited version <a href='http://www.pixelchaos.net/wp-content/uploads/2009/04/clvm.init'>here</a>.</li>
<li>The next is debian/control. Modify the dependies (lvm2 without the version number, openais in place of cman) and modify the comments accordingly. A pre-edited version is <a href='http://www.pixelchaos.net/wp-content/uploads/2009/04/control'>here</a>.</li>
<li> The last file is debian/rules. Replace cman by openais in the configure options, and add the PATH where to find the openais libs. Again, a pre-made version is <a href='http://www.pixelchaos.net/wp-content/uploads/2009/04/rules'>here</a>.</li>
</ul>
<p>For clarities sake, here is the actual code block from debian/rules:</p>
<pre class="brush: plain;">
$(STAMPS_DIR)/setup-deb: SOURCE_DIR = $(BUILD_DIR)/source
$(STAMPS_DIR)/setup-deb: DIR = $(BUILD_DIR)/build-deb
$(STAMPS_DIR)/setup-deb: $(STAMPS_DIR)/source
        rm -rf $(DIR)
        cp -al $(SOURCE_DIR) $(DIR)
        cd $(DIR); \
        ./configure CFLAGS=&quot;$(CFLAGS)&quot; \
		LDFLAGS=&quot;-L/usr/lib/openais&quot; \
                $(CONFIGURE_FLAGS) \
                --with-optimisation=&quot;&quot; \
                --with-clvmd=openais \
                --enable-readline
        touch $@
</pre>
<p>The last thing to do is update the internal version number of the clvm package and add some comments to the changelog:</p>
<pre class="brush: plain;">
root@host:/usr/src/lm2-2.02.39# dch -i
</pre>
<p>Now go ahead and compile the package:</p>
<pre class="brush: plain;">
root@host:/usr/src/lm2-2.02.39# dpkg-buildpackage -rfakeroot -uc -b
</pre>
<p>After the compliation completes you should have some shiny new .deb files in /usr/src. The one we are interested in is clvm_2.02.39-7.1_i386.deb (the actual version of yours may vary depending on what you put in the debian changelog in the previous step).</p>
<p>So now that weve got our custom version of clvm compiled, its time to move on the cluster nodes. On each node in the cluster, do the following&#8230;</p>
<p>Install openais and add a user for it:</p>
<pre class="brush: plain;">
root@node:~# apt-get install openais
root@node:~# mkdir -p /etc/ais
root@node:~# adduser --no-create-home --disabled-password --disabled-login --gecos openAIS ais
</pre>
<p>Now create the following config in /etc/ais/openais.conf. This is the most basic config you can have. All you need to do is set 192.168.1.0 to be your actual network address.</p>
<pre class="brush: plain;">
totem {
        version: 2
        secauth: off
        threads: 0
        interface {
                ringnumber: 0
                bindnetaddr: 192.168.1.0
                mcastaddr: 226.94.1.1
                mcastport: 5405
        }
}
</pre>
<p>openais does not include a proper debian init sript so you can download one <a href="http://www.pixelchaos.net/wp-content/uploads/2009/04/openais.init">here</a> and save it as /etc/init.d/openais. After that is done, add it to the proper runlevels by issuing:</p>
<pre class="brush: plain;">
root@node:~# update-rc.d openais start 62 S . start 50 0 6 .
</pre>
<p>Now we can install our custom deb and turn on LVM clustering</p>
<pre class="brush: plain;">
root@node:~# dpkg -i clvm_2.02.39-7.1_i386.deb
root@node:~# sed -i 's/^    locking_type = 1$/    locking_type = 3/' /etc/lvm/lvm.conf
</pre>
<p>Thats it! Reboot your cluster nodes and they should all be cluster aware now :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelchaos.net/2009/04/23/openais-an-alternative-to-clvm-with-cman/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>diskless booting with PXE and NFS</title>
		<link>http://www.pixelchaos.net/2009/02/15/diskless-booting-with-pxe-and-nfs/</link>
		<comments>http://www.pixelchaos.net/2009/02/15/diskless-booting-with-pxe-and-nfs/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 15:10:42 +0000</pubDate>
		<dc:creator>jcl</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://www.pixelchaos.net/?p=89</guid>
		<description><![CDATA[For a long time now I&#8217;ve wanted to set up all my mythfrontends to be diskless nodes that boot via PXE using an NFS share as their root filesystem. I finally got around to doing this. I was even able to just migrate my existing installations directly into the PXE boot environment. Here is how [...]]]></description>
			<content:encoded><![CDATA[<p>For a long time now I&#8217;ve wanted to set up all my mythfrontends to be diskless nodes that boot via PXE using an NFS share as their root filesystem. I finally got around to doing this. I was even able to just migrate my existing installations directly into the PXE boot environment. Here is how I accomplished it&#8230;</p>
<p><span id="more-89"></span></p>
<p>The first thing youll need is a TFTP server. This will serve out the kernel and initrd images to clients on the network.</p>
<pre class="brush: plain;">
root@pxe:~$ apt-get install tftpd-hpa
</pre>
<p>That will install a good tftp server daemon and create the tftp root for you in /var/lib/tftpboot. Some HOWTO&#8217;s on the Internet suggest installing the syslinux package as well which provides a needed file (pxelinux.0). I prefer to download the entire netboot environment for debian since this will also provide a network bootable installer for Debian on top of the other goodness we are creating today.</p>
<pre class="brush: plain;">
root@pxe:~$ cd /var/lib/tftpboot
root@pxe:~$ wget http://ftp.debian.org/debian/dists/lenny/main/installer-i386/current/images/netboot/netboot.tar.gz
root@pxe:~$ tar xzvf netboot.tar.gz
</pre>
<p>The kernel and initrd you are going to use to boot the mythbox must reside on the TFTP server. Furthermore, the initrd must be updated to support NFS root. On the mythbox I was migrating to the NFS root, it looked like this:</p>
<pre class="brush: plain;">
root@mythbox:~$ sed -i 's/BOOT=local/BOOT=nfs/'  /etc/initramfs-tools/initramfs.conf
root@mythbox:~$ /usr/sbin/mkinitramfs -o /boot/initrd.img-2.6.26-1-686_netboot
</pre>
<p>Now just copy the /boot/vmlinuz-2.6.26-1-686 and /boot/initrd.img-2.6.26-1-686_netboot to /var/lib/tftpboot/ on the TFTP server.</p>
<p>Last step for the TFTP server is to create a config file for our mythbox. If you dont create one specifically for it, it will instead boot the network installer as mentioned above. Create the file /var/lib/tftpboot/pxelinux.cfg/01-$(hardware ethernet address). Including the hardware address in the file name binds that config to the particular workstation we are working on today. In my case, the file name is 01-00-19-db-4a-6a-0e.</p>
<pre class="brush: plain;">
LABEL linux
KERNEL vmlinuz-2.6.26-1-686
APPEND root=/dev/nfs initrd=initrd.img-2.6.26-1-686_netboot nfsroot=192.168.1.108:/srv/nfs/mythbox.pixelchaos.net ip=dhcp rw
</pre>
<p>Now that our TFTP server is up and running we will next need to configure a DHCP server to provide IP addresses to netboot clients, as well as point them to the TFTP server to continue the boot process.</p>
<pre class="brush: plain;">
root@dhcp:~$ apt-get install dhcp3-server
</pre>
<p>That will install the DHCP service for you. Now we just need to add one little section to /etc/dhcp3/dhcpd.conf for the workstation we are going to netboot.</p>
<pre class="brush: plain;">
host mythbox {
hardware ethernet 00:19:db:4a:6a:0e;
fixed-address mythbox.pixelchaos.net;
filename &quot;pxelinux.0&quot;;
next-server 192.168.1.115;
}
</pre>
<p>host mythbox: mythbox is just the descriptive name for this configuration block .You can use any name you like.<br />
hardware ethernet 00:19:db:4a:6a:0e: This is the hardware ethernet address of the workstation we are netbooting.<br />
fixed-address mythbox.pixelchaos.net: This tells the DHCP server what address to assign the mythbox. You can use a FQDN (if its resolvable!) or an IP address.<br />
filename &#8220;pxelinux.0&#8243;: This is the PXE boot loader file that we installed onto our TFTP server earlier.<br />
next-server 192.168.1.115: This is the IP address of our TFTP server. It tells the mythbox where the &#8220;next server&#8221; is after it gets its IP address from the DHCP server. The &#8220;next server&#8221; can be any machine on the network. It can even be the same one running DHCP.</p>
<p>Once all that is done, restart your DHCP server.</p>
<pre class="brush: plain;">
root@dhcp:~$ /etc/init.d/dhcp3-server restart
</pre>
<p>Now for the third piece of the puzzle, our NFS root filesystem. You&#8217;ll first need to create a directory to share.</p>
<pre class="brush: plain;">
root@nfs:~$ mkdir /srv/nfs/mythbox.pixelchaos.net
</pre>
<p>Now add that directory to /etc/exports so that it gets shared via NFS with this line:</p>
<pre class="brush: plain;">
/srv/nfs/mythbox.pixelchaos.net mythbox(rw,async,no_root_squash)
</pre>
<p>The rw, async, and no_root_squash options are important. Dont omit them. At this point we can reload all our NFS exports to active this new share point.</p>
<pre class="brush: plain;">
root@nfs:~$ exportfs -rv
</pre>
<p>At this point the entire TFTP, DHCP, and NFS parts of the environment are ready to go. Now we will migrate our existing installation of Linux from the mythbox onto its new nfsroot. First we make a directory to mount the NFS share on and then mount it.</p>
<pre class="brush: plain;">
root@mythbox:~$ mkdir /mnt/nfs
root@mythbox:~$ mount -t nfs -o nolock 192.168.1.108:/srv/nfs/mythbox.pixelchaos.net /mnt/nfs
</pre>
<p>Now we run a cp command on every locally mounted partition, as well as /dev. On my mythbox it looked like this:</p>
<pre class="brush: plain;">
root@mythbox:~$ cp -axv /. /mnt/nfs/.
root@mythbox:~$ cp -axv /boot/. /mnt/nfs/boot/.
root@mythbox:~$ cp -axv /home/. /mnt/nfs/home/.
root@mythbox:~$ cp -axv /dev/. /mnt/nfs/dev/.
</pre>
<p>The last thing to do is edit two files that we copied up to /mnt/nfs. The first is /mnt/nfs/etc/network/interfaces. You&#8217;ll need to remove any lines that bring the interface up automatically. You want to remove anything like &#8220;allow-hotplug eth0&#8243; and just leave a single line like &#8220;iface eth0 inet dhcp&#8221;. The network interface will have already been brought up by netboot normally and leaving in any &#8220;hotplug&#8221; or &#8220;auto&#8221; lines will bring it up again, which has the effect of destroying it.</p>
<p>Now we remove all the old filesystems from /mnt/nfs/etc/fstab so that it looks like this:</p>
<pre class="brush: plain;">
# /etc/fstab: static file system information.
#
# &lt;file system&gt; 		&lt;mount point&gt;   	&lt;type&gt;  &lt;options&gt;       &lt;dump&gt;  &lt;pass&gt;
/dev/nfs        /               nfs     defaults 0 0
none            /tmp            tmpfs   defaults 0 0
none            /var/run        tmpfs   defaults 0 0
none            /var/lock       tmpfs   defaults 0 0
none            /var/tmp        tmpfs   defaults 0 0
none            /media          tmpfs   defaults 0 0
</pre>
<p>That should be it. Now just set the mythbox to use network booting in its BIOS and reboot.</p>
<p>Cool, huh? :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelchaos.net/2009/02/15/diskless-booting-with-pxe-and-nfs/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>VLAN Bridging in Xen</title>
		<link>http://www.pixelchaos.net/2008/07/16/vlan-bridging-in-xen/</link>
		<comments>http://www.pixelchaos.net/2008/07/16/vlan-bridging-in-xen/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 00:47:22 +0000</pubDate>
		<dc:creator>jcl</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Xen]]></category>

		<guid isPermaLink="false">http://www.pixelchaos.net/?p=53</guid>
		<description><![CDATA[Recently I came upon the need to do all my network routing and firewalling inside a Xen domU. I am not the first to do this but I thought I&#8217;d do a little write up on it to help others trying to accomplish the same thing in Debian.
The idea here is to end up with [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I came upon the need to do all my network routing and firewalling inside a Xen domU. I am not the first to do this but I thought I&#8217;d do a little write up on it to help others trying to accomplish the same thing in Debian.</p>
<p>The idea here is to end up with (at least) two VLANs on the network with the dom0 and domU&#8217;s being able to choose one or both networks on which to exist. In the case of both, you can set up a handy domU firewall/gateway :)</p>
<p><a href='http://www.pixelchaos.net/wp-content/uploads/2008/07/xen_vlans.png'><img src="http://www.pixelchaos.net/wp-content/uploads/2008/07/xen_vlans-300x226.png" alt="" title="xen_vlans" width="300" height="226" class="aligncenter size-medium wp-image-54" /></a></p>
<p>As you can see from the diagram above, we will end up with three bridges in the dom0 with all the appropriate glue to tie everything together. Best of all, this is all assembled on the fly during bootup.</p>
<p><span id="more-53"></span></p>
<p>Now, you obviously need to have a Xen dom0 set up and running properly. Once you are at that point, adding VLAN bridging is fairly straightforward:</p>
<p>First we need to install the vlan package to get the tools for manipulating vlans. Crazy, huh?</p>
<pre class="brush: plain;">apt-get install vlan</pre>
<p>Now we set up the interfaces we will need in /etc/network/interfaces. The seasoned admins out there will note that we only bring up the eth0 interface automatically but leave it unconfigured. It will not have an IP or any of the other usual information. The other two (VLAN) interfaces are defined but are NOT brought up during boot. This is important!</p>
<p>In this example the “vlan100″ interface is the replacement for your old “eth0″ interface. Its the interface you’ll be able to reach the dom0 on from the internal VLAN. The “vlan99″ interface is defined but is left unconfigured since there will be no publicly routeable path to the dom0.</p>
<pre class="brush: plain;">auto eth0
iface eth0 inet manual
        pre-up ifconfig $IFACE up
        post-down ifconfig $IFACE down

iface vlan99 inet manual
        mtu 1500
        vlan_raw_device eth0

iface vlan100 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        dns-nameservers 192.168.1.254
        dns-search pixelchaos.net
        mtu 1500
        vlan_raw_device eth0</pre>
<p>Now we create a new network script for xen located at /etc/xen/scripts/network-multi:</p>
<pre class="brush: plain;">#!/bin/sh
#============================================================================
# Xen vlan bridge start/stop script.
# Xend calls a network script when it starts.
# The script name to use is defined in /etc/xen/xend-config.sxp
# in the network-script field.
#
# This script creates multiple bridges to segregate individual domUs to
# separate VLANs. Customize to fit your needs.
#
# Usage:
#
# network-multi (start|stop|status)
#
#============================================================================

dir=$(dirname &quot;$0&quot;)

##
# To make the tagged interface available to some DomUs, create the default
# bridge. Comment this out to only make vlan-based bridges available.
&quot;$dir/network-bridge&quot; &quot;$@&quot; vifnum=0 netdev=eth0 bridge=&quot;xbr_trunk&quot;

# Once the &quot;normal&quot; bridge is active, bring up the vlan interfaces.
# They will be attached to the virtual eth0 interface, and not the
# physical one.
ifup vlan99
ifup vlan100

# Create any vlan-based briges.
&quot;$dir/network-bridge&quot; &quot;$@&quot; vifnum=1 bridge=&quot;xbr_vl99&quot; netdev=&quot;vlan99&quot;
&quot;$dir/network-bridge&quot; &quot;$@&quot; vifnum=2 bridge=&quot;xbr_vl100&quot; netdev=&quot;vlan100&quot;

# bring up the interfaces again? why do we need to do this? they should have been brought back up by the previous network-bridge call…
ip link set vlan100 up
route add default gw 192.168.1.1 vlan100</pre>
<p>That script basically just calls the standard “network-bridge” script supplied with Xen three times &#8211; once for each VLAN we are setting up. You’ll notice some interesting bits at the end &#8211; We call “ip link” and “route” to bring the vlan100 interface up again. I’m not sure yet why the previous “network-bridge” call doesnt do that on its own… it should as far as I know but I havent dug into why it doesnt. This is just a quick hack to bring “vlan100″ back up again and fix the routes.</p>
<p>Go ahead and add the call to that script in the place of network-bridge in /etc/xen/xend-config.sxp.</p>
<p>Now we need to do one final thing to another Xen script. By default, the xen-network-common.sh script calls “ifdown” directly to take an interface down. Unfortunately, this has the undesirable side effect of destroying any VLANs associated with that interface. This causes all kinds of problems when we call our “network-multi” script so we need to patch /etc/xen/scripts/xen-network-common.sh with the following section:</p>
<pre class="brush: plain;"># do not call ifdown directly
  ifdown()  {
    ip addr flush $1
    ip link set $1 down
    true
  }</pre>
<p>To see exactly where that chunk of code goes you can download my already modified script <a href='http://www.pixelchaos.net/wp-content/uploads/2008/07/xen-network-common.sh'>here</a>, or get a diff <a href='http://www.pixelchaos.net/wp-content/uploads/2008/07/xen-network-common.patch'>here</a> if you prefer.</p>
<p>After youve done all that, reboot your dom0. You should now be up and running on the vlan100 interface. The output of &#8220;brctl show&#8221; should show this:</p>
<pre class="brush: plain;">root@atlas:~# brctl show
bridge name  bridge id          STP enabled    interfaces
xbr_trunk    8000.feffffffffff  no             vif0.0
                                               peth0
xbr_vl100    8000.feffffffffff  no             vif0.2
                                               pvlan100
xbr_vl99     8000.feffffffffff  no             vif0.1
                                               pvlan99</pre>
<p>If so, you should be all ready to go. Now edit the vif line in your config file for a given domU to link its ethernet interface to a bridge. My domU firewall is linked to two bridges so it looks like this:</p>
<pre class="brush: plain;">vif= [ 'mac=00:16:3E:44:F9:9C, bridge=xbr_vl99', 'mac=00:16:3E:41:16:51, bridge=xbr_vl100' ]</pre>
<p>Thats it! Easy, huh?</p>
<p>Many, many thanks go to <a href="http://mike.neir.org">Mike Neir</a> for holding my hand through figuring this all out since he&#8217;d already set up a functional system that is very similar. Thanks also go to <a href="http://www.firstserved.net/blog/2007/07/19/bridging-vlan-interfaces-in-xen/trackback">firstserved.net</a> for the ifdown patch and <a href="http://renial.net/weblog/2007/02/27/xen-vlan/trackback">renial.net</a> for other ideas on ways to set up VLAN bridging in Xen.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelchaos.net/2008/07/16/vlan-bridging-in-xen/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
