A guide to securing your home and home network with inexpensive hardware, open source software and about 8 hours of dedicated time. This is a living document, updated on a regular basis to reflect additional best practice methodologies, tips and tricks as they become available.
In this guide, we will walk you through the process of building and configuring security systems to protect your home and home/office network through the use of motion-sensing digital security cameras, advanced firewalls, intrusion detection systems, and realtime notification mechanisms.
In a mere eight hours, we will endeavor to build and configure a moderately sophisticated wired and wireless home or office LAN with a DMZ for public-facing services, strong ingress and egress filtering for all connected subnets and a realtime risk management console with live monitoring and alerts by email and/or telephone!
In the event you have older hardware lying around (i.e. old PC’s, Pentium or better), you should be able to secure your network without purchasing any (much) additional hardware. Otherwise, components can generally be purchased for less than $100/ea at major retail and electronics stores (i.e. BestBuy, CircuitCity, CompuUSA, etc.) and all of the software referenced in this guide is freely available, most under an OSI-approved OpenSource license.
Numerous tools (hardware and software) referenced in this text are interchangeable with other, similar tools, and where possible I will offer suggestions for such alternatives. Below is a materials list so you can start to determine what you might need to purchase prior getting started. For most, the total cost for this project will fall well under USD$400.00.
For your firewall:
For your IDS / Motion Detection / Monitoring server:
(I use an old Dell PIII-500. Since this device will not run a GUI, likely any PIII or better should suffice.)
(I use D-Link DCS-900s.)
(I’ve had good success with cheap D-link and Linksys switches.)
(Sometimes hard to find, but any brand should suffice.)
Step 1: Install the Firewall
The first step in securing our castle will be that of establishing perimeter security by building and configuring our firewall. There are several solutions to firewalling our home networks, and although inexpensive wired/wireless routers, like those from Linksys and D-link, provide adequate perimeter security, they lack granularity and do very little to secure egress traffic. For this reason, even if you’ve purchased a WRT54G as suggested above, you will be replacing the on-board firmware with one that will allow more control over the firewalling process and provide the ability to interact with the rest of our network security and network monitoring systems (bearing in mind, of course, that this will invalidate your warranty).
If you are using a low-end PC, go ahead and install m0n0wall (or whatever firewall OS you chose).This process should take no more than about 30 minutes.
Personally, I’m using m0n0wall due to its small size, native ability to run from CompactFlash, its solid BSD base and slick configuration GUI. Other firewall OSes may offer different features; if necessary, do a bit of research before settling for one. (For instance, IPCop also provides Snort by default, offering IDS at the firewall for all connected interfaces. This may not be important to you if you plan to implement IDS on your monitoring server, however, which I will described below.)
Also, bear in mind that the number of interfaces in your firewall will determine your ability to effectively isolate wireless traffic from internal and DMZ subnets, which is highly desirable. Four interfaces should work well for this purpose. With only three, you will have to stick your WAP(s) onto either your DMZ or Internal networks, neither of which would I recommend, if it can be avoided. Given four interfaces, your network will look something like this:
When configuring your firewall rules, bear in mind the following considerations:
- Initially you will want to block or reject all inbound traffic, to both the LAN and DMZ. Once you have OSSIM and ZoneMinder in place, you can decide if you want to allow access from the outside (or preferably only via VPN). Remember to try to limit inbound access to minimal services, if any at all. In an ideal world, you would allow nothing to the outside world (except, perhaps, basic web and/or mail — no open relays!) and only allow access to services in the DMZ via VPN, whether IPsec, SSL (OpenVPN) or even PPtP (ick).
- Although you can allow “any” traffic from LAN to WAN, I highly recommend that you spend a little bit of time building a strong egress filtering ruleset. As a reference, you can refer to elmore’s Strong Egress Ruleset for PF, which provides numerous excellent examples of rules that limit outbound access while still ensuring necessary connectivity to the outside world.
Step 2: Build the Monitoring Server
Our monitoring server will actually serve multiple purposes, providing IDS, network and security monitoring, IP camera motion detection and capture, and realtime alerting via email, SMS and telephone. In an ideal world, and following security best practices, each of these services would be provided by a separate machine, though for our purposes, a single device should suffice as long as we take good care to secure it properly. And although we don’t really need an extraordinary amount of CPU power, the more memory our monitoring server has, the better overall performance of the subsystems will be. Therefore, I would highly recommend that you stick at least 512MB if not a GB or more in this box to ensure that it’s able to dedicate enough memory to each task.
Which OS/distribution you choose here is really up to you. Personally, I use Gentoo for it’s speed, power and flexibility. Fedora, Ubuntu or Mandriva will quicken the install process, at the cost of a little less optimization and package customizability. My best recommendation is that you go with what you’re most comfortable with. If you’re not already comfortable running a Linux or BSD server, stick with Fedora, Ubuntu, or Mandriva, or roll the dice. For the faint of heart, and easiest installation of the packages described by this guide, stick with Debian or Ubuntu. A final option is to use the ZoneMinder LiveCD, provided by Ross Melin, which will install Mandriva and pre-install ZoneMinder in one fell swoop. In any case, the installation of the operating system should probably take you between 30 minutes and an hour, depending on the speed of your hardware.
Alright, once you’ve got the base OS installed, your first step will be to harden the server itself, as this device will be more exposed than the workstations in your Internal network. At the very minimum, install and run Bastille on this box prior to going any further.
Next, we’ll need to install a few software packages, as well as any requisite dependencies. The important one here are those mentioned in the list above, specifically: Snort, OSSIM and ZoneMinder. If you used the Mandriva LiveCD mentioned above, you’ll already have ZoneMinder installed and configured, otherwise you’ll have to install some or all of the following: Snort, Apache, PHP, MySQL, Acid, MRTG, ntop, OpenNMS, nmap, Nessus, RRDtool, and ZoneMinder.
In most cases, this isn’t as difficult as it sounds, as the package manager provided with the operating system should handle all dependency resolution and automate the installation process. Further, if you’re using Fedora or Debian/Ubuntu, there are package repositories for both OSSIM and ZoneMinder that will handle everything from the above list. For Debian/Ubuntu, check here and here. Once you have the repositories configured, installing ZoneMinder should be as simple as “apt-get update ; apt-get install zm.” Installing OSSIM is only slightly more complex, and is described in detail here. Total time to complete this phase shouldn’t exceed 2 - 4 hours, depending on your chosen os/distro.
On my Gentoo box, the process was a bit more complicated because I had to install most of these packages individually, then manually configure them to work together as required by OSSIM. Further, the ZoneMinder ebuild in Gentoo’s Portage is quite old, so I had to build that one from scratch, without the help of my package manager.
Step 3: Configuring the Hardware (WAP(s) and Cameras)
Once we’ve got our firewall and monitoring server built and configured, it’s time to drop in our WAPs and IP cameras. If you took my advice and bought yourself a WRT54G or few, I highly recommend that you now consider replacing the stock-Linksys firmware with one of the following replacement firmwares:
- HyperWRT - Adjustable Transmit Power & Antenna Select
- Sveasoft - Highly modified firmware, provides wide range of enhanced features
- OpenWRT - Minimal firmware with support for add-on packages
- eWRT - Provides a captive portal and a writeable jffs2 filesystem
Personally, I use the Sveasoft firmware, as it has the most extensive featureset out-of-the-box, and I have my WAPs implemented in a meshed configuration via WDS, extending my wireless network to all of the rooms in my house without the need to run additional cable.
If you are using 4 interfaces on your primary firewall, make sure that the 4th interface and the WAP are on an isolated subnet. I would highly recommend disabling SSID broadcast, and if your client device(s) support it, I would suggest using WPA in lieu of WEP as WEP will provide only marginal security of your wireless traffic (and consequently your network), at best. If you have the patience, I also recommend enabling MAC-address filtering for an additional layer of security, especially if you expect to have less than 5 or 10 wireless clients. In 2002, I wrote a white-paper on Best Practices for Securing 802.11 Networks, and most of the principles still hold true; it would be worth a quick review prior to plugging your WAPs into the rest of your network.
Configuration of your cameras will depend on the vendor, but for my D-link DCS-900s all I had to do was set IPs and configure listening ports. By default, the camera provides an integrated webserver with Live ActiveX/Java viewers, though they tend to be tediously slow. A second port provides realtime static image display, in JPG format. As such, I would suggest that you put your IP cameras in your DMZ network, as this will provide proper protection for all devices running listening services and will ease the process of configuring ZoneMinder on your management server within the same subnet.
Step 3: Configuring ZoneMinder and OSSIM
Configuration of ZoneMinder and OSSIM are probably the most complex tasks in this setup, though with the simple network configuration that I’ve outlined above, still shouldn’t take more than a few hours.
There is an excellent article at Newsforge about configuring ZoneMinder using the wireless version of the D-link cameras. The document offers some specific tips and tricks that I found very valuable when configuring the software, one of which I’ll reference below:
The next task is to create monitors. A monitor is a camera. I’ve seen comments in the ZoneMinder forum about having more than one monitor per camera, but I think the relationship is almost always one-to-one. To create a monitor, click the Add New Monitor button on the ZM Console.
The ZM Monitor New screen shows five tabs across the top. Here are the changes to the default values that I made. Just as with the options, your mileage will vary depending on the particulars of your installation.
• Monitor - Enter monitor name (Front Door) and select Remote for the Source Type Note: Selection of Source Type drives what options are shown on other tabs
• Source - Enter Remote Host Name (userid:password@XXX.145.100.156) Note: the userid and password are those configured in the camera, not in Apache or MySQL
• Source - Enter Remote Host Port (9293)
• Source - Enter image.jpg for Remote Host Path
• Source - Select 24-bit color for Remote Image Colors
• Source - Enter 640/480 for the Capture Width and Height
• Buffers - Enter 25 for Image Buffer Size
That last setting was necessary for me because I ran out of shared memory space with the default setting of 100. You may not need to adjust your own buffer size at all. Originally, I wrote that you might need to change to a new Shared Memory Key (ZM_SHM_KEY) in the System tab of ZM Options. but Coombes has advised me that is not necessary unless you have two complete Zoneminder installations on the same machine. He said “Ordinarily you would change your system config to allow more shared memory to be allocated (either in total or per request)”. Update: I wrote a column about how to do this on Linux.com. You can find it here.
I then repeated the Add New Monitor process to configure the second remote camera. The only difference in the two configurations was the name (TheDriveway) and the Remote Host Port (9294).
I highly recommend reading the article in its entirety, as the article covers significant detail with regards to advanced setup and configuration of ZoneMinder.
Finally, you’ll need to tweak your OSSIM configuration. If you have all of the requisite packages installed, and/or you followed along with one of the OSSIM install documents referenced above, you should be about 3/4 of the way there. The rest of your work will be defining sensors and hosts and tweaking basic parameters, then setting up alerts. It would probably be a good idea to go ahead and reboot your Monitoring Server at this point in time, however, to ensure that all necessary services are running and everything is humming along as expected prior to attempting further configuration. Also, upon boot, make sure and review the end of your syslogs to ensure that there aren’t any problems that were not obvious during the boot process, and use netstat to make sure you have necessary listening ports open.
The following resources will likely prove useful while tweaking OSSIM, and make sure to join the mailinglists and/or participate in the forums if you have problems.
Step 4: All Done! Relax and Have a Beer and a Nap
At this point in time, you should have a fully configured and relatively well-secured network (hell, your security will probably exceed that of a lot of large enterprise organizations I know, whose names I will omit to protect the guilty innocent). You should have both wired and wireless subnets with strong egress rules in place thanks to your stateful firewall, and you have a DMZ containing your monitoring systems for both your physical premises and logical infrastructure. And, if you used existing hardware, or purchased inexpensive COTS equipment, and you stayed focused on building and securing your network in one session, you probably spent less than $800 and no more than about 8 or so hours setting all this up and taking it live.
In fact, I think you deserve a big pat on the back and a nice cold beer — and since you’re security and monitoring systems are now all automated — a nice long nap afterwards.
One final thing — if you have comments or suggestions on how I can improve or amend this article, please don’t hesitate to add your comments or suggestions below and/or email me via the kaos.theory contact link on the front page. You’ll also find my PGP key on public keyservers, and can verify the fingerprint on the kaos.theory member’s page!