here you'll find information about some security concepts, some protocols,
typical communications, and example rules and rulesets for linux and windows
firewalls. (All down at the bottom, there is a small collection of further
ressources.)
"Firewall" is the principle of controlling which information gets in
and out of your computer/net. Thus it covers several areas where such control
can be applied: You can (try to) control which processes and programs are
running on your host(s) that generate and propagate information in the first
place. You can try to control your Operating Systems behaviour and you can try
to control which information is "on the wire". Only this last area is
covered by a family of programs called firewalls in turn (although some of them
provide functionality in the other areas as well), which sometimes are even
running on dedicated machines. And only these programs are covered here...
(Although i have a short paragraph about wrappers (see
here), which can be best described
by the first idea.)
The most basic distinction is the one between
Application Gateways (Proxies
with security functionality falling into this category) and
Packet Filters:
This is the most powerful way of controlling which information is transmitted.
Let's first see what generic proxies are:
A generic proxy is a program that is inserted in a communication between
sender and recipient, which simply relays the messages and can hardly be used
to filter anything.
back...
| No. | Application/Description | Allow/Deny/Reject | In/Outbound | Protocol | Source address:Port | Destination address:Port | ICMP Type/Code | Comment | LnS Screenshot | Kerio Screenshot | Sygate Screenshot | Outpost Screenshot | ZAP Screenshot | iptables command |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Default Policy | D | I&O | All | All:All | All:All | All/All | If your firewall has a "policy" setting, you may want to set this, otherwise a "drop" rule should be appended as last rule of your ruleset (see below) | n/a | n/a | n/a | n/a | n/a |
iptables -P INPUT DROP iptables -P OUTPUT DROP iptables -P FORWARD DROP |
| 2 | Drop impossible sources | D | I | All | your Internet IP 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8 224.0.0.0/3 204.152.64.0/23 169.254.0.0/16 127.0.0.0/8 0.0.0.0/8 255.255.255.255/32 192.0.0.0/16 1.0.0.0/24 |
All:All | All/All | see http://security.royans.net/info/articles/nonroutableip.shtml | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j DROP -s your Internet IP iptables -A INPUT -j DROP -s 192.168.0.0/16 iptables -A INPUT -j DROP -s 172.16.0.0/12 iptables -A INPUT -j DROP -s 10.0.0.0/8 iptables -A INPUT -j DROP -s 224.0.0.0/3 iptables -A INPUT -j DROP -s 204.152.64.0/23 iptables -A INPUT -j DROP -s 169.254.0.0/16 iptables -A INPUT -j DROP -s 127.0.0.0/8 iptables -A INPUT -j DROP -s 0.0.0.0/8 iptables -A INPUT -j DROP -s 255.255.255.255/32 iptables -A INPUT -j DROP -s 192.0.0.0/16 iptables -A INPUT -j DROP -s 1.0.0.0/24 |
| 3 | Accept Source-Quench in | A | I | ICMP | All | localhost | 4/. | This is an issue of some debate - it has some performance reasons for it, on the other hand it opens a DOS door. Choose your poison ;-) (Log it at least!) | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j ACCEPT -p icmp --icmp-type source-quench |
| 4 | Accept Echo-Reply in | A | I | ICMP | All | localhost | 0/. | ... | ![]() |
n/a | n/a | n/a | n/a |
iptables -A INPUT -j ACCEPT -p icmp --icmp-type echo-reply -m state --state ESTABLISHED,RELATED |
| 5 | Accept Destination-Unreachable in | A | I | ICMP | All | localhost | 3/All | ... | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j ACCEPT -p icmp --icmp-type destination-unreachable -m state --state ESTABLISHED,RELATED |
| 6 | Accept TTL-Exceeded in | A | I | ICMP | All | localhost | 11/All | ... | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j ACCEPT -p icmp --icmp-type time-exceeded -m state --state ESTABLISHED,RELATED |
| 7 | Accept Parameter-Problem in | A | I | ICMP | All | localhost | 12/All | ... | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j ACCEPT -p icmp --icmp-type parameter-problem -m state --state ESTABLISHED,RELATED |
| 8 | Accept Timestamp-Reply in | A | I | ICMP | All | localhost | 14/. | ... | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j ACCEPT -p icmp --icmp-type timestamp-reply -m state --state ESTABLISHED,RELATED |
| 9 | Accept Address-Mask-Reply in | A | I | ICMP | All | localhost | 18/. | ... | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j ACCEPT -p icmp --icmp-type address-mask-reply -m state --state ESTABLISHED,RELATED |
| 10 | Drop the rest of inbound ICMP | D | I | ICMP | All | localhost | All/All | ... | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j DROP -p icmp |
| 11 | Accept Fragmentation-Needed out | A | O | ICMP | localhost | All | 3/4 | ... | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p icmp --icmp-type fragmentation-needed |
| 12 | Accept Network-Prohibited out | A | O | ICMP | localhost | All | 3/9 | ... | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p icmp --icmp-type network-prohibited |
| 13 | Accept Host-Prohibited out | A | O | ICMP | localhost | All | 3/10 | ... | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p icmp --icmp-type host-prohibited |
| 14 | Accept Communication-Prohibited out | A | O | ICMP | localhost | All | 3/13 | ... | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p icmp --icmp-type communication-prohibited |
| 15 | Drop TTL-Exceeded out | D | O | ICMP | localhost | All | 11/All | this can be used for tracerouting your comp or hosts behind it. | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j DROP -p icmp --icmp-type time-exceeded |
| 16 | Drop TTL-Exceeded out | D | O | ICMP | localhost | All | 11/All | this can be used for tracerouting your comp or hosts behind it. | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j DROP -p icmp --icmp-type time-exceeded |
| 17 | Drop Echo-Reply out | D | O | ICMP | localhost | All | 0/. | used for pinging/tracerouting your comp. | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j DROP -p icmp --icmp-type echo-reply |
| 18 | Drop the rest of Destination Unreachable out | D | O | ICMP | localhost | All | 3/All (except 4,9,10,13 allowed above) | used for tracerouting (scanning) your comp. | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j DROP -p icmp --icmp-type destination-unreachable |
| 19 | Accept the Rest of ICMP out | A | O | ICMP | localhost | All | All/All | ... | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p icmp -m state --state NEW,ESTABLISHED,RELATED |
| 20 | Accept DNS | A | I&O | UDP | dns.isp.com:53 | localhost:1024-65535 | ./. | get your isp's dns and use it/them here. (See below on how to do this.) | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j ACCEPT -p udp -s dns1.isp.com --sport 53 --dport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED iptables -A OUTPUT -j ACCEPT -p udp -d dns1.isp.com --dport 53 |
| 21 | Time Synchronisation/NTP client | A | I&O | UDP | ntp.server.com:123 | localhost:1024-65535 | ./. | If you insist on getting your time from the internet (which opens possibilities to some "replay" attacks), you should use ntp to synch and configure explicitly three different servers. | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j ACCEPT -p udp -s ntp1.isp1.com --sport 123 --dport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED iptables -A OUTPUT -j ACCEPT -p udp -d ntp1.isp1.com --dport 123 iptables -A INPUT -j ACCEPT -p udp -s ntp2.somewhere.org --sport 123 --dport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED iptables -A OUTPUT -j ACCEPT -p udp -d ntp2.somewhere.orgom --dport 123 iptables -A INPUT -j ACCEPT -p udp -s ntp3.bla.com --sport 123 --dport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED iptables -A OUTPUT -j ACCEPT -p udp -d ntp3.bla.com --dport 123 |
| 22 | ICQ | A | I&O | UDP | localhost:1024-65535 | All:5190 | ./. | If you want ICQ, you have to open up somewhat big holes... | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j ACCEPT -p udp --sport 5190 -m state --state NEW,ESTABLISHED,RELATED iptables -A OUTPUT -j ACCEPT -p udp --dport 5190 |
| 23 | Drop the rest of UDP | D | I&O | UDP | All:All | All:All | ./. | maybe you prefer to rely on your default policy to have these dropped, maybe you want to set it explicitly. | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j DROP -p udp iptables -a OUTPUT -j DROP -p udp |
| 24 | POP/Mail Client | A | O | TCP | localhost:1024-65535 | pop.isp.com:110 | ./. | restrict this to the servers you get your mail from (if you use POP, that is. Otherwise you don't need this rule at all.). | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp -d pop.isp.com --dport 110 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED |
| 25 | IMAP/Mail Client | A | O | TCP | localhost:1024-65535 | imap.isp.com:143 | ./. | Restrict this to your IMAP server(s) (if you use IMAP, that is. Otherwise you don't need this rule at all.). | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp -d imap.isp.com --dport 143 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED |
| 26 | SMTP/Mail Client | A | O | TCP | localhost:1024-65535 | smtp.isp.com:25 | ./. | Restrict this to your outgoing mail server (or some relay ;-). If you're running your own smtp server, restrict it to All:25. | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp -d smtp.isp.com --dport 25 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED |
| 27 | Browser (http only) | A | O | TCP | localhost:1024-65535 | All:80 | ./. | You can try to restrict this to remote port 80, although some http connections use port redirections to other ports. Maybe you want to add ports (also so that your browser may use ftp (21) and nntp (119))... | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp --dport 80 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED iptables -A OUTPUT -j ACCEPT -p tcp -m multiport --destination-port 80,443,119,21,3128,8070,8080 -m state --state NEW,RELATED,ESTABLISHED |
| 28 | Browser (shttp) | A | O | TCP | localhost:1024-65535 | All:443 | ./. | Secure http connections almost always use port 443, so it should be okay to restrict this. On the other hand, you may want to have a single browser rule, then remember to include port 443 in that other (port 80 etc.) one. I, for one, have a rule to allow IE shttp but nothing else (my online banking co. requires damn IE but i don't trust it (IE) very much...) | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp --dport 443 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED |
| 29 | Browser (using proxies) | A | O | TCP | localhost:1024-65535 | ProxyIP:ProxyPort | ./. | Maybe you want to use a local or remote proxy on your browsing sessions (Actually, this is pretty advisable - see above). Then you can restrict your browser to access only your proxy (common ports are 3128,1080 and in the 8000-8888 range) - and if it's a local proxy, allow it to access those remote ports that a browser normally needs access to (80,21,119). You may also chain proxies - allow your browser to access only the first proxy, allow this one only to access the second one and the second one to access all sorts of external ports... (How about a cache-adfilter-anonymizing proxy cascade? ;-P) | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp -d localhost --dport 3128 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED iptables -A OUTPUT -j ACCEPT -p tcp -d proxy.isp.com --dport 8080 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED |
| 30 | FTP-Client/Browser (ftp out) | A | O | TCP | localhost:1024-65535 | All:21 | ./. | As you can see from ftp being split into two rules, ftp is a tricky issue. This has mainly to do with ftp using a dedicated connection for dataflow control. You have to think about restricting servers, client applications, using passive ftp, using a stateful inspection firewall etc. Otherwise you open up huge holes. See below for details on ftp. | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp --dport 21 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED |
| 31 | FTP-Client/Browser (ftp in) | A | I | TCP | All:All | localhost:20 | ./. | Also see the previous rule and below for details on ftp. | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j ACCEPT -p tcp --dport 20 -m state --state ESTABLISHED ! --syn |
| 32 | Newsreader | A | O | TCP | localhost:1024-65535 | nntpserver.isp.com:119 | ./. | You can restrict this to the newsserver(s) you're using. | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp -d nntpserver.isp.com --dport 119 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED |
| 33 | SSH-Client | A | O | TCP | localhost:1024-65535 | All:22 | ./. | SSH is a recured version of telnet. (passwords don't travel unencrypted etc.) If you can, try to use ssh instead of telnet, you might even use ssh's port-forwarding to secure e.g. our pop connection. If you want to offer remote access to your own machine, never use telnetd, always use sshd (and check for security patches/vulnerabilities)! | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp --dport 22 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED |
| 34 | Telnet-Client | A | O | TCP | localhost:1024-65535 | All:23 | ./. | Telnet gives you a shell access to a remote machine. Remember that it is not very secure and try to use ssh instead, if possible. Remember that it's not only insofar as it can be used to hack into hosts offering telnet service, but also insofar as you as a client also may send your own security-relevant info (passwords!) unencrypted over the internet. (See previous rule for ssh.) | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp --dport 23 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED |
| 35 | IRC | A | O | TCP | localhost:1024-65535 | irc.ircnetwork.com:6667 | ./. | If you use primarily a single or a handful of irc servers, try to restrict your ruleset to this/these. If not, use All:6667. (Remember that there are so-called "bots", that silently and secretly connect to some hard-coded irc server, join a certain channel and wait for their coder to come there and give them orders on what to do. Maybe you can make their job a little harder by restricting your irc servers - as well as by restricting irc to your irc client... An interesting coverage of this bot stuff can be found at grc.com.) | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp -d irc.ircnetwork.com --dport 6667 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED |
| 36 | IRC-DCC/IRC-Client (ddc out) | A | O | TCP | localhost:7701-7800 | All:All | ./. | IRC features an ftp of sorts. There's a server and a client part to each dcc connection - with every client supporting dcc running a server (warning lights should start blinking here). On clients that support it, configure listening and outbound ports so that you can restrict your firewall rules. I have my client configured to listen on 7700 (see next rule) and to use 7701-7800 for its outbound connections. Since you don't know from the outset how other people have their clients configured, you can't restrict much on the remote side of the connections... IPTables also has some irc connection tracking but i am not sure how much this covers... | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp --sport 7701:7800 -m state --state NEW,ESTABLISHED,RELATED |
| 37 | IRC-DCC/IRC-Client (ddc in) | A | I | TCP | All:All | localhost:7700 | ./. | This is the server (listening) part of DDC. See the previous rule for some more talk about DCC. This rule example also presupposes the client to be configured to listen on port 7700. | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j ACCEPT -p tcp -d localhost --dport 7700 -m state --state NEW,ESTABLISHED,RELATED |
| 38 | Finger | A | O | TCP | localhost:1024-65535 | All:79 | ./. | The Finger protocol allows you to find out if a certain email adress is valid. There are not very much servers offering finger services, but here's how you allow outbound finger requests. | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp --dport 79 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED |
| 39 | WhoIs | A | O | TCP | localhost:1024-65535 | All:43 | ./. | The Whois/Nicname protocol allows you to find out registration information about domains. Some traceroute programs use it for example. And of course you can also use it manually. Here's how you allow outbound whois requests. | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p tcp --dport 43 --sport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED |
| 40 | Ident | R | I | TCP | All:All | localhost:113 | ./. | Reject Ident requests so your mail reacts faster. If your IRC servers won't let you in, then accept it (maybe make different rules for mailserver reject / ircserver accept behaviour). (See below.) | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j REJECT -p tcp --dport 113 --syn --reject-with tcp-reset iptables -A INPUT -j ACCEPT -p tcp -s irc.ircnetwork.com --dport 113 --syn |
| 41 | Accept ARP requests out | A | O | ARP | localhost's MAC address | FF:FF:FF:FF:FF:FF | ./. | Accept localhost (winipconfig.exe (ifconfig on linux) is the command you can use to learn about localhost's MAC addy...) to send out ARP request (OpCode 1) broadcasts to its own subnet (that's the ff:ff:ff:ff:ff:ff). Actually both the ff:ff:etc. and the IP address specify it to be an arp request subnet broadcast. | n/a | n/a | n/a | n/a | n/a |
iptables -A OUTPUT -j ACCEPT -p arp -m mac --mac-source 66:55:44:33:22:11 |
| 42 | Accept ARP replies in | A | I | ARP | gateway's mac address | localhost | ./. | Accept ARP replies (OpCode 2) from your gateway (see below). | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j ACCEPT -p arp -m mac --mac-source 11:22:33:44:55:66 |
| 43 | Termination Rule | D | I&O | All | All:All | All:All | ./. | Drop anything that was not matched yet... | n/a | n/a | n/a | n/a | n/a |
iptables -A INPUT -j DROP iptables -A OUTPUT -j DROP |
| 99 | Complete Ruleset Samples | - | - | - | - | - | - | Here you can find sample rulesets for the different firewall programs. Sometimes they're just screenshots, sometimes, textfiles, sometimes complete pages... | Look'n'Stop | Kerio | Sygate | Outpost | ZAP | IPTables |