How to Set Up and Configure a Firewall in Webmin (Linux Firewall Module)

Priya

Content Writer & Researcher

Last Updated: 14 August 2026
How to Set Up and Configure a Firewall in Webmin (Linux Firewall Module)
πŸ–₯️

Is Your Webmin Server Running Without a Firewall?

An unprotected server exposes every port to the internet, inviting brute force attacks and data breaches. CloudHouse's server hardening team sets up and audits iptables firewall rules for Webmin-managed servers β€” so you're protected from day one.

πŸ–₯️12,400+PCs Fixed
⭐4.9β˜…Google Rating
⚑<15 minAvg. Response
πŸ›‘οΈISO 27001Certified

Webmin gives you a powerful graphical interface for managing a Linux server β€” but that same web interface is exposed on port 10000 by default, reachable by anyone on the internet. Without a firewall, your server accepts connections on every port, and bots are constantly scanning for open SSH, database, and control panel ports. This guide walks you through setting up a complete firewall using Webmin's built-in Linux Firewall module, blocking unwanted traffic while keeping your services accessible.

Understanding Webmin's Firewall Options

Webmin offers two built-in firewall management modules:

  • Linux Firewall (iptables): Directly manages iptables rules β€” the underlying Linux firewall. Works on all distributions. More granular control.
  • FirewallD: A higher-level firewall manager available on CentOS/RHEL/AlmaLinux. Uses zones and services. Easier to manage but less granular than raw iptables.

This guide covers the Linux Firewall (iptables) module, which works on all Webmin-supported Linux distributions including Debian, Ubuntu, CentOS, AlmaLinux, and Rocky Linux. If you're on AlmaLinux/Rocky and FirewallD is active, disable it first or use the FirewallD module instead to avoid conflicts.

πŸ’‘ None of these worked? Skip the guesswork.

Get Expert Help β†’

Step 1: Access the Linux Firewall Module

1Log in to Webmin at https://your-server-ip:10000 as root.

2. Navigate to the Linux Firewall module: In the left sidebar, go to Networking > Linux Firewall. If you don't see it, go to Webmin > Webmin Configuration > Webmin Modules and install it.

3. If no rules exist yet, click "Setup Firewall" to initialize the module with a basic ruleset. Choose the option to "Block all except SSH, IDENT, ping and high ports" as your starting template β€” this gives you a safe default while you build your custom rules.

Step 2: Understand the Default Chains

The Linux Firewall module displays three main chains:

  • INPUT: Rules for traffic coming into your server. This is where you block or allow inbound connections.
  • OUTPUT: Rules for traffic going out of your server. Usually left open by default.
  • FORWARD: Rules for traffic being routed through your server. Only relevant if your server acts as a router.

For securing a standard web server, you'll focus almost entirely on the INPUT chain.

Step 3: Set a Safe Default Policy

The default policy is what happens to traffic that doesn't match any rule. For INPUT, you want to DROP all traffic that isn't explicitly allowed.

4. In the Linux Firewall module, find the "Default action for packets not matched below" setting for the INPUT chain and set it to DROP. This means any connection that doesn't match an allow rule will be silently rejected β€” the most secure default.

5. Before saving, make absolutely sure you've added a rule to allow your current SSH connection (port 22). If you drop all traffic without an SSH allow rule, you will be locked out of the server.

Step 4: Create Allow Rules for Essential Services

Add rules in this order β€” they are processed top to bottom and the first match wins:

6. Allow established/related connections (critical β€” ensures existing sessions aren't broken):

  • Action: ACCEPT
  • Connection state: ESTABLISHED, RELATED
  • This allows responses to connections your server initiates (e.g., yum/apt updates, outbound mail)

7. Allow loopback interface (localhost traffic):

  • Action: ACCEPT
  • Input interface: lo

8. Allow ICMP (ping):

  • Action: ACCEPT
  • Protocol: ICMP
9Allow SSH (port 22):
  • Action: ACCEPT
  • Protocol: TCP
  • Destination TCP or UDP port: 22
10Allow HTTP and HTTPS (web traffic):
  • Action: ACCEPT
  • Protocol: TCP
  • Destination port: 80, 443
11Allow Webmin (port 10000):
  • Action: ACCEPT
  • Protocol: TCP
  • Destination port: 10000

Optional β€” add your IP only: If you want to restrict Webmin access to your IP address only, also set Source address to your static IP. This prevents anyone else from even reaching the Webmin login page.

12Block MySQL/MariaDB from external access (port 3306):
  • Action: DROP
  • Protocol: TCP
  • Destination port: 3306

MySQL should never be exposed to the internet unless you have a specific reason. Applications connect to it on localhost.

13Block unwanted mail ports if you don't run a mail server:
  • DROP ports: 25, 465, 587, 110, 143, 993, 995
14Block FTP (ports 20-21) if you use SFTP instead:
  • DROP port: 21
15Click "Apply Configuration" in the Webmin Linux Firewall module. Webmin will immediately apply the iptables rules.

16. Verify you can still connect via SSH by opening a new terminal session before closing your current one. Do NOT close your current SSH session until you've confirmed the new session works β€” if a rule mistake locked you out, you'll need your existing session to fix it.

17. Make rules persistent across reboots. Webmin's Linux Firewall module can save rules automatically on boot if you enable the option "Activate at boot time?" β€” check this checkbox in the module. Alternatively, use the iptables-save mechanism:

iptables-save > /etc/iptables/rules.v4
# On RHEL/CentOS:
service iptables save

Step 7: Restrict Webmin to Your IP Only (Recommended)

The most effective Webmin security hardening is restricting port 10000 access to only your IP address or VPN exit IP. This means that even if your Webmin password were compromised, attackers cannot reach the login page at all.

18. In the Linux Firewall module, modify the Webmin allow rule (Step 11 above) to also set:

  • Source IP or network: your.static.ip.address/32

If your IP is dynamic, consider using a VPN and restricting to the VPN subnet instead.

19. Also restrict Webmin access in Webmin itself: Go to Webmin > Webmin Configuration > IP Access Control and add your IP to the allow list. This provides a second layer of protection if the firewall rule is accidentally removed.

Step 8: Verify the Active Firewall Rules

Always verify rules are active after applying them.

20. Via SSH, list all INPUT rules:

iptables -L INPUT -n --line-numbers -v

This shows each rule, the packet/byte count (useful for seeing which rules are actually being matched), and the protocol/port/address criteria.

21. Test that blocked ports are actually blocked from an external machine:

nmap -Pn -p 3306,21,25 your-server-ip

Blocked ports should show as filtered, not open.

For ongoing server security management including firewall audits, intrusion monitoring, and hardening reviews, CloudHouse's server hardening service provides comprehensive protection for Webmin-managed Linux servers.

Conclusion

A properly configured iptables firewall via Webmin's Linux Firewall module is one of the most effective security controls you can put on a Linux server. The key principles are: default DROP policy for INPUT, allow only the services you explicitly need, restrict Webmin access to trusted IPs, and verify rules both in the Webmin GUI and via SSH after every change. A firewall configured this way blocks the vast majority of automated attack traffic before it ever reaches your applications.

Get the Free IT Security Checklist (PDF)

10-point security audit checklist for servers, websites, and email β€” print it and run through it today.

Is your business properly protected from cyber threats?

Our Security Managed Service covers vulnerability scanning, firewall management, email filtering, and incident response β€” so breaches stop before they start.

  • Continuous vulnerability scanning and patching
  • Email security: SPF, DKIM, DMARC, anti-phishing
  • Firewall, WAF, and intrusion detection setup
  • Incident response within 15 minutes
See Pricing Plans β†’

What our customers say

β€œSuspected ransomware on a Sunday. CloudHouse contained it, cleaned it, and had us operational β€” all within 4 hours.”

Thomas J.

IT Director

β€œTheir security audit found 3 critical vulnerabilities we'd been running for months. Fixed them the same day.”

Kavitha R.

CISO

Frequently Asked Questions

Log in to Webmin at https://your-server-ip:10000 as root, then go to Networking > Linux Firewall in the left sidebar. If the module isn't visible, go to Webmin > Webmin Configuration > Webmin Modules to install it. Once opened, click 'Setup Firewall' if no rules exist yet to initialize with a safe default ruleset.

Need this done for you?

Server Hardening and Security

Lock down your servers, SSL and firewalls with certified engineers.

Learn more

Book your free 15-minute diagnosis

A certified technician will call you back within 15 minutes during business hours.

Share this article

Leave a Comment

Comments (0)

Loading comments...