Troubleshooting iptables
Source: microhowto.info
Content
Objective
To ensure that iptables has been correctly configured.
Background
iptables is a component of the Linux kernel that allows IPv4 traffic to be manipulated as it traverses the network stack. Its two main uses are:
- packet filtering (firewalling) and
- network address translation (NAT).
The behaviour of iptables is controlled by rules, each of which specifies the action to be taken if a packet meets a particular set of conditions. The rules are organised into chains, and the chains into tables. Chains may be either built-in or user-defined.
For more information about the architecture and configuration of iptables see:
- the netfilter/iptables project homepage,
- the iptables tutorial and
- the Packet Filtering and NAT HOWTOs
Symptoms
The most likely symptoms of an iptables configuration error are:
- traffic being dropped or rejected,
- traffic not being NATted when it should have been,
- traffic being NATted when it shouldn’t have been, or
- traffic being NATted to the wrong address.
A wide variety of other effects are possible, but unlikely unless the configuration is an unusual one.
Scenario
Suppose that a machine has been configured to act as a boundary router between a local area network (connected to interface eth0 with the address 192.168.0.1/24) and the public Internet (connected to interface ppp0 with the address 203.0.113.144/32). The default gateway is 203.0.113.1. Because the local area network uses a private address range, iptables on the boundary router has been configured to SNAT them to its public IP address.
In order to test this configuration you have attempted to ping a machine on the public Internet (198.51.100.1) from a machine on the local area network (192.168.0.2), but this has failed.