Linux for network engineers lab 5 of 14
Firewall and NAT with iptables
You turn a Linux box into the depot firewall: masquerade, a stateful default-deny policy, protection for the box itself, a published web server, logging, and rules that survive a reboot.
Run this lab
It needs Lite: its 5 nodes are set to 5 vCPU and 2,560 MB in total. That fits the free demo too.
In your workspace: Shared, then Linux for network engineers guided labs, then 05 - Firewall and NAT with iptables
- Level
- Intermediate
- Time
- About 80 minutes
- Nodes need
- 5 vCPU, 2,560 MB
- Smallest plan
- Lite
The scenario
Kestrel's Doncaster depot has one public address, a LAN, a small DMZ with the web app, and no firewall budget. FW is a Linux box with three ports. By the end of today it has to share the public address, allow only what the depot needs, keep the Internet away from its own admin page, and publish the web app.
| Device | Interface | Address | Role |
|---|---|---|---|
| H1 | eth0 | 10.5.10.10/24 | LAN PC, gateway .1 |
| SRV | eth0 | 10.5.20.10/24 | DMZ server, gateway .1, app on TCP 8080 |
| FW | eth0 | 10.5.10.1/24 | LAN |
| FW | eth1 | 10.5.20.1/24 | DMZ |
| FW | eth2 | 203.0.113.2/29 | public side; admin page on TCP 8000 |
| R1 | Gi0/0, Gi0/1 | 203.0.113.1/29, 198.51.100.1/24 | the ISP (no route to Kestrel's private addresses) |
| NET1 | eth0 | 198.51.100.10/24 | a host on the Internet, web on 80 and 8888 |
| Device | Runs | How to log in |
|---|---|---|
| H1, SRV, NET1 | Alpine Linux 3.20 | root, no password. |
| R1 | Cisco IOSv 15.9 | The console opens at >; enable has no password. |
| FW | Alpine Linux 3.16 with iptables and iproute2 | Opens on a menu: press 5, then Enter, for a root shell. |
What you’ll practise
- Follow a packet through the netfilter tables and chains
- Share a public address with MASQUERADE
- Write a stateful default-deny FORWARD policy
- Protect the firewall with INPUT rules
- Publish a server with DNAT and the matching filter rule
- Log drops, save rules and read the matching nft syntax
The tasks
- Start the Linux nodes
- Read the tables
- Share one public address
- Default deny, stateful
- Publish the web app
- Log what you drop
The Lab Tasks pane has the scenario, these tasks, the checks to run, hints and the full solution.
Topology and devices
The network as it opens in EVE-NG, drawn from the lab’s own canvas, and the image each node runs.
Every link, as text
- FW
eth0to H1eth0 - FW
eth1to SRVeth0 - FW
eth2to R1Gi0/0 - R1
Gi0/1to NET1eth0
| Node | Device | Image in Add Node | Set to |
|---|---|---|---|
| H1 | Alpine Linux | clbalpinebase-alpine-base-3-20-3 | 1 vCPU, 512 MB |
| SRV | Alpine Linux | clbalpinebase-alpine-base-3-20-3 | 1 vCPU, 512 MB |
| NET1 | Alpine Linux | clbalpinebase-alpine-base-3-20-3 | 1 vCPU, 512 MB |
| R1 | Cisco IOSv | vios-adventerprisek9-m.spa.159-3.m9 | 1 vCPU, 512 MB |
| FW | Alpine WAN emulator | clbalpinewanem-alpine-3-16-2-wanem | 1 vCPU, 512 MB |
How to open this lab
Sign in to your workspace at
lab.cloudlabbox.com.In File Manager, open Shared, then the folder
Linux for network engineers guided labs.Open
05 - Firewall and NAT with iptablesand start its nodes, then open Lab Tasks for the scenario and the steps.
The lab is read-only. You can start the nodes and configure the devices, but changes to the topology can’t be saved. To change it, rebuild it in your own folder.
More Linux for network engineers labs
All Linux for network engineers labs
Related labs in other courses
CloudLabBox is independent of Cisco, CompTIA, the Linux Foundation and the Linux Professional Institute. The lab follows exam topics and isn’t vendor training material; vendor names identify the exams and the images in the workspace.