Select Page

Iptables Tutorial – Securing your Debian server with Linux Firewall
December 21, 2017
Iptables Tutorial – Securing your Debian server with Linux Firewall

iptables is a command-line firewall utility that uses policy chains to allow or block traffic. When a connection tries to establish itself on your system, iptables looks for a rule in its list to match it to. If it doesn’t find one, it resorts to the default action.

Step 1 – Installing Iptables Linux Firewall

apt-get update
apt-get install iptables

Step 2 – Setting chain rules

Login as root user and run the following command

vim /etc/iptables.rules

Defining chain rules, for example

Open a port
iptables -I INPUT -p tcp --dport 23456 -j ACCEPT
Block an IP
iptables -A INPUT -s 88.88.188.188 -j REJECT
Delete a rule
iptables -D INPUT -s 221.194.47.0/24 -j REJECT

Step 3 – Start Iptables Service On Boot

iptables-save > /etc/iptables.up.rules
echo -e '#!/bin/bash\n/sbin/iptables-restore < /etc/iptables.up.rules' > /etc/network/if-pre-up.d/iptables
chmod +x /etc/network/if-pre-up.d/iptables

Save iptables rules

iptables-save > /etc/iptables.up.rules

Other Commands

Check all current rules

iptables -L -n

Update iptables

apt-get update iptables

Status, restart iptables

ervice iptables status
service iptables restart

By Jackie Sung

Jackie Sung, also known by his nick-name KK, always strives for the best and learn from the best. Working and living as a Freelance Web Engineer/ Web Developer & Designer/ Amateur Youtuber/ Husky Lover.

Related Articles

How To Install and Configure Proxmox VE on Hetzner Server

How To Install and Configure Proxmox VE on Hetzner Server

Proxmox VE is a complete open-source platform for enterprise virtualization. With the built-in web interface you can easily manage VMs and containers, software-defined storage and networking, high-availability clustering, and multiple out-of-the-box tools on a single solution.

read more

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This