Skip to main content
← All projects

Linux firewall lab · Traffic filtering & validation · 2025

Linux Firewall Engineering: Filtering & Access Control


Objective & background

I configured a Linux gateway with iptables to control traffic between two virtual networks. The work covered default policies, stateful forwarding, a client-specific Telnet exception, ICMP rate limiting, and an experiment with connection-rate controls. I verified behavior using client commands and firewall counters, with mixed results in the final scan-control stage.

Lab environment

  1. 01

    Outside · LAN 2

    Kali 192.168.1.11 and Windows XP 192.168.1.12

  2. 02

    Linux gateway

    eth0: 192.168.1.1/24 · eth1: 192.168.2.1/24

  3. 03

    Inside · LAN 1

    Metasploitable 192.168.2.10

Two virtual LANs connected by a Linux gateway; “outside” refers to the other lab subnet.

The rules ran on the gateway. INPUT covered traffic addressed to the gateway itself, OUTPUT covered traffic it originated, and FORWARD covered traffic crossing between the LANs. I flushed rules and reapplied the default policies between experiments, so the following stages represent separate configurations.

Default policy & stateful forwarding

I set INPUT and FORWARD to DROP and left OUTPUT at ACCEPT. This required explicit permission for traffic entering or crossing the gateway while allowing the gateway to initiate traffic. I then permitted new connections from the inside interface and established or related return traffic from outside.

Default policies and forwarding rules recorded in the first experiment
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

iptables -A FORWARD -i eth1 -o eth0 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
The initial default policies restricted inbound and forwarded traffic.
State-based rules allowed inside-initiated connections and their return traffic.

The inside host successfully pinged Kali with three replies and no loss. My report also describes a failed inbound ping, but that screenshot targets 192.168.1.10 rather than the inside host at 192.168.2.10. It therefore does not reliably verify the intended inbound-blocking test.

Client-specific access control

For the Telnet exception, I identified the Windows XP machine’s MAC address with ipconfig /all and allowed TCP port 23 from that source on the outside interface. Windows reached a Metasploitable login session, while the Kali attempt remained at “Trying”. The matching firewall counter also increased.

The permitted Windows client established a Telnet session.
The Kali connection did not progress to a login prompt during the recorded test.

This was an access-control exercise using a legacy lab service. A MAC match identifies a source on the adjacent network segment; it is not a substitute for user authentication or an encrypted remote-access protocol.

ICMP rate limiting

In a fresh ruleset, I allowed incoming echo requests at one packet per second with a burst allowance of three, and allowed echo replies back out. Normal ping received five replies from five requests. The flood test sent 757 packets and received 14 replies, approximately 98% loss.

ICMP rules recorded in the isolated rate-limit experiment
iptables -A FORWARD -i eth0 -o eth1 -p icmp --icmp-type echo-request -m limit --limit 1/second --limit-burst 3 -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -p icmp --icmp-type echo-reply -j ACCEPT
Normal-rate ICMP succeeded in the isolated rate-limit experiment.
The flood test experienced approximately 98% packet loss.

The limit match supplies a shared allowance for packets matching this rule. The result shows rate restriction in this test, not a general denial-of-service defense or an ability to distinguish intent.

Scan-control experiment

For the final stage, I added service exceptions and experimented with the recent module to track new TCP traffic from Kali. My written configuration described a ten-hit threshold over 30 seconds. However, the captured final rules use a 15-second window and place HTTP accepts before the recent checks. These are materially different configurations.

The saved rules and counters expose differences from the written scan-control configuration.

Reviewing that screenshot also reveals a broad ACCEPT for new TCP traffic below the threshold, duplicate entries, and zero hits on the scan DROP rules. As written, the broad ACCEPT can permit traffic beyond the intended service exceptions, and the earlier HTTP accepts bypass the later checks. The screenshot does not demonstrate that the rate-control drop rule triggered.

Results & validation

Final scan-control stage: evidence takes precedence over success labels
TestRecorded evidence
Windows TelnetAn established Metasploitable session is shown.
Kali pingFive requests, zero replies: the screenshot contradicts the success label.
Kali HTTPcurl timed out. Outbound HTTP counters increased, with no matching return traffic shown.
Kali Nmap“Host seems down”; no completed port scan is shown.
recent thresholdThe final listing shows zero hits on the scan DROP rules.
The final-stage screenshot shows 100% loss, contrary to the report’s success label.
curl did not establish a working HTTP exchange within the test timeout.
Nmap stopped at host discovery; this is not proof that port enumeration was prevented.

The HTTP counters show that packets matched an allow rule; they do not establish a completed TCP handshake or HTTP response. My original report suggested an environment issue, but the supplied evidence does not establish the cause. Nmap’s discovery result likewise cannot establish that the host cannot be enumerated.

Limitations & next tests

A follow-up would first reconcile the active rules with the intended policy: remove duplicate entries, restore only the required service permissions, and check rule order. I would then retest each allowed flow in both directions, recording counters and packet captures to locate the missing replies. These changes and tests have not been performed as part of this write-up.

For scan controls, I would compare discovery-enabled scanning with a lab scan that skips discovery, then test bursts above and below the threshold, slower probes, and multiple sources. A rate threshold may affect legitimate clients opening many connections while missing slower activity.

Lessons learned

The stateful-forwarding and ICMP experiments gave me practical experience with interface direction, connection state, and measurable filtering behavior. Reviewing the final stage reinforced that a rule counter is only one piece of evidence: it must agree with the client result and return path. A timed-out command or incomplete scan should lead to investigation, rather than being counted automatically as a successful security control.

Sources & tools used

iptables extension reference ↗Reference for the limit and recent matches used when reviewing the recorded rules.

Nmap: Host Discovery Controls ↗Explains why a failed discovery probe does not establish that port scanning is prevented.

Tools used

  • Linux
  • iptables
  • Nmap
  • VMware