You are on page 1of 1

iptables

Iptables provides packet filtering, network address translation (NAT) and other packet mangling. Two of
the most common uses of iptables is to provide firewall support and NAT.Configuring iptables manually
is challenging for the uninitiated. Fortunately, there are many configuration tools (wizards) available to
assist: e.g., fwbuilder, bastille, ferm (wiki page), ufw (Uncomplicated Firewall, from Ubuntu).

Viewing current configuration


See what rules are already configured. Issue this command:

iptables –L

The output will be similar to this:

Chain INPUT (policy ACCEPT)


target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination

This allows anyone access to anything from anywhere.

Storing iptables rules in a file

Once you are happy, save the new rules to the master iptables file:

iptables-save > /etc/iptables.up.rules

To make sure the iptables rules are started on a reboot we'll create a new file:

pico /etc/network/if-pre-up.d/iptables

Add these lines to it:

#!/bin/sh
/sbin/iptables-restore < /etc/iptables.up.rules

The file needs to be executable so change the permissions:

chmod +x /etc/network/if-pre-up.d/iptables

You might also like