Select Page

Iptables Tutorial – Securing Your Debian Server With Linux Firewall
Posted on December 21, 2017
Iptables Tutorial – Securing Your Debian Server With Linux Firewall

Jackie, 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. If you love one of these things that I love, we already have something in common.

Jackie Sung

Owner

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

service iptables status
service iptables restart

Related Articles

0 Comments

Submit a Comment

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

Pin It on Pinterest

Share This