Home Blog Archive Software Debian: Firewall setup - how to

Debian: Firewall setup - how to

  • Oct 30, 2025
  • 498
  • 0

For safety, you should use it under Debian for a Firewall. You'll learn in this hands-on advice on how the device works.

Firewall under Debian setup so it works

  1. Log in to Debian as the Administrator and open the Terminal.
  2. Type the command "nano /etc/iptables.firewall.rules", to activate the Firewall.
Debian: setting up Firewall

Commands and rules insert

This file is still empty. Insert in the file the following commands and rules:
  • *filter
  • -A INPUT-i lo -j ACCEPT
  • -A INPUT-d 127.0.0.0/8 -j REJECT
  • -A INPUT-m state --state ESTABLISHED,RELATED -j ACCEPT
  • -A INPUT-p tcp --dport 80 -j ACCEPT
  • -A INPUT-p tcp --dport 443 -j ACCEPT
  • -A INPUT-p tcp -m state --state NEW --dport 22 -j ACCEPT
  • -A INPUT-p icmp -j ACCEPT
  • -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied:" --log-level 7
  • -A OUTPUT-j ACCEPT
  • -A INPUT-j DROP
  • -A FORWARD -j DROP
  • COMMIT
  • Save the Changes with [Ctrl] + [O] and exit Nano Editor with [Ctrl] + [X].

Further steps: Firewall under Debian setup

  1. You have saved the Changes, you need to you with "iptables-restore < /etc/iptables.firewall.rules" import.
  2. Thus, the rules are automatically enabled, enter the command "nano /etc/network/if-pre-up.d/firewall" a.
  3. Here, you will then need to add the following to make it work:
  4. #!/bin/sh
  5. /sbin/iptables-restore < /etc/iptables.firewall.rules
  6. With "chmod +x /etc/network/if-pre-up.d/firewall" make the file executable and the Firewall is ready to be decorated.
In our next tip we will show you how to work under Debian Linux, a Kernel Update to perform.

YOU MAY ALSO LIKE

0 COMMENTS

LEAVE A COMMENT

Human?
1 + 3 =