Linux Firewall
Linux Firewall
Linux has firewall capabilities built into the operating system. This has been a part
of the Linux operating system for many years, with occasional improvements in
the technology.
3.7.1 Iptables
The first widely used Linux firewall was called ipchains. It was essentially a chain
of rules for filtering traffic. It was first introduced in version 2.2 of the Linux
kernel and superseded the previous ipfwadm (which was not widely used). The
more modern iptables replaced ipchains and is the primary firewall for Linux. The
iptables service was first introduced in Linux kernel 2.4.
Iptables requires some configuration. You can do it through the GUI (KDE,
GNOME, etc.) but the shell commands are common to most distributions. Let’s
take a look at some common basic configuration.
To cause iptables to function as a basic packet filtering firewall, you need these
commands:
iptables -F
iptables -N block
iptables -A block -m state --state ESTABLISHED,RELATED -j ACCEPT
Obviously, that is the most basic and essential iptables configuration. However,
here are some others.
iptables –L
To allow communication on a specific port, SSH port 22 and HHTP port 80 for
example use:
Also there are several flags that can be passed to the iptables command. Below are
listed the most common flags and what they do. Several other flags exist but are
not listed.
--dport: The destination port required for the rule. A single port can be given or a
range.