Simple YAML iptables script

Опубликовано: 22 Апрель 2026
на канале: Solve Computer Science
105
1

iptables is a tool for network packet filtering. In this video I'll show you a script which acts as a frontend to iptables commands and it siplifies administration.

Firstly we'll see the configuration file as well as a simple test with a webserver to see how the firewall acts.

This script is not a simple frontend: given a file with a list of IP addresses it is able to whitelist them. This is useful for geographical-based IP filtering. Files with IP addresses sorted by country exist on websites such as ipdeny.com. The Python script will download a specified file then create and apply the iptables rules.

All the configuration is done through a YAML file.

The script is known to work on Debian GNU/Linux.

LINKS

📝 Contact me for you project (Google form): https://SolveComputerScience.github.i...
📝 Contact me for you project (Nextcloud form): https://SolveComputerScience.github.i...
💼 Fiverr profile: https://SolveComputerScience.github.i...
Script: https://codeberg.org/frnmst/ftutorial...
Configuration: https://codeberg.org/frnmst/ftutorial...
Systemd service unit file: https://codeberg.org/frnmst/ftutorial...

CHAPTERS

0:00 Intro
0:11 Explaining the simpler options: dry run, packet policy, accepted IPs
1:41 The `patch_rules` configuration block
2:22 The `input_ports` configuration block
3:07 The `set_patch_rules_first` option: what it does
3:37 Testing a webserver behind the firewall with the port closed
5:29 Testing a webserver behind the firewall with the port opened
6:02 Checking the iptables rules after opening the port
7:38 Showing the iptables rules after closing the new port
8:30 The Python script: resets, default chains, rules, and policies
10:48 Other functions in the Python script
11:05 Other considerations for the script and the Systemd unit files
13:48 Outtro

#firewall #iptables #python #ipaddress #solvecomputerscience