<?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>Technically  Amusing &#187; network</title>
	<atom:link href="http://eison.net/tag/network/feed/" rel="self" type="application/rss+xml" />
	<link>http://eison.net</link>
	<description>Info, rants, and other techinical geekery (no, that&#039;s not a real word)</description>
	<lastBuildDate>Tue, 06 Mar 2012 01:30:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Cisco ASA: AnyConnect for phone using self-signed certificates for authentication</title>
		<link>http://eison.net/2012/02/cisco-asa-anyconnect-for-phone-using-self-signed-certificates-for-authentication/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cisco-asa-anyconnect-for-phone-using-self-signed-certificates-for-authentication</link>
		<comments>http://eison.net/2012/02/cisco-asa-anyconnect-for-phone-using-self-signed-certificates-for-authentication/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 02:23:47 +0000</pubDate>
		<dc:creator>Ross Eison</dc:creator>
				<category><![CDATA[asa]]></category>
		<category><![CDATA[cisco]]></category>
		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://eison.net/?p=221</guid>
		<description><![CDATA[Yeah, I know the title is pretty boring, but I wanted it to be clear what this one is all about, especially if you&#8217;re looking specifically for something like this. So, here&#8217;s the deal: Cisco 99xx and 79xx phones out on the internet somewhere connecting back to an ASA over an SSL tunnel to register [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah, I know the title is pretty boring, but I wanted it to be clear what this one is all about, especially if you&#8217;re looking specifically for something like this.</p>
<p>So, here&#8217;s the deal: Cisco 99xx and 79xx phones out on the internet somewhere connecting back to an ASA over an SSL tunnel to register with an internal network&#8217;s Call Manager, using only self-signed certificates. To me, this is the best option, rather than having users try to type usernames and passwords into the phone interface. For some users, that really is just too much to ask. This method makes it easy on them, and still gives the ASA administrator and Call Manager administrator the ability to prevent a stolen or misused phone from connecting to the network.<br />
<span id="more-221"></span><br />
This configuration absolutely depends on a few things:</p>
<ul>
<li>Working Call Manager that supports VPN configurations for phones. I have no idea what licenses or versions are required.</li>
<li>Working ASA, with it&#8217;s outside interface connected to the internet. This doesn&#8217;t work without internet access.</li>
<li>ASA is licensed specifically for &#8220;AnyConnect for phone&#8221;. <strong>show version</strong>, as well as some other commands, will tell you which features are enabled.</li>
</ul>
<p>Once those items are out of the way, the configuration for the ASA is pretty simple, as long as you understand the basics. This configuration is for code version 8.4, but 8.0+ is very similar. There are a few keywords that are different, so type slowly, rather than just bulk copy-and-paste.</p>
<p>A few things are happening here:</p>
<ul>
<li>generating keys to generate a self-signed certificate to share with the Call Manager</li>
<li>configuring a webvpn group-policy and tunnel-group that will allow the phone to connect to a very specific URL and present certificates for authentication</li>
<li>importing two certificates from Call Manager into the ASA</li>
</ul>
<p>If you read through the configuration example, my notes should explain each step. I also refer to a couple of Cisco documents that were very helpful.</p>
<pre class="brush: plain; collapse: true; light: false; title: ; toolbar: true; notranslate">
! based on this cisco.com ASA AnyConnect for Phone configuration example:
! https://supportforums.cisco.com/docs/DOC-9124
! http://www.cisco.com/en/US/products/ps6120/products_configuration_example09186a00808efbd2.shtml

! generate crypto keypair for ASA
crypto key generate rsa label ssl_vpn_key modulus 1024

! create trustpoint and enroll with the self-signed key above
crypto ca trustpoint phone_ssl_vpn_trustpoint
 enrollment self
 fqdn ac-phone.your-domain-here.com
 subject-name CN=ac-phone.your-domain-here.com
 keypair ssl_vpn_key
 exit

crypto ca enroll phone_ssl_vpn_trustpoint noconfirm
ssl trust-point phone_ssl_vpn_trustpoint outside

! export the certificate trustpoint to import into CallManager
crypto ca export phone_ssl_vpn_trustpoint identity-certificate

! copy the anyconnect client to the ASA
copy tftp://&lt;tftp_server&gt;/anyconnect-win-3.0.5080-k9.pkg flash

! enable webvpn and select an image
webvpn
anyconnect image disk0:/anyconnect-win-3.0.5080-k9.pkg 1
enable outside
anyconnect enable

! create an IP pool not already in use and assign
ip local pool ac_phone_ip_pool_01 10.0.242.1-10.0.242.255 mask 255.255.255.0

! create group policy for phones
group-policy gp_anyconnect_phone internal
group-policy gp_anyconnect_phone attributes
 dns-server value 10.10.41.183 10.10.41.4
 vpn-tunnel-protocol ssl-client
 default-domain &lt; value your-domain-here.com &gt;
 address-pools value ac_phone_ip_pool_01

! permit interface ACL bypass for IPSec and SSL clients globally
sysopt connection permit-vpn

! create a certificate map to map the 'ac-phone' certificate to a specific
! tunnel-group: 'tg_anyconnect_phone' --&gt; 10
! this will be the cert the phone presents as a part of it's authentication.
! when presented, it'll trigger the use of the tunnel-group below.
crypto ca certificate map cm_anyconnect_phone 10
subject-name co ac-phone

! create a tunnel group and URL alias
tunnel-group tg_anyconnect_phone type remote-access
tunnel-group tg_anyconnect_phone general-attributes
 default-group-policy gp_anyconnect_phone
  username-from-certificate CN

tunnel-group tg_anyconnect_phone webvpn-attributes
 authentication certificate
 group-alias anyconnect-phone enable
 ! this URL has to exactly match what's in the CallManager config
 group-url https://name-or-ip-of-outside-int-of-asa/anyconnect-phone enable
 ! permit rules to determine which tunnel-group is used
 tunnel-group-map enable rules
 ! match the certificate map to the tunnel-group
 tunnel-group-map cm_anyconnect_phone 10 tg_anyconnect_phone

! configure nat exemption (no nat, nat 0) for phone address pool, version 8.3 and above
! https://supportforums.cisco.com/docs/DOC-11639, bug is fixed in later version of 8.3, 8.4
! http://tools.cisco.com/Support/BugToolKit/search/getBugDetails.do?method=fetchBugDetails&amp;bugId=CSCtf89372
object network obj_ac_phone_ip_pool_01
 ! subnet &lt;ac_phone_ip_pool_network&gt; &lt;ac_phone_ip_pool_netmask&gt;
 subnet 10.0.242.0 255.255.255.0

nat (INSIDE,OUTSIDE) source static any any destination static obj_ac_phone_ip_pool_01 obj_ac_phone_ip_pool_01

! create new trustpoints and import CallManager certificates
!
! IP phones that have MICs: 99xx
crypto ca trustpoint Cisco_Manufacturing_CA
 enrollment terminal
crypto ca authenticate Cisco_Manufacturing_CA
! &lt; paste Cisco_Manufacturing_CA pem &gt;

! IP phones that have CAPFs: 79xx
crypto ca trustpoint CAPF
 enrollment terminal
crypto ca authenticate CAPF
! &lt; paste Cisco_Manufacturing_CA pem &gt;
</pre>
<p>All of the configuration words that have underscores are my own and can be changed to anything you choose&#8211;as long as you&#8217;re consistent with them. I&#8217;ve tried to make a habit of using underscores for my configuration variables, since Cisco doesn&#8217;t use them in configuration keywords. I also like to use <strong>gp_</strong>, <strong>tg_</strong>, and other similar abbreviations so it&#8217;s really clear in my configurations which items are which based on their names alone.</p>
<p>This configuration absolutely works. In fact, we have our phones configured with a primary and secondary &#8220;concentrator&#8221; (ASA); if the primary doesn&#8217;t answer, the phone will automatically try to connect to the secondary.</p>
]]></content:encoded>
			<wfw:commentRss>http://eison.net/2012/02/cisco-asa-anyconnect-for-phone-using-self-signed-certificates-for-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I like free, so I like TACACS+</title>
		<link>http://eison.net/2012/02/i-like-free-so-i-like-tacacs/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=i-like-free-so-i-like-tacacs</link>
		<comments>http://eison.net/2012/02/i-like-free-so-i-like-tacacs/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 22:04:23 +0000</pubDate>
		<dc:creator>Ross Eison</dc:creator>
				<category><![CDATA[cisco]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[tacacs]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://eison.net/?p=194</guid>
		<description><![CDATA[Yes, I still like free stuff, even though I&#8217;m turning into a bit of a Mac fanboy. Ubuntu and I remain very close, just not as my daily (desktop) driver. I am leaning on Ubuntu as my new server platform at work, however, since it&#8217;s so much easier to count on than CentOS. And as [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, I <em>still</em> like free stuff, even though I&#8217;m turning into a bit of a Mac fanboy. Ubuntu and I remain very close, just not as my daily (desktop) driver.</p>
<p>I am leaning on Ubuntu as my new server platform at work, however, since it&#8217;s so much easier to count on than CentOS. And as I wrote last, TACACS+ authentication for network device administration is one of my current projects.</p>
<p>There are several pieces to that project,</p>
<ul>
<li>setting up two servers</li>
<li>configuring them the same</li>
<li>configuring TACACS+ user accounts that can&#8217;t login to the server</li>
<li>sync-ing the TACACS+ user accounts between servers, with one as primary</li>
<li>sync-ing the TACACS+ config file between servers</li>
</ul>
<p>but this post is only going to focus on getting TACACS+ installed on Ubuntu 11.10 server (64-bit) and the configuration file. In a later post, we&#8217;ll take a look at IOS, ASA, and NX OS configurations for AAA that I&#8217;ve found to work well. As always, &#8220;your mileage may vary&#8221;, but I&#8217;d love to know of any tricks or tips others might have. I&#8217;m definitely not claiming to have invented this stuff.</p>
<p>On to the installation!</p>
<p><span id="more-194"></span></p>
<p>With Ubuntu 11.10, the command line installation process is extremely complicated:</p>
<p><code>me@tacacs-server-1:~$ sudo aptitude install tacacs+</code></p>
<p>Ubuntu will install any required dependencies and will create a sample config file, <strong>/etc/tacacs+/tac_plus.conf</strong>. Generally speaking, I like to copy the original config file for safe keeping before I make any changes to it, so let&#8217;s do that before we move on.</p>
<p><code>me@tacacs-server-1:~$ sudo cp /etc/tacacs+/tac_plus.conf /etc/tacacs+/tac_plus.conf.orig</code></p>
<p>Whew! It felt good to be so responsible!</p>
<p>It&#8217;s also important to know that many Ubuntu servers/services have &#8220;config&#8221; files in <strong>/etc/default</strong> that set values or start-up parameters, so if we take a look there, we see that a file does exist for TACACS+ and it states which config file to use when the service starts:</p>
<p><code>me@tacacs-server-1:~$ more /etc/default/tacacs+<br />
# This is the configuration file for /etc/init.d/tacacs+<br />
# You can overwrite default arguments passed to the daemon here.<br />
# See man(8) tac_plus</p>
<p>DAEMON_OPTS="-C /etc/tacacs+/tac_plus.conf"<br />
me@tacacs-server-1:~$</code></p>
<p>The default config file location is good with me, so I&#8217;ll leave that file as it is. It&#8217;s also important to know that <em>root</em> is the only user who can do anything with the TACACS+ config file, which is a critical part of securing this service.</p>
<p><code>me@tacacs-server-1:~$ ls -la /etc/tacacs+/<br />
total 16<br />
drwxr-xr-x  2 root root 4096 2012-01-18 14:25 .<br />
drwxr-xr-x 83 root root 4096 2012-02-05 23:19 ..<br />
-rw-------  1 root root 3348 2012-02-05 23:12 tac_plus.conf<br />
-rw-------  1 root root 1413 2012-01-18 14:25 tac_plus.conf.orig<br />
me@tacacs-server-1:~$</code></p>
<p>My goal, when configuring these servers, is to have user accounts that are local Linux accounts&#8211;so all user accounts can be administered in one place&#8211;but I don&#8217;t want those Linux users to be able to login to the server locally or via ssh. The config file below reflects Linux accounts, though you should note that it&#8217;s possible to create user accounts in a separate config file, that are <strong>not</strong> Linux user accounts. That wasn&#8217;t a part of my plan, so I&#8217;m not going to cover it.</p>
<p>Here&#8217;s my config file:</p>
<pre class="brush: plain; collapse: true; light: false; title: ; toolbar: true; notranslate"># Created by Henry-Nicolas Tourneur(henry.nicolas@tourneur.be)
# See man(5) tac_plus.conf for more details

# Define where to log accounting data, this is the default.
#
accounting file = /var/log/tac_plus_acct.log

# This is the key that clients have to use to access Tacacs+
#
key = your_secret_key_here

# Use /etc/passwd file to do authentication
#
default authentication = file /etc/passwd

#
# ACLs that may be used to restrict users' access to certain hosts
#
acl = switch01_users_acl {
        # allow access to only one device, switch01
        permit = 10.10.10.10
}

#
# These tacacs+ user groups are not actually tied to the local
# Linux groups, but we'll use the same names here.
#
#
# &quot;level 3&quot; users, with no restrictions
#
group = l3_tacacs_users {
        default service = permit
        login = file /etc/passwd
        enable = file /etc/passwd
        service = exec {
                priv-lvl = 15
                }
}

#
# &quot;level 2&quot; users who cannot &quot;debug&quot; or &quot;config&quot;
#
group = l2_tacacs_users {
        default service = permit
        login = file /etc/passwd
        enable = file /etc/passwd
        service = exec {
                priv-lvl = 15
                }
        cmd = configure {
                deny &quot;.&quot;
                }
        cmd = debug {
                deny &quot;.&quot;
                }
}

#
# &quot;level 1&quot; users permitted to &quot;show&quot;, &quot;ping&quot;, &quot;telnet&quot;,
# &quot;exit&quot;, and &quot;quit&quot;
#
group = l1_tacacs_users {
        default service = deny
        login = file /etc/passwd
        enable = file /etc/passwd
        service = exec {
                priv-lvl = 15
                }
        cmd = show {
                permit &quot;.&quot;
        }
        cmd = ping {
                permit &quot;.&quot;
        }
        cmd = telnet {
                permit &quot;.&quot;
        }
        cmd = exit {
                permit &quot;^(&lt;cr&gt;)?$&quot;
        }
        cmd = quit {
                permit &quot;^(&lt;cr&gt;)?$&quot;
        }
}

#
# Users outside of Net-Ops group, probably restricted to specific hosts
# and specific commands.
#
group = switch01_users {
        default service = permit
        login = file /etc/passwd
        enable = file /etc/passwd
        service = exec {
                priv-lvl = 15
                }
        cmd = show {
                permit &quot;.&quot;
        }
        cmd = ping {
                permit &quot;.&quot;
        }
        cmd = exit {
                permit &quot;^(&lt;cr&gt;)?$&quot;
        }
        cmd = quit {
                permit &quot;^(&lt;cr&gt;)?$&quot;
        }
        acl = switch01_users_acl
}

#
# Assign Linux users to tacacs+ groups
#
user = dave {
        member = l3_tacacs_users
}

user = simon {
        member = l2_tacacs_users
}

user = theodore {
        member = l1_tacacs_users
}

user = alvin {
        member = switch01_users
}

# You can use feature like per host key with different enable passwords
#host = 127.0.0.1 {
#        key = test
#        type = cisco
#        enable = &lt;des|cleartext&gt; enablepass
#        prompt = &quot;Welcome XXX ISP Access Router \n\nUsername:&quot;
#}

# We also can define local users and specify a file where data is stored.
# That file may be filled using tac_pwd
#user = test1 {
#    name = &quot;Test User&quot;
#    member = staff
#    login = file /etc/tacacs/tacacs_passwords
#}

# We can also specify rules valid per group of users.
#group = group1 {
#       cmd = conf {
#               deny
#       }
#}

# Another example : forbid configure command for some hosts
# for a define range of clients
#group = group1 {
#       login = PAM
#       service = ppp
#       protocol = ip {
#               addr = 10.10.0.0/24
#       }
#       cmd = conf {
#               deny .*
#       }
#}

user = DEFAULT {
        login = PAM
        service = ppp protocol = ip {}
}

# Much more features are available, like ACL, more service compatibilities,
# commands authorization, scripting authorization.
# See the man page for those features.</pre>
<p>If you read through the comments, you can get a pretty good idea of what my goals are:</p>
<ul>
<li>modularity</li>
<li>at least 4 levels of user&#8211;level-3, level-2, level-1, and special cases</li>
<li>use the local Linux user database, rather than another config file with either clear-text passwords, or passwords I&#8217;d have to encrypt with <strong>tac_pwd</strong></li>
</ul>
<p>Though I&#8217;m not 100% positive, I believe that they order of the sections is very important. During my testing with ACLs, it seemed that ACLs had to come first, then groups, then users. I also didn&#8217;t have any luck with not assigning a user to a group and trying to assign an ACL to him.</p>
<p>This is a working config, though, tested on real Cisco equipment&#8211;IOS, ASA, and NX OS. And it&#8217;s free. Well, you do have to have internet access to read it, so not completely free, unless you&#8217;ve hacked your neighbor&#8217;s wireless, though you didn&#8217;t learn that from me.</p>
]]></content:encoded>
			<wfw:commentRss>http://eison.net/2012/02/i-like-free-so-i-like-tacacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu, Linksys WUSB600N v1, Dish DVR: whose @#$% idea was this?</title>
		<link>http://eison.net/2010/07/ubuntu-linksys-wusb600n-v1-dish-dvr-whose-idea-was-this/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ubuntu-linksys-wusb600n-v1-dish-dvr-whose-idea-was-this</link>
		<comments>http://eison.net/2010/07/ubuntu-linksys-wusb600n-v1-dish-dvr-whose-idea-was-this/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 23:47:48 +0000</pubDate>
		<dc:creator>Ross Eison</dc:creator>
				<category><![CDATA[htpc]]></category>
		<category><![CDATA[linksys]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://eison.net/?p=98</guid>
		<description><![CDATA[I love Ubuntu and give myself a little &#8220;mental hug&#8221; each day for making the switch from Windows to Linux. But, sometimes, the stuff I want/need to do in Linux just isn&#8217;t as obvious to me as I&#8217;d like; so, I beat my head against a wall trying to figure it out, until my wife [...]]]></description>
			<content:encoded><![CDATA[<p>I love Ubuntu and give myself a little &#8220;mental hug&#8221; each day for making the switch from Windows to Linux. But, sometimes, the stuff I want/need to do in Linux just isn&#8217;t as obvious to me as I&#8217;d like; so, I beat my head against a wall trying to figure it out, until my wife gives me that &#8220;walk away from it for awhile so you can maintain the little bit of sanity you have left&#8221; look. This particular situation is one of those.</p>
<p><strong>What I wanted to do:</strong> I have a Dish Network DVR in my living room that has an ethernet card in it, but I don&#8217;t have any ethernet wiring where it is. What I <strong>do</strong> have is an Ubuntu <a href="http://xbmc.org/" target="_blank">XBMC</a> <a href="http://en.wikipedia.org/wiki/Htpc target="_blank">HTPC</a> with an on-board ethernet card and a Linksys <a href="http://homesupport.cisco.com/en-us/wireless/lbc/WUSB600N?referrer=www.linksysbycisco.com target="_blank">WUSB600N</a> v1 (the version number is important here, I think), connected to a Linksys <a href="http://homesupport.cisco.com/en-us/wireless/lbc/WAP610N" target="_blank">WAP610N</a> AP (configured for 5GHz 802.11N only), so it stands to reason that I <em>should</em> be able to share the HTPC&#8217;s internet connection with the Dish DVR, right?</p>
<p><a class="floatbox" href="http://eison.net/wp-includes/images/posts/htpc/htpc.jpg" class="floatbox" rev="group:98" alt="Network Diagram"><img src="http://eison.net/wp-includes/images/posts/htpc/htpc_thumb.jpg" alt="Network Diagram" /></a></p>
<p>Ok, so it wasn&#8217;t. Twice. Once for Ubuntu 9.10 (Karmic) and once for 10.04 (Lucid).<br />
<span id="more-98"></span></p>
<p>The first thing all good Linux users have to learn is <em>just because it works auto-magically in Windows, doesn&#8217;t mean it works the same in Linux</em>. It stings a little, but it&#8217;s true. The good news is that there are lots of Linux super-geniuses out there to help and most believe in writing stuff down. If you&#8217;re willing to do some Google-ing, most Linux questions/problems can be answered relatively quickly. I had to do a bunch of that.</p>
<p><strong>Task #1: Get 5GHz 802.11n wireless working</strong><br />
When I first plugged my new WUSB600N into my Ubuntu HTPC, Ubuntu recognized it right away, though it couldn&#8217;t &#8220;see&#8221; my 5GHz network (WAP610N). It could see and connect to my 2.4GHz network (WRT54GL) with no problem, so I knew it was time to <a href="http://lmgtfy.com/?q=wusb600n+ubuntu+karmic" target="_blank">Google</a>. I found all kinds of stuff&#8211;using Windows drivers with NDIS, blacklisting, modprobe&#8211;and I tried them all, to the point of complete frustration. Nothing seemed to work, so I decided to install <a href="http://wicd.sourceforge.net/" target="_blank">Wicd</a> (and remove Network Manager), because I&#8217;d had some luck with it in the past.</p>
<p>Unfortunately, Wicd wasn&#8217;t the complete answer: it couldn&#8217;t <em>see</em> my 5GHz network, either, so I knew there was more I wasn&#8217;t doing. After looking through the logs in /var/log/messages and fumbling through more Google searches for <strong>wusb600n ubuntu 11n</strong>, I happened across some posts like <a href="http://ubuntuforums.org/showthread.php?t=1357303" target="_blank">this one</a> that said I needed to blacklist the <strong>rt2800usb</strong> driver. Once I&#8217;d done that, there were different log messages in /var/log/messages, this time saying that <strong>/etc/Wireless/RT3070STA/RT3070STA.dat</strong> couldn&#8217;t be read. So, I looked for it&#8211;the directory didn&#8217;t even exist! Now, I&#8217;m on to something!</p>
<p>Back to <a href="http://lmgtfy.com/?q=ubuntu+%20%2Fetc%2FWireless%2FRT3070STA%2FRT3070STA.dat" target="_blank">Google</a> again, and it looks like I&#8217;m definitely on the right track. I took the example file from <a href="http://swiss.ubuntuforums.org/showthread.php?p=9288229" target="_blank">this post</a>, and edited it for my network, including the SSID and PSK. Reboot, fingers crossed. Wait a sec&#8230;what&#8217;s that? Is that a 5GHz network? Yessssssssss! One thing I still don&#8217;t understand is that even though I specified all of that stuff in <strong>RT3070STA.dat</strong>, I still had to do the same in Wicd. I may look into that more later, but for now, it&#8217;s time to move on to Task #2.</p>
<p><strong>Task #2: Figure out how to give eth1 an IP address</strong><br />
Unlike Network-Manager (built-in with Ubuntu, Gnome), it <a href="http://wicd.sourceforge.net/moinmoin/FAQ/2interfaces" target="_blank">didn&#8217;t seem like Wicd has a facility to have two interfaces up at once</a>, so I had to figure out a way to give it an IP address outside of Wicd. I could have used /etc/network/interfaces, but since Wicd has the ability to let you run scripts before and after network connections are established, it seemed like a good idea to write a script with ifconfig commands in it to assign eth1&#8242;s address:</p>
<p><a class="floatbox" href="http://eison.net/wp-includes/images/posts/htpc/wicd.png" class="floatbox" rev="group:98" alt="Wicd"><img src="http://eison.net/wp-includes/images/posts/htpc/wicd_thumb.png" alt="Wicd" /></a></p>
<p><code>me@htpc:~$ more /etc/router_script<br />
#! /bin/sh</code></p>
<p><code># This script is run by the Wicd daemon after the PC boots<br />
# and connects the the WLAN using wlan0. Once run, eth1<br />
# has an IP address on another subnet and provides DHCP<br />
# addresses for that subnet. All packets are routed from<br />
# eth1 through wlan0.</code></p>
<p><code># give ethernet interface an IP address<br />
ifconfig eth1 172.16.5.1 netmask 255.255.255.252</code></p>
<p>I made my script executable</p>
<p><code>me@htpc:~$ sudo chmod 755 /etc/router_script</code></p>
<p>and after a reboot, I could see that both interfaces were up and had IP addresses.</p>
<p><strong>Task #3: Figure out how to give my DVR an IP address</strong><br />
Unfortunately for me, I can&#8217;t manually assign an IP address to my DVR, so I have to provide it one using DHCP. My router is already running dhcpd, but the request would have to go <em>through</em> my HTPC to get there, much like an ethernet-to-wireless bridge or <a href="http://www.dlink.com/products/?pid=333" target="_blank">wireless game adapter</a>; the problem is that I need for my HTPC to still be able to actively participate on my wireless network, not just bridge for my DVR.</p>
<p>I Google&#8217;d a bunch about this topic, too, and read and tried a bunch of stuff with <a href="http://www.linuxfoundation.org/collaborate/workgroups/networking/bridge" target="_blank">bridge-utils</a>, but could never make it work. Instead, I started thinking about my HTPC as more of a <em>router</em>, which made it a lot easier for me to find stuff about <a href="http://www.google.com/search?q=linux+router+dhcp" target="_blank">Linux routers and providing DHCP addresses</a>. Turns out, it was really easy to set up a second DHCP server on my HTPC that only serves addresses from <strong>eth1</strong>&#8211;that means only devices connected to that interface (my DVR) will ever get addresses. I read a good bit about using <strong>firestarter</strong>, and even tried it successfully, but I soon realized that for my purposes, it was over-kill. More on that later.</p>
<p>All I had to do to set up my new DHCP server in Ubuntu was<br />
<code>me@htpc:~$ sudo aptitude install dhcp3-server</code></p>
<p>After my install, I edited <strong>/etc/default/dhcp3-server</strong> to choose DHCP for only eth1, then edited <strong>/etc/dhcp3/dhcpd.conf</strong> for the network settings I wanted:<br />
<code>me@htpc:~$ more /etc/dhcp3/dhcpd.conf<br />
# DHCP configuration<br />
ddns-update-style interim;<br />
ignore client-updates;</p>
<p>subnet 172.16.5.0 netmask 255.255.255.252 {<br />
	option routers 172.16.5.1;<br />
	option subnet-mask 255.255.255.252;<br />
	option domain-name-servers 172.16.4.1;<br />
	option ip-forwarding off;<br />
	range dynamic-bootp 172.16.5.2 172.16.5.3;<br />
	default-lease-time 21600;<br />
	max-lease-time 43200;<br />
}</code></p>
<p>Note that I purposely picked a really small network mask, since I just needed a couple of usable IP addresses for that network. It would do no harm to pick something larger, like 255.255.255.0.</p>
<p>Since the DHCP server&#8217;s assigning a default router, I need to be sure that the router exists before dhcpd tries to hand out addresses. Calling the dhcp3-server init script again from my <em>router_script</em> is a good way to do that, so I added to it:</p>
<p><code># restart the DHCP server<br />
/etc/init.d/dhcp3-server restart</code></p>
<p>With the configuration done, I restarted the DHCP daemon and connected my DVR to my HTPC with a cross-over cable, then ran the broadband utility to see if it could get an address from dhcpd. Cool! That worked, but it says it&#8217;s not connected (to the Dish Network servers). Hmmm&#8230;guess there&#8217;s a Task #4, then.</p>
<p><strong>Task #4: Give the DVR access to the interwebs</strong><br />
Though the DVR has an address and a default gateway/router, that doesn&#8217;t mean that the HTPC is willing to let it&#8217;s traffic pass through it. For that, I need to get some help from <a href="http://en.wikipedia.org/wiki/Iptables" target="_blank">iptables</a>. As I mentioned a bit earlier, I actually installed <strong>firestarter</strong> during this process because it has <em>internet connection sharing</em> built-in, and can work with dhcpd&#8217;s scripts. What I didn&#8217;t like about it was that it seemed like &#8220;too much&#8221;, since all I really wanted to do was pass <em>all</em> traffic from one interface to another&#8211;I didn&#8217;t really want to <em>restrict</em> anything. So, I removed it and tried to do the same thing with <a href="https://wiki.ubuntu.com/UncomplicatedFirewall" target="_blank">ufw</a>. After fumbling around with that for awhile, it seemed again, that I was wasting my energy&#8211;ufw is really just an interface for iptables, so why not just learn enough iptables to do what I want?</p>
<p>By default, the Linux kernel doesn&#8217;t allow the forwarding of packets from one interface to another, but you can tell it to allow it using <a href="http://snipperoo.com/iptables_stuff/ubuntu_firewall.html" target="_blank">/etc/sysctl.conf</a>. Change one value and reboot.</p>
<p><code># Uncomment the next line to enable packet forwarding for IPv4<br />
net.ipv4.ip_forward=1</code></p>
<p>Now that <a href="http://en.wikipedia.org/wiki/Colonel_Sanders" target="_blank">the kernel</a> will let us forward packets from one interface to another (eth1 to wlan0), we need to tell iptables to accept the traffic into eth1 (filter table), as well as the return traffic to wlan0, back through to eth1 (nat table) Basically, wlan0 is a <a href="http://en.wikipedia.org/wiki/Network_address_translation" target="_blank">NAT</a> interface for whatever is behind eth1. We add to those two tables like this:</p>
<p><code>me@htpc:~$ sudo iptables --table nat --append POSTROUTING --out-interface wlan0 -j MASQUERADE<br />
me@htpc:~$ sudo iptables --append FORWARD --in-interface eth1 -j ACCEPT</code></p>
<p>Ok, cool: iptables is all set up, so I rebooted and checked to see if my DVR could find the interwebs. <a href="http://en.wikipedia.org/wiki/Lee_Corso" target="_blank">&#8220;Not so fast, my friend!&#8221;</a> Why doesn&#8217;t it work? The DVR has an address and I can ping it from the HTPC&#8230;gotta be something with iptables, then, so I checked using the command <strong>iptables &#8211;list</strong>.</p>
<p><code>me@htpc:~$ sudo iptables --list<br />
Chain INPUT (policy ACCEPT)<br />
target     prot opt source               destination</code>         </p>
<p><code>Chain FORWARD (policy ACCEPT)<br />
target     prot opt source               destination</code>        </p>
<p><code>Chain OUTPUT (policy ACCEPT)<br />
target     prot opt source               destination</code></p>
<p>My masquerade and forwarding are gone. If I run my two iptables commands again, <strong>iptables &#8211;list</strong> looks like this:</p>
<p><code>me@htpc:~$ sudo iptables --list<br />
Chain INPUT (policy ACCEPT)<br />
target     prot opt source               destination</code>        </p>
<p><code>Chain FORWARD (policy ACCEPT)<br />
target     prot opt source               destination<br />
ACCEPT     all  --  anywhere             anywhere</code>            </p>
<p><code>Chain OUTPUT (policy ACCEPT)<br />
target     prot opt source               destination</code></p>
<p>And if I &#8220;print&#8221; to STDOUT, I can see both:</p>
<p><code>me@htpc:~$ sudo iptables-save<br />
# Generated by iptables-save v1.4.4 on Sat Jul 10 19:16:47 2010<br />
*filter<br />
:INPUT ACCEPT [57221:27498502]<br />
:FORWARD ACCEPT [1163:76309]<br />
:OUTPUT ACCEPT [61462:49085429]<br />
COMMIT<br />
# Completed on Sat Jul 10 19:16:47 2010<br />
# Generated by iptables-save v1.4.4 on Sat Jul 10 19:16:47 2010<br />
*nat<br />
:PREROUTING ACCEPT [852:112868]<br />
:POSTROUTING ACCEPT [10:571]<br />
:OUTPUT ACCEPT [112:7142]<br />
-A POSTROUTING -o wlan0 -j MASQUERADE<br />
COMMIT<br />
# Completed on Sat Jul 10 19:16:47 2010</code></p>
<p>Seems to me that if I&#8217;ve already got this super-awesome script that Wicd calls once wlan0 connects, I should just be able to add my iptables stuff to it, so that every time my HTPC is booted the right rules will be in-place. The final version of my router_script looks like this:</p>
<p><code>e@htpc:~$ more /etc/router_script<br />
#! /bin/sh</code></p>
<p><code># This script is run by the Wicd daemon after the PC boots and connects<br />
# the the WLAN using wlan0. Once run, eth1 has an IP address on another<br />
# subnet and provides DHCP addresses for that subnet. All packets are<br />
# routed from eth1 through wlan0.</code></p>
<p><code># give ethernet interface an IP address<br />
ifconfig eth1 172.16.5.1 netmask 255.255.255.252</code></p>
<p><code># restart the DHCP server<br />
/etc/init.d/dhcp3-server restart</code></p>
<p><code># add needed rules to iptables<br />
iptables --table nat --append POSTROUTING --out-interface wlan0 -j MASQUERADE<br />
iptables --append FORWARD --in-interface eth1 -j ACCEPT</code></p>
<p>One last time, I checked my DVR: woo-hoo! It says &#8220;connected online&#8221; and I can manage it from the <a href="http://dish.sling.com/" target="_blank">dish.sling.com</a> website.</p>
<p>Now what? Guess I need to get a DVR with Slingbox built-in, or buy one of the add-ons. Donations will certainly be accepted.</p>
]]></content:encoded>
			<wfw:commentRss>http://eison.net/2010/07/ubuntu-linksys-wusb600n-v1-dish-dvr-whose-idea-was-this/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

