{"id":407,"date":"2007-12-28T21:41:37","date_gmt":"2007-12-29T02:41:37","guid":{"rendered":"http:\/\/blogs.n1zyy.com\/n1zyy\/2007\/12\/28\/geek-2\/"},"modified":"2007-12-28T21:41:37","modified_gmt":"2007-12-29T02:41:37","slug":"geek-2","status":"publish","type":"post","link":"https:\/\/blogs.n1zyy.com\/n1zyy\/2007\/12\/28\/geek-2\/","title":{"rendered":"Geek"},"content":{"rendered":"<p>We&#8217;ve been having a lot of intermittent network problems at home. Periodically, our Internet cuts out. At first I assumed it was our ISP&#8211;it&#8217;s no longer Adelphia (run by pharmacists), though&#8211;but subsequent research indicated that it wasn&#8217;t our ISP&#8217;s fault: our router was going down.<\/p>\n<p>My dad set it all up, so I wasn&#8217;t too sure how things went. I was pretty confident that we were just using a generic store-bought broadband router, though, so I found it strange that it would be drifting in and out. It turns out that I overlooked something about the router: it&#8217;s being held together with duct tape.<\/p>\n<p>I&#8217;d already been intrigued by OpenBSD&#8217;s <a href=\"http:\/\/www.openbsd.org\/faq\/pf\/\">pf<\/a>, so this seemed like a sign! I commissioned an old desktop system, loaded OpenBSD up on it, and went to work configuring it. OpenBSD was just more different from Linux than I expected. It asks you if you want to let OpenBSD use the whole hard drive. I said yes, and thought, &#8220;Wow, this is just as easy as Ubuntu!&#8221; But it turns out that this was just the first stage. After this, you have to set &#8220;disk labels,&#8221; which are sort of like partitions but ambiguously different. The syntax is obscure, the purpose is obscure, and so forth. Then I had to configure the network. NICs are named by the drivers they use, so instead of eth0 and eth1 (for <em>Eth<\/em>ernet), I have rl0 (Realtek) and dc0 (who knows).<\/p>\n<p>I was also extremely confused trying to set up routing. Long-term, it was going to be the router, but short-term, it needs to know about our existing router so that it can connect and download the requisite packages.<\/p>\n<p>So I <em>finally<\/em> got it all set up. I also installed MySQL (unnecessarily, it turns out), Apache, and <a href=\"http:\/\/www.allard.nu\/pfw\/\">PFW<\/a>, a web-based configuration tool for pf. I ended up not using PFW, because my understanding of pf is so bad that I&#8217;m basically relegated to copying-and-pasting rules from websites into the configuration file.<\/p>\n<p>Even using pf is confusing. It&#8217;s called pf, but typing &#8220;pf&#8221; at the command line doesn&#8217;t do anything. It turns out that you control it with a tool called &#8220;pfctl.&#8221; You can do pfctl -e to enable pf, and pfctl -d to disable it.<\/p>\n<p>As I tried to tweak the firewall\/routing rules, I&#8217;d periodically &#8220;restart&#8221; pf by disabling and then re-enabling it. I wasn&#8217;t sure if it read the rules &#8220;live&#8221; or if a restart was needed. It turns out&#8230; neither! The rules are stored in memory, but restarting pf doesn&#8217;t flush the rules. You need to pass pf some more arguments to tell it to flush the cache and read them anew from its configuration file.<\/p>\n<p>After a few more hours of work, I thought it was all set up. Both NICs were configured, the external one to get an IP over DHCP, and the internal one with a low fixed IP. I had a complex set of rules, doing NAT, filtering traffic, and using <a href=\"https:\/\/solarflux.org\/pf-b\/?p=22\">HFSC<\/a> for prioritized queueing. (HFSC seems <em>completely<\/em> undocumented, by the way. I took my tips from random websites.) It seemed very impressive: I prioritized <a href=\"http:\/\/www.benzedrine.cx\/ackpri.html\">ACK<\/a>s so that downloads wouldn&#8217;t suffer if our outbound link was saturated. (Aside: it really doesn&#8217;t make sense to do queueing on incoming traffic, since the bottleneck is our Internet link, not our 100 Mbps LAN.)\u00a0 I also afforded DNS, ssh, and video game traffic high priorities, but allocated them a lower percentage of traffic. I even figured out the default BitTorrent ports and gave them exceptionally low priority: if our line is fully saturated, the last thing I care about is sharing unnecessary data with other people.<\/p>\n<p>And there are other neat features. It &#8220;scrubs&#8221; incoming connections, reassembling fragmented packets and just eliminating crap that doesn&#8217;t make sense. It catches egregious &#8220;spoofing&#8221; attempts and discards them.<\/p>\n<p>I hooked up the second LAN connection to test it out, rebooted, and&#8230; waited.<\/p>\n<p>It never came up. Well, it did come up. The computer&#8217;s running fine. Both network cards show up with the switch. Doing an nmap probe of our LAN, I see one strange entry. It&#8217;s actually pretty mysterious: it has no open ports, and attempting to ssh into it just sits there: it doesn&#8217;t send a connection refused, but completely ignores the incoming packets, leaving my poor ssh client sitting there waiting for a reply, having no clue what&#8217;s going on.<\/p>\n<p>In a nutshell, it seems that I just built a firewall\/router that&#8217;s <em>so<\/em> secure that I can only find one of its two cards on the network, and I can&#8217;t even <em>try<\/em> to log into it. Let&#8217;s see you hack that! Of course, this does have some issues. For example, I can&#8217;t use it.<\/p>\n<p>I haven&#8217;t lost hope yet: I have a keyboard and monitor so I can log in on the console and try to do some tweaking there. (You can&#8217;t firewall off the keyboard.) It&#8217;s just not very encouraging to think, &#8220;Alright, let&#8217;s reboot and make sure it works as flawlessly as I think it will&#8221; and then have the darned thing not even show up on the network.<\/p>","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve been having a lot of intermittent network problems at home. Periodically, our Internet cuts out. At first I assumed it was our ISP&#8211;it&#8217;s no longer Adelphia (run by pharmacists), though&#8211;but subsequent research indicated that it wasn&#8217;t our ISP&#8217;s fault: &hellip; <a href=\"https:\/\/blogs.n1zyy.com\/n1zyy\/2007\/12\/28\/geek-2\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,10,13,18,22,24,27],"tags":[],"class_list":["post-407","post","type-post","status-publish","format-standard","hentry","category-computers","category-ideas","category-linux-tips","category-ocd","category-programming","category-rants-raves","category-security"],"_links":{"self":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/comments?post=407"}],"version-history":[{"count":0,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/407\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/media?parent=407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/categories?post=407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/tags?post=407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}