Linux Firewalls (Ubuntu Iptables)
Linux Firewalls (Ubuntu Iptables)
Introduction
Linux Firewalls is the way to make our Linux OS more secure and safe because it enables you to
control your connection ports and your inbound and outbound traffic. To control this inbound and
outbound traffic, Linux OS uses a software called iptables. IPTables is actually a net filter software
which is integrated with the kernel implementation, it also provides filtering features that can filter
the inbound and outbound in routed traffics to our computer system.
IPTables Organization
The iptables organizes its information in tables, each tables consists of number of chains and each
chain consists of many rules, these rules are responsible for controlling the system traffic. Each
Chain has a default taken action called chain default policy and it used when there is no rule created
for a specified service or traffic.
Main IPTabels
1. filter table is the default table.
2. nat table is used to tell the kernel what connections to change and how to change them.
3. mangle table is mainly used for mangling packets.
IPTables Useful Commands
$dpkg-query -l iptables used for listing the packages that matches iptables.
$dpkg-query -s iptables used for recognizing the status of the iptable packages.
$dpkg-query -L iptables used for listing the files and libraries that related to the iptables.
$iptables -h used for getting the iptables help.
$iptables -L used for listing the table chains and the rules of each chain, to specify a
certain table use -t followed by the name of the table.
$iptable -A used to Append a rule to a certain chain.
$iptables -I used for Inserting a rule in a location not only adding it to the
tail of the chain of rules.
$iptable -D used for deleting a rule from a chain in a table.
$iptable -F used for flushing all rules of a chain.
$iptable-save used for saving all current rules and chains of the system in a file.
$iptable-restore used for restoring saved rules from a file.
PCLinux Machine with one Network Card Named eth0 for Virtual LAN
Ubuntu Machine with Network Card called eth0 for NATing
and another Network Card called eth1 for Virtual LAN
Host Machine with a lot of Network Cards
One is called Virtual Box Host-Only Adapter for Virtual LAN
Filter Table (INPUT & OUTPUT Chains)
Example#1
Write a firewall rule to prevent pinging the Ubuntu machine from the PCLinux machine.
Exercise#2
Write firewall rules to prevent any client except the PCLinux Machine from accessing the web
server on the Ubuntu Machine.