<?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>delx &#187; linux</title>
	<atom:link href="http://delx.net.au/blog/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://delx.net.au/blog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 13 Apr 2012 14:05:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>OpenWRT and Guest Networks on the Netgear WNDR3700</title>
		<link>http://delx.net.au/blog/2011/06/openwrt-and-guest-networks-on-the-netgear-wndr3700/</link>
		<comments>http://delx.net.au/blog/2011/06/openwrt-and-guest-networks-on-the-netgear-wndr3700/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 03:45:37 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[openwrt]]></category>
		<category><![CDATA[voip]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=283</guid>
		<description><![CDATA[In my house I have Debian Linux running on an old laptop acting as my router with a Netgear WNDR3700 acting as an access point (WAN port on this is unused). The AP is configured with WPA2 security, but recently I wanted to connect my Nintendo DS to the wifi network. Now the Netgear has [...]]]></description>
			<content:encoded><![CDATA[<p>In my house I have Debian Linux running on an old laptop acting as my router with a Netgear WNDR3700 acting as an access point (WAN port on this is unused). The AP is configured with WPA2 security, but recently I wanted to connect my Nintendo DS to the wifi network. Now the Netgear has guest networks, which is pretty much what I wanted, but it only allows the guest wifi access to the WAN port, which was useless to me. I also wanted to be able to conveniently enable and disable the insecure network with a button on the access point. Knowing that the hardware supported what I wanted to do, and having had good experiences with <a href="http://openwrt.org">OpenWRT</a> on another router in the past, I set out to see if I could make it work.</p>
<p><span id="more-283"></span></p>
<p>Now the Netgear factory firmware actually is a heavily stripped down old version of OpenWRT. After reading a few of forum posts and wiki pages I decided that I should go for a bleeding edge snapshot version of OpenWRT (r27153). It&#8217;s all working very well now :)</p>
<h4>Installation</h4>
<p>First thing, I grabbed <tt>openwrt-ar71xx-generic-wndr3700-squashfs-factory.img</tt> from the website and flashed it onto the router using the stock firmware&#8217;s upgrade page. This process went smoothly and rebooted the router. I then used telnet to connect and was prompted to set a password. That disabled telnetd and enables the dropbear ssh server. I also put an ssh public key into <tt>/etc/dropbear/authorized_keys</tt>. So far so good.</p>
<p>OpenWRT uses a squashfs as the base read-only filesystem, with jffs2 set up as an overlay filesystem so you can write to anywhere. You can use the builtin <tt>opkg</tt> package manager to install a bunch of useful software beyond what is built in. Currently I have 2.3M used with 4.2M free :)</p>
<p>I didn&#8217;t bother installing a web interface, instead preferring to do all the configuration using the UCI config files in <tt>/etc/config</tt>. See the <a href="http://wiki.openwrt.org/doc/uci">UCI docs</a> for a description of what to put in all these files. Whenever you start a service, eg dnsmasq using the <tt>/etc/init.d/dnsmasq</tt> script, the appropriate UCI files are read, a temporary native config file for the service is created (if appropriate) and any necessary command line args are generated to start the service.</p>
<h4>Syslog</h4>
<p>If you&#8217;re trying to debug something, you can view the syslog on the device using the <tt>logread</tt> command. The <tt>logger</tt> command will echo its arguments to syslog.</p>
<h4>Wireless Setup</h4>
<p>Most of the <tt>/etc/config/wireless</tt> settings are automatically detected. Just set the encryption to psk2 (WPA2 AES) and put in your preferred passphrase and ssid.</p>
<p>The radios on this device support multiple SSIDs. Each of these shows up as a separate network interface in Linux. I chose &#8216;guest&#8217; as the name for this interface.</p>
<pre>
config wifi-iface
  option device radio0
  option network guest
  option mode ap
  option wmm 0
  option encryption none
  option ssid 'your-guest-ssid'
</pre>
<p>Quick note, I discovered that leaving wmm (Wireless MultiMedia extensions?) enabled (the default) made SIP VoIP calls from my Nokia wifi clients unusable. It&#8217;s easy to disable as seen above.</p>
<h4>Firewall (iptables)</h4>
<p>Now we have our guest wifi network interface, lets set up some firewall rules to isolate it from the main lan.</p>
<p>I&#8217;m not using the WAN port on my WNDR3700. There are three interfaces that are relevant. The ethernet switch and my main wifi are both bridged as &#8216;lan&#8217;. This network is served by DHCP and DNS from my Debian router. It is 192.168.1.0/24. I also have the &#8216;guest&#8217; network, which is not bridged, and gets DHCP and DNS from dnsmasq on the WNDR3700, it uses 192.168.2.0/24. dnsmasq is set to forward DNS requests onto my main router and to explicitly ignore the &#8216;lan&#8217; interface.</p>
<p>The firewall policy is to disallow everything on the guest network except:</p>
<ul>
<li>ICMP</li>
<li>DHCP/DNS requests to dnsmasq on the WNDR3700</li>
<li>Packets from 192.168.2.0/24 not addressed to 192.168.0.0/16</li>
</ul>
<p>That last rule ensures that anything coming from the guest network must be using one of the expected addresses, and also that the guest network cannot send packets to hosts on my main lan. By default OpenWRT allows all related,established packets using Linux iptables&#8217; conntrack module.</p>
<p>Here&#8217;s the complete firewall config I&#8217;m using: <a href="/blog/wp-content/uploads/2011/06/etc_config_firewall.txt"><tt>/etc/config/firewall</tt></a>.</p>
<h4>Routing</h4>
<p>My Debian router also needs to know how to route back to the guest wlan subnet.</p>
<pre>
# route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.3
</pre>
<p>This can be put into <tt>/etc/network/interfaces</tt> as a post-up line. It tells the Debian router that whenever it needs to forward traffic from the internet back to the guest wlan it should do so through 192.168.1.3. This is the address of my WNDR3700.</p>
<h4>Cron and Button events</h4>
<p>I wanted to be able to turn the guest network on and off with the push of a button. I also wanted it to automatically disable itself each night at 3am if I forgot to turn it off.</p>
<p>First thing was to write a simple <a href="/blog/wp-content/uploads/2011/06/root_guest-wifi.txt">/root/guest-wifi</a> script to enable/disable the guest wifi network from the command line. Then I&#8217;d hook this up to the button hotplug system and cron.</p>
<p>Cron is installed but not enabled by default:</p>
<pre>
cat &gt; /etc/crontabs/root &lt;&lt;EOT
# m h  dom mon dow   command
  0 3   *   *   *     /root/guest-wifi disable
EOT
ln -s /etc/crontabs/root /etc/crontab
/etc/init.d/cron enable
/etc/init.d/cron start
</pre>
<p>Finally, set up the push button:</p>
<pre>
mkdir /etc/hotplug.d/button
cat &gt; /etc/hotplug.d/button/guest-wifi-toggle &lt;&lt;EOT
#!/bin/sh
if [ "$BUTTON" = "BTN_2" -a "$ACTION" = "pressed" ]; then
  /root/guest-wifi toggle
fi
EOT
chmod +x /etc/hotplug.d/button/guest-wifi-toggle
</pre>
<h4>System upgrades</h4>
<p>You can update and install new packages with opkg, however at some point you may want to upgrade the kernel. Also if you&#8217;re using the squashfs images, anything you upgrade is taking up valuable space on the squashfs and the jffs2 overlay.</p>
<p>OpenWRT has a neat solution: <a href="http://wiki.openwrt.org/doc/howto/generic.sysupgrade">sysupgrade</a>. Always make sure to add any files that you want to keep across upgrades to the <tt>/etc/sysupgrade.conf</tt> file. Any files or directories listed here will be preserved by sysupgrade.</p>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2011/06/openwrt-and-guest-networks-on-the-netgear-wndr3700/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Encrypted file systems on Debian/Ubuntu Linux</title>
		<link>http://delx.net.au/blog/2009/08/encrypted-file-systems-on-debianubuntu-linux/</link>
		<comments>http://delx.net.au/blog/2009/08/encrypted-file-systems-on-debianubuntu-linux/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 15:06:57 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[crypto]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=179</guid>
		<description><![CDATA[Recently I set up an encrypted file system so I could do rsync backups to a secured location. What you end up with is a mountable file system that you can use to securely store data. Debian offers an easy way to set up encrypted file systems using the LUKS standard with the cryptsetup package. [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I set up an encrypted file system so I could do rsync backups to a secured location. What you end up with is a mountable file system that you can use to securely store data. Debian offers an easy way to set up encrypted file systems using the LUKS standard with the cryptsetup package. You&#8217;ll need to enter a decryption passphrase to mount the volume whenever the system boots.</p>
<p><span id="more-179"></span></p>
<h4>Package installation</h4>
<p>Install the required packages:</p>
<pre># aptitude install e2fsprogs cryptsetup</pre>
<h4>Partitioning</h4>
<p>Use your favourite partitioning tool, for example <tt>fdisk</tt> or <tt>cfdisk</tt> to set aside a whole partition with enough space to store your data.</p>
<h4>Erase</h4>
<p>This step is optional. For complete security you want the contents of the disk to be random before you start using it. Use the <tt>badblocks</tt> tool to do this.</p>
<pre>
# badblocks -c 10240 -s -w -t random -v /dev/sdX9
</pre>
<h4>Format</h4>
<p>The <tt>luksformat</tt> tool will format a partition to be used with LUKS (Linux Unified Key Setup) and then create a filesystem on it.</p>
<pre># luksformat -t ext3 /dev/sdX9</pre>
<h4>Mounting Manually</h4>
<p>First use cryptsetup to create a device file:</p>
<pre># cryptsetup luksOpen /dev/sdX9 cryptofoo</pre>
<p>You can now mount the device from /dev/mapper/cryptofoo:</p>
<pre># mount /dev/mapper/cryptofoo /mnt</pre>
<p>When you&#8217;re done, unmount and then remove the cryptofoo device.</p>
<pre># umount /mnt; cryptsetup luksClose cryptofoo</pre>
<h4>Mount on Boot</h4>
<p>Now all that remains is to add one line in each of crypttab and fstab</p>
<p>Add this line to <tt>/etc/crypttab</tt>:</p>
<pre>myname /dev/sdX9 none luks</pre>
<p>The <tt>crypttab</tt> file is examined by the system during boot. Each line maps a real encrypted device file (<tt>/dev/sdX9</tt>) to a virtual decrypted device file (<tt>/dev/mapper/myname</tt>). Once you&#8217;ve added done this run the following command to actually set up the mapping:</p>
<pre># /etc/init.d/cryptdisks restart</pre>
<p>Now you can set up that virtual device file to be mounted like any other. For example, the following command would mount your filesystem:</p>
<pre># mount /dev/mapper/myname /mnt</pre>
<p>Note that you should probably use partition UUIDs (<tt>UUID=XXXXX</tt>) in place of device file names (<tt>/dev/sdX9</tt>) in your <tt>crypttab</tt> for a more robust system. The easiest way to find these is by running:</p>
<pre># ls -l /dev/disks/by-uuid</pre>
<p>Add a line like this to <tt>/etc/fstab</tt></p>
<pre>/dev/mapper/myname /path/to/mountpoint ext3 defaults 0 2</pre>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2009/08/encrypted-file-systems-on-debianubuntu-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apple Keyboard on Linux</title>
		<link>http://delx.net.au/blog/2009/04/apple-keyboard-on-linux/</link>
		<comments>http://delx.net.au/blog/2009/04/apple-keyboard-on-linux/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 06:20:11 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=159</guid>
		<description><![CDATA[The Apple aluminium keyboards are very nice. I recently bought one for an Ubuntu Linux machine, and it requires some special configuration to work as expected. This post describes how to fix the function keys and swap command (windows or &#8216;super&#8217;) keys with the alt (or option) keys. This command will fix the function keys, [...]]]></description>
			<content:encoded><![CDATA[<p>The Apple aluminium keyboards are very nice. I recently bought one for an Ubuntu Linux machine, and it requires some special configuration to work as expected.</p>
<p>This post describes how to fix the function keys and swap command (windows or &#8216;super&#8217;) keys with the alt (or option) keys.</p>
<p><span id="more-159"></span></p>
<p><img src="http://delx.net.au/blog/wp-content/wp-uploads/2009/04/apple_aluminium_keyboardcompare.jpg" alt="Apple Aluminium Keyboard" width="400" height="292" class="size-full wp-image-160" /></p>
<p>This command will fix the function keys, it saves you pressing fn-F1 whenever you want F1. The first command is for older kernels, the second is for version 2.6.28 or later.</p>
<pre>
# echo 2 > /sys/module/hid/parameters/pb_fnmode
# echo 2 > /sys/module/hid_apple/parameters/fnmode
</pre>
<p>Then add that line to your <tt>/etc/rc.local</tt> file, somewhere before the <tt>exit 0</tt> at the end, so that it gets run on startup.</p>
<p>Next to swap the Command/Alt keys using xmodmap. I&#8217;m aware you can do this from the Gnome Keyboard Settings panel, but I&#8217;ve found this method works better. Particularly when combined with <a href="http://synergy2.sf.net">synergy</a>.</p>
<p>Create a file called <tt>~/.xmodmaprc</tt> with this inside:</p>
<pre>
clear mod1
keycode 115 = Alt_L
keycode 116 = Alt_R
keycode 64 = Super_L
keycode 113 = Super_R
add mod1 = Alt_L Alt_R
</pre>
<p>On another computer I&#8217;ve found this worked:</p>
<pre>
clear mod1
keycode 133 = Alt_L
keycode 134 = Alt_R
keycode 64 = Super_L
keycode 108 = Super_R
add mod1 = Alt_L Alt_R
</pre>
<p>Now run to activate the new keys, run:</p>
<pre>$ xmodmap ~/.xmodmaprc</pre>
<p>Don&#8217;t forget to add it to your list of startup programs. If you&#8217;re using Gnome, look at System->Preferences->Startup Applications<br />
Otherwise you can just add it to <tt>~/.xsession</tt></p>
<p>To find the keycodes above I used the <tt>xev</tt> program. Try running it from a console. It shows you all X11 events that the xev window receives, including key presses/releases.</p>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2009/04/apple-keyboard-on-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

