<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-13456247</id><updated>2011-12-15T02:52:17.258Z</updated><title type='text'>NetNix</title><subtitle type='html'>Random scribblings on Networks and Unix</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://netnix.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://netnix.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Chris Read</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>11</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-13456247.post-114192346085587478</id><published>2006-03-09T16:49:00.000Z</published><updated>2006-03-09T17:06:13.343Z</updated><title type='text'>Moving...</title><content type='html'>Well, it's been about 6 months since I last blogged. I've not had much interesting to say really, just had my head down working. Things have lightened up a bit since then, so hopefully I'll have a bit more time on my hands to order my thoughts and scribble them down. All this is going to happen at my new site, &lt;a href="http://www.chris-read.net"&gt;http://www.chris-read.net&lt;/a&gt;. See you there...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13456247-114192346085587478?l=netnix.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netnix.blogspot.com/feeds/114192346085587478/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13456247&amp;postID=114192346085587478' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/114192346085587478'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/114192346085587478'/><link rel='alternate' type='text/html' href='http://netnix.blogspot.com/2006/03/moving.html' title='Moving...'/><author><name>Chris Read</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13456247.post-113041706699359134</id><published>2005-10-27T13:25:00.000+01:00</published><updated>2005-10-27T14:26:49.616+01:00</updated><title type='text'>Why reading books is still important</title><content type='html'>I finally got around to reading my copy of &lt;a href="http://www.oreilly.com/catalog/ipv6na/index.html"&gt;IPv6 Network Administration&lt;/a&gt; and in chapter 4 there's a section that deals with transition mechanisms which covers the kinds of problems I've been trying to solve with &lt;a href="http://stfl.sourceforge.net/"&gt;STFL&lt;/a&gt;. When I was first digging around the net to see what people had done about allowing IPv6 clients to connect to IPv4 only applications, I found some elusive references to something from the &lt;a href="http://www.kame.net/"&gt;KAME&lt;/a&gt; project called &lt;span style="font-style: italic;"&gt;faithd&lt;/span&gt;. All I could find out about it at the time was that it seemed to be half implemented in user space, and half in the kernel of FreeBSD, but it seems to have been lost in the mists of time. While the book also refers to it, there is also mention of &lt;a href="http://www.ietf.org/rfc/rfc3142.txt"&gt;RFC 3142&lt;/a&gt; which describes something called TRT, or Transport Relay Translation. I now have a proper name for what I'm trying to do! That's why reading books is still important.&lt;br /&gt;&lt;br /&gt;The solution described in the RFC is pretty much exactly what I've been thinking of, except for the following differences:&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;Name Resolution&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Or the way the DNS is configured for the service. The approach I've been thinking of is pretty simple - assign an IPv6 address to the service you want to offer, add an AAAA record to DNS for that service, run STFL on that IPv6 address and forward the requests to the IPv4 address and port where the application server actually runs. While RFC 3142 does allude to doing it this way, it also talks about using a custom resolver library or DNS server to automatically convert the IPv4 address into an IPv6 address (the don't mention it specifically, but I guess they're talking about 6to4 which is described in &lt;a href="http://www.ietf.org/rfc/rfc3056.txt"&gt;RFC 3056&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Service Granularity&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;My philosophy is simple. You have one application (in my personal case it's Apache 1.3 on OpenBSD) that is not IPv6 compatible but you want to serve IPv6 clients with. So all you do is spark up an application on an equivalent port on an IPv6 address and just ferry the TCP packets back and forth. If you have more than one application you want to do this for, then you simply fire up additional STFL instances. The RFC seems to suggest making an entire IPv4 address and all its TCP and UDP services available on the same IPv6 address (hence the need for mangling resolver). I guess this is why the reference implementation need a kernel level component, and is probably why it never seemed to get off the ground - that's some pretty complicated stuff you need to do!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13456247-113041706699359134?l=netnix.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netnix.blogspot.com/feeds/113041706699359134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13456247&amp;postID=113041706699359134' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/113041706699359134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/113041706699359134'/><link rel='alternate' type='text/html' href='http://netnix.blogspot.com/2005/10/why-reading-books-is-still-important.html' title='Why reading books is still important'/><author><name>Chris Read</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13456247.post-112540006557047008</id><published>2005-08-30T11:41:00.000+01:00</published><updated>2005-08-30T12:07:57.210+01:00</updated><title type='text'>Introducing STFL - the Six to Four Layer</title><content type='html'>It's been a long time since I last posted my ramblings on a simple way to allow legacy IPv4 services to serve IPv6 clients, but at last I have something to show for it! After playing around a bit more with my Python "proof of concept" code, I realized that while the idea was sound, implimenting it in Python may not be the best solution. The main problem I had was with the &lt;a href="http://docs.python.org/api/threads.html"&gt;Python global interpreter lock&lt;/a&gt;. Even though I'd written the code using threads, it would not scale under heavy load. So, I decided to chip the layers of rust off my C skills. The result is the &lt;a href="http://stfl.sourceforge.net/"&gt;STFL&lt;/a&gt; project. It's functional, but needs polish and a bit of effort to get it working all the major Unix flavours. Currently it's only fully functional (and tested) on Linux and OpenBSD.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13456247-112540006557047008?l=netnix.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netnix.blogspot.com/feeds/112540006557047008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13456247&amp;postID=112540006557047008' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/112540006557047008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/112540006557047008'/><link rel='alternate' type='text/html' href='http://netnix.blogspot.com/2005/08/introducing-stfl-six-to-four-layer.html' title='Introducing STFL - the Six to Four Layer'/><author><name>Chris Read</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13456247.post-112160980093720574</id><published>2005-07-17T15:15:00.000+01:00</published><updated>2005-07-17T15:59:39.150+01:00</updated><title type='text'>The easy way to IPv6 support for TCP apps</title><content type='html'>When I initially got my static IPv6 address range from my ISP, I was running Linux as my firewall and Apache 2 on Solaris x86 as my web server. This meant that getting my site available over IPv6 was pretty straight forward. All I had to do was add new &lt;span style="font-style: italic;"&gt;A6&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;AAAA&lt;/span&gt; records to my DNS entries, configure the static IP address on the Solaris box and add an additional &lt;span style="font-style: italic;"&gt;Listen&lt;/span&gt; directive to Apache. Life was good. Not that I ever got more than 10 hits a month on my site from IPv6 addresses, but that was not the point!&lt;br /&gt;&lt;br /&gt;Then I switched the firewall and web server over to OpenBSD. One of the main factors in me deciding to do this was the great "Tinfoil Hat" approach the OpenBSD guys have to security. Sure, you may not be able to run the latest greatest version of your favourite app, but the stuff they do ship with the core distribution has been fairly well nit-picked by some pretty bright people. This means I don't have to worry so much about the script kiddies getting in...&lt;br /&gt;&lt;br /&gt;However, this does mean that the Apache they ship and support and have tweaked to have run in its own little chrooted sandbox is pretty old - 1.3.29 at the time of writing this. Yes, all the security patches that come from the Apache group have been applied. But it does not do IPv6. There are patches out there from the &lt;a href="http://www.kame.net/"&gt;Kame&lt;/a&gt; guys to enable this in the 1.3 branch, but it's old, experimental, and does not do SSL. I did for a few brief minutes contemplate seeing if I could at least try crafting my own patch to get mod_ssl to work, but then sanity kicked in. I am not a hard core developer. I am a Sys Admin who knows how to code.&lt;br /&gt;&lt;br /&gt;I then decided to step back and look at the picture from another angle. All that's different really is the IP stack. The actual TCP protocol used to do all the chatting is the same. What I really needed was something to mess with the inbound IPv6 packets, send them to the required IPv4 host, and do the opposite on replies. Trying to write some code to do this somewhere in the network stack is more scary and presents more security bugs than trying to write a mod_ssl patch. So I decided to go for the quick and easy method - write a socket app that listens on an IPv6 port, and pumps all the TCP packets down a new IPv4 connection, and do the opposite with the replies.&lt;br /&gt;&lt;br /&gt;A few hours later I had a small (about 200 lines at the moment) Python app to do this all for me. It's also fast handles multiple ports, and is protocol indepentant. I've tested HTTP, SSL, SSH, IMAP, POP3 and SMTP with it.&lt;br /&gt;&lt;br /&gt;I'm busy working on the final touches before releasing it, but I will anounce it here when it's ready.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13456247-112160980093720574?l=netnix.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netnix.blogspot.com/feeds/112160980093720574/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13456247&amp;postID=112160980093720574' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/112160980093720574'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/112160980093720574'/><link rel='alternate' type='text/html' href='http://netnix.blogspot.com/2005/07/easy-way-to-ipv6-support-for-tcp-apps.html' title='The easy way to IPv6 support for TCP apps'/><author><name>Chris Read</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13456247.post-111901514657454212</id><published>2005-06-23T09:23:00.000+01:00</published><updated>2005-06-23T09:30:21.083+01:00</updated><title type='text'>Xen and the Art of Virtualization</title><content type='html'>I've installed Fedora Core 4 on one of my tinkering machines, and since it now ships with prebuilt &lt;a href="http://www.cl.cam.ac.uk/Research/SRG/netos/xen/"&gt;Xen&lt;/a&gt; kernels I decided it was high time to give it a try. Having played with all kinds of machine virtualization from VMWare to Solaris 10 Zones to the Hypervisors on IBM pSeries servers (I'm still waiting for someone to give me time on a mainframe so I can tinker with z/VM though) I'd say I'm pretty familiar with the technology as a whole and the different approaches people take to it all.&lt;br /&gt;&lt;br /&gt;So far I'm pretty impressed. Installation of the host (Domain0 in Xen speak) is easy as expected. Just install the supplied xen0 kernel, disable SELinux (and IPTables if you want to network it) and reboot. However, that's pretty much where the simple stuff ends. Unfortunately most of the pain and suffering I've had getting this to work has been caused by Red Hat, not Xen...&lt;br /&gt;&lt;br /&gt;The Fedora guys have a &lt;a href="http://www.fedoraproject.org/wiki/FedoraXenQuickstart"&gt;Virtualization Quick Start&lt;/a&gt; page which describes what you need to do. It's pretty much accurate, except for when it comes to getting a working OS installation on your virtual disk image. The only thing I can think is that Yum has changed a bit since that document was written. After a bit of hacking I did manage to get a Fedora image booting under a virtual machine, but it was not pretty. So I decided to try a "build from almost scratch" distro I was familiar with - &lt;a href="http://www.gentoo.org/"&gt;Gentoo&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I've run Gentoo on various machines of mine for almost 3 years now. It's fast, gives you a lot of control, but ultimately is a royal pain to maintain, especially for server environments. Installing it onto a Xen image is a dream though. It's quick, to the point, and let's you do what you want. All was going swimmingly until I tried to boot the virtual machine. It loaded the kernel (the supplied xenU kernel from Fedora) just fine, but when it came to mounting the file system, fsck.ext3 bombed with errors that there were unknown options in the filesystem metadata. It turns out that Red Hat have added an option to their e2fsprogs that allows online filesystem resizing, but this is not reflected in the version numbers they display. Luckily they are all statically linked, so I just copied the FC4 binaries over to my Gentoo partition and all is funky!&lt;br /&gt;&lt;br /&gt;I now have a nice little playpen to install a new honeypot on. I've even got full IPv6 connectivity to it, so let's see what nastiness is spreading around the IPv6 side of the net these days...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13456247-111901514657454212?l=netnix.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netnix.blogspot.com/feeds/111901514657454212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13456247&amp;postID=111901514657454212' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111901514657454212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111901514657454212'/><link rel='alternate' type='text/html' href='http://netnix.blogspot.com/2005/06/xen-and-art-of-virtualization.html' title='Xen and the Art of Virtualization'/><author><name>Chris Read</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13456247.post-111902515334618675</id><published>2005-06-17T17:09:00.000+01:00</published><updated>2005-06-17T17:23:54.610+01:00</updated><title type='text'>How Privoxy ruined my day</title><content type='html'>I've been puzzled for the past few days about wierd things my browser has been doing. Sometimes things works nicely, other times it makes no sense! I was starting to wonder if there's a problem with the Firefox build that ships with FC4. One of the most painfull things it was doing was screwing with me trying to post here. I'd log in, type up something good, and then when I try "Save as Draft" it kicks me to the login page and loses my edits. And I kept on having to log into Slashdot...&lt;br /&gt;&lt;br /&gt;I got so upset with losing posts, that I thought it was the blogger.com software. I then proceeded to download and install &lt;a href="http://wordpress.org/"&gt;WordPress&lt;/a&gt;, which was quick and painless. Then I tried to tweak the config, and it bitched and screamed about my browser not sending any referer headers. Luckily it included a link in the error message, which took me to a nice little &lt;a href="http://codex.wordpress.org/Enable_Sending_Referrers"&gt;page&lt;/a&gt; that explained how to get your browser to send these headers. I checked my settings, and they were all correct! And then right at the bottom was a little note about Privoxy. And the light bulb clicked on. This great protector of my browser from such nasties as popups and double-click was also protecting me from blogging! So I added .blogger.com (and .slashdot.org and a few others) to the fragile list in the Privoxy configuration...&lt;br /&gt;&lt;br /&gt;And now it all works....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13456247-111902515334618675?l=netnix.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netnix.blogspot.com/feeds/111902515334618675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13456247&amp;postID=111902515334618675' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111902515334618675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111902515334618675'/><link rel='alternate' type='text/html' href='http://netnix.blogspot.com/2005/06/how-privoxy-ruined-my-day.html' title='How Privoxy ruined my day'/><author><name>Chris Read</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13456247.post-111869648447602024</id><published>2005-06-13T21:46:00.000+01:00</published><updated>2005-06-13T22:05:05.463+01:00</updated><title type='text'>Automated Abuse Reporting</title><content type='html'>For the past few days I've been tinkering with the idea of automated abuse reporting. I started out writing a little python script to grab the whois data for a specific IP address and parse out email addresses. Once more I'm moved by the power and simplicity of regular expressions, but I'm hugly frustrated by the fact that all the &lt;span class="small"&gt;Regional Internet Registries don't use a common whois format! I know it's not realistic to have a totally common format, but a parsable abuse contact field should not be that hard. I'd rather not send a form letter to every email address in the whois record, as I'm not a fan of spam. Maybe I should start making enquiries...&lt;br /&gt;&lt;br /&gt;Other than that, the filtering is working fine. Blocked a few more IP's. I've taken the limit down to 5/60 because slow scans were still getting too many attempts in.&lt;br /&gt;&lt;br /&gt;So, my next quest is to start improving my IPv6 filter rules. I think the hard part is going to be finding a shell account on a machine on an IPv6 network that's not mine. Anyone out there feeling helpfull?&lt;br /&gt;&lt;br /&gt;As if anyone reads this stuff anyway! I think I'll go directly to plan B and test drive the fair queing so I don't get lagged out playing WoW while downloading Fedora Core 4...&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13456247-111869648447602024?l=netnix.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netnix.blogspot.com/feeds/111869648447602024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13456247&amp;postID=111869648447602024' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111869648447602024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111869648447602024'/><link rel='alternate' type='text/html' href='http://netnix.blogspot.com/2005/06/automated-abuse-reporting.html' title='Automated Abuse Reporting'/><author><name>Chris Read</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13456247.post-111831580447955312</id><published>2005-06-09T11:48:00.000+01:00</published><updated>2005-06-09T12:27:26.790+01:00</updated><title type='text'>OpenBSD Network Protection - Summary</title><content type='html'>It works! Much more efficient and responsive than the first solution. Caught another kiddie yesterday, he only managed to get 13 attempts in a 25 second window before the system blocked him.&lt;br /&gt;&lt;br /&gt;I changed the trigger rate after some additional testing after the previous post. 10/60 is much more realistic. Ideally it should be somewhere in the region of 5/60, but I'm being a bit conservative as that's how I connect to my home machines and I don't feel like locking myself out.&lt;br /&gt;&lt;br /&gt;So, to summarise, the best way to tune your OpenBSD firewall to protect your systems from brute force dictionary attacks is to use the following rule format:&lt;br /&gt;&lt;br /&gt;block quick from &lt;bad_hosts&gt;&lt;br /&gt;pass in on $ext_if proto tcp to $target_ip_address port $port_to_protect flags S/SA keep state   (max-src-conn-rate $connections_per_second_to_trigger, overload &lt;bad_hosts&gt; flush)&lt;br /&gt;&lt;br /&gt;The trigger rate can be tuned to your level of paranoia, but I've found that having a long window to monitor in helps considerably.&lt;br /&gt;&lt;br /&gt;Now, let's see if I can get automated abuse reporting going once I've caught these little buggers...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13456247-111831580447955312?l=netnix.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netnix.blogspot.com/feeds/111831580447955312/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13456247&amp;postID=111831580447955312' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111831580447955312'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111831580447955312'/><link rel='alternate' type='text/html' href='http://netnix.blogspot.com/2005/06/openbsd-network-protection-summary.html' title='OpenBSD Network Protection - Summary'/><author><name>Chris Read</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13456247.post-111813959254195477</id><published>2005-06-07T10:52:00.000+01:00</published><updated>2005-06-07T11:19:52.546+01:00</updated><title type='text'>OpenBSD Protection - Part 2</title><content type='html'>It's been almost 24 hours since I put up the scan protection mentioned in the last article, and I've already blocked a scanner!&lt;br /&gt;&lt;br /&gt;But having a look at it all, it's not a very good solution. Problems are:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Scanning is resource intensive. It put quite a notable load spike on the system when ever it ran, and that can be expected from shell scripts scanning log files.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Not granular enough. I was initially running the script every 5 minutes. And as luck would have it, the kiddie I caught started his scan at 15:24:05. If he had started his scan a minute later, there's a good chance I would not have picked it up. In the minute that his scan was allowed to run, he had already managed 97 connections!&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Limited to single machine. As I'm getting all my info from ssh logs, and I'm blocking the packets coming in to the exposed host, when the do trip the wire I only end up protecting a single machine.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;To get around these problems, I've decided to make use of the rate limiting features of pf in OpenBSD. I have a dedicated machine protecting my network and doing all my external routing. By putting the monitoring and blocking at this level, as soon as I pick up a scan I can block traffic from that IP address to my entire network.&lt;br /&gt;&lt;br /&gt;To do this, I simply added the following rules to my pf.conf:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;table &amp;lt;bad_hosts&amp;gt; persist file "/var/log/bad_hosts.list"&lt;br /&gt;block quick from &amp;lt;bad_hosts&amp;gt;&lt;br /&gt;pass in on tun0 proto tcp to (my IP address) port ssh flags S/SA keep state (max-src-conn-rate 5/10, overload &amp;lt;bad_hosts&amp;gt; flush)&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;Note that I load the bad IP addresses on start up from a file. To keep the file up to date, I run &lt;i&gt;pfctl -t bad_hosts -Tshow &amp;gt; /var/log/bad_hosts.list&lt;/i&gt; every hour via cron.&lt;br /&gt;&lt;br /&gt;Let's see how this works for the next few days. The next quest will be to automatically file an abuse report for the IP address once you pick it up...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13456247-111813959254195477?l=netnix.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netnix.blogspot.com/feeds/111813959254195477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13456247&amp;postID=111813959254195477' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111813959254195477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111813959254195477'/><link rel='alternate' type='text/html' href='http://netnix.blogspot.com/2005/06/openbsd-protection-part-2.html' title='OpenBSD Protection - Part 2'/><author><name>Chris Read</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13456247.post-111805743133360860</id><published>2005-06-06T12:15:00.000+01:00</published><updated>2005-06-07T11:24:35.520+01:00</updated><title type='text'>OpenBSD SSH Protection</title><content type='html'>As may become apparent over time, I'm a Unix Geek. Each flavour is special in its own little way. My favourite for exposing to the 'Net is &lt;a href="http://www.openbsd.org/"&gt;OpenBSD&lt;/a&gt;. But the problem I have with my current machines is that script kiddies keep trawling trying to get in over SSH, etc. So what I've done (inspired by &lt;a href="http://denyhosts.sourceforge.net/"&gt;DenyHosts&lt;/a&gt;) is write a small shell script to keep an eye on my authlogs and block offenders.&lt;br /&gt;&lt;br /&gt;DenyHosts looks interest, and earns brownie points from me being written in &lt;a href="http://www.python.org/"&gt;Python&lt;/a&gt;. But I just need something to be small and specific. Also, DenyHosts only adds entries to your hosts.deny file, and I want to block all access from these little buggers!&lt;br /&gt;&lt;br /&gt;OpenBSD ships with a good firewall. The approach I took was to parse my log files for people trying to get in via SSH and failing (with a bit of extra logic to stop it booting me if I do something silly) and then simply add offending IP addresses to the firewall as blocked hosts.&lt;br /&gt;&lt;br /&gt;Here's the script that does the work: (it's messy, I know, but it works)&lt;br /&gt;&lt;blockquote&gt;#!/bin/ksh&lt;br /&gt;#&lt;br /&gt;# Script to trawl logs for nastiness and log bad IP addresses&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;NUM_TRIES=3&lt;br /&gt;&lt;br /&gt;SSH_INVALID_USERS=`grep 'Invalid user' /var/log/authlog | awk '{ print $10 }' | sort -u`&lt;br /&gt;&lt;br /&gt;for iu in $SSH_INVALID_USERS; do&lt;br /&gt;&amp;nbsp;&amp;nbsp;    num=`grep $iu /var/log/authlog | wc -l`&lt;br /&gt;&amp;nbsp;&amp;nbsp;    if [ $num -gt $NUM_TRIES ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;        echo "$iu" &gt;&gt; /var/tmp/invalid_users.list&lt;br /&gt;&amp;nbsp;&amp;nbsp;    fi&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;cat /var/tmp/invalid_users.list | sort -u &gt; /var/tmp/invalid_users.list&lt;br /&gt;&lt;br /&gt;SSH_FAILED_PASSWORD=`grep 'Failed password for' /var/log/authlog | grep -v 'invalid user' |  awk '{ print $11 }' | sort -u`&lt;br /&gt;&lt;br /&gt;for fp in $SSH_FAILED_PASSWORD; do&lt;br /&gt;&amp;nbsp;&amp;nbsp;           num=`grep $fp /var/log/authlog | wc -l`&lt;br /&gt;&amp;nbsp;&amp;nbsp;           if [ $num -gt $NUM_TRIES ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;        echo "$fp" &gt;&gt; /var/tmp/failed_passwords.list&lt;br /&gt;&amp;nbsp;&amp;nbsp;    fi&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;cat /var/tmp/failed_passwords.list | sort -u &gt; /var/tmp/failed_passwords.list&lt;br /&gt;&lt;br /&gt;cat /var/tmp/invalid_users.list /var/tmp/failed_passwords.list | sort -u &gt; /var/tmp/blockers.list&lt;br /&gt;&lt;br /&gt;pfctl -t kiddies -vTadd -f /var/tmp/blockers.list&lt;br /&gt;&lt;/blockquote&gt;This script, run from cron as root, will update the kiddies table with bad IP addresses.&lt;br /&gt;&lt;br /&gt;Here's the entries from the pf.conf file (firewall configuration) that does the work:&lt;br /&gt;&lt;blockquote&gt;ext_if="vr0"&lt;br /&gt;table &amp;lt;kiddies&amp;gt; persist&lt;br /&gt;block in on $ext_if from &amp;lt;kiddies&amp;gt;&lt;br /&gt;&lt;/blockquote&gt;And that's all there is to it! If you want to see how effective you're being, you can run something like:&lt;br /&gt;&lt;blockquote&gt;pfctl -t kiddies -vTshow&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13456247-111805743133360860?l=netnix.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netnix.blogspot.com/feeds/111805743133360860/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13456247&amp;postID=111805743133360860' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111805743133360860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111805743133360860'/><link rel='alternate' type='text/html' href='http://netnix.blogspot.com/2005/06/openbsd-ssh-protection.html' title='OpenBSD SSH Protection'/><author><name>Chris Read</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13456247.post-111805617452836051</id><published>2005-06-06T12:07:00.000+01:00</published><updated>2005-06-06T12:09:34.533+01:00</updated><title type='text'>First Post</title><content type='html'>This is the first post! Lots of people at work blog, I'm still not 100% convinced it's worth the effort, but I've finally got something to say! I can't think of anywhere to say it other than at a blog type place, and I could not be arsed right now to set up my own blog system, so I'm gonna give Google a try and see how it goes...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13456247-111805617452836051?l=netnix.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netnix.blogspot.com/feeds/111805617452836051/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13456247&amp;postID=111805617452836051' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111805617452836051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13456247/posts/default/111805617452836051'/><link rel='alternate' type='text/html' href='http://netnix.blogspot.com/2005/06/first-post.html' title='First Post'/><author><name>Chris Read</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
