Setting up a powerful firewall
There are all sorts of firewalls out there, gui-based and web-based being the most popular for home systems. Shorewall however, offers greater control then most, it does not require a desktop gui, and has been proven over many years. The advantage a non-gui is that secure remote administration is simple and very fast. My servers are located in another country, but a simpe ssh connection (not on port 22 of course!) allows secure encrypted manipulation of the firewall and its blacklist from anywhere with negligible bandwidth overhead. (Servers should never run gui's anyway, for obvious security and resource reasons.) Shorewall as a bidirectional firewall plus clamavd as a viruses scanner are hard to beat. And of course, they are free of charge, unlike the bumpf available commercially.
Here's a quick and dirty guide for setting up shorewall on your system. Here I assume that you are running a stand-alone server using a real operating system (Unix, Solaris, BSD, BE, etc.) and that it offers https, smtps, and imaps to a user community:
| 1 | Install it: apt-get install shorewall |
| 2 | Modify it:
|
| 3 | Here is the only "complex" part of setting things up. In /etc/shorewall/rules we place the holes in the firewall through which we will allow certain people to access the http, smtp, and imap ports on our server. I like to divide rules up by incoming, outgoing, and local only rules. Note that for this example, only encrypted connections from users are allowed, in conformity with the UN Convention on Human Rights (that is, we ensure user privacy). The laws in your country may differ. Here we go: SECTION NEW ## ------------------------------------------------------------------- OUTGOING RULES # Rules for ICMP - note that I do not like pings - you may so change the Ping/Reject to Ping/Accept if your # # particular religion requires the Cosmic Muffin knowing all about you Ping/REJECT net $FW ACCEPT $FW net icmp ACCEPT $FW loc icmp # Rules for outbound loc hosts HTTPS/ACCEPT $FW loc SMTPS/ACCEPT $FW loc IMAPS/ACCEPT $FW loc ## -------------------------------------------------------------------- INCOMING RULES # Note here that I have limited the number of connections per second and the maximum burst # number of connections (20/sec: burst 30 for HTTPS) to prevent the gerbils spinning the hard drive to get too # tired. # Rules for public services HTTPS/ACCEPT net $FW - - - - 20/sec:30 SMTPS/ACCEPT net $FW - - - - 2/sec:5 IMAPS/ACCEPT net $FW - - - - 2/sec:5 # Rules for private services IMAPS/ACCEPT loc $FW HTTPS/ACCEPT loc $FW SMTPS/ACCEPT loc $FW |
| 4 | And last but not least, always have a blacklist. Very handy for keeping out .cn attackers. For example, in /etc/shorewall/blacklist you might wish to add the following lines: # block useless ports from Micro$oft viruses such as Vista, XP, etc. (the hyphen (-) means 'all ips') - udp 1024:1033,1434 - tcp 57,1433,1434,2401,2745,3127,3306,3410,4899,5554,6101,8081,9898 # block some idiot 61.37.235.120 # block a group of idiots 216.239.53.0/24 |
That's all - easy! You now have the basis of an amazingly powerful and easy to use firewall.
