Page 1 of 1

How to Open Ports in Iptables on a Linux Server

Posted: Tue Feb 18, 2025 6:53 am
by bitheerani319
Iptables is a basic and built-in Linux server firewall. Iptables is used to configure, maintain, and verify tables of IP packet filtering rules in the Linux kernel. It is extremely powerful and configurable, but as a result, due to the abundance of options and features, it has become incredibly complex to manage. For this reason, iWeb recommends ConfigServer Security & Firewall (CSF) for managing iptables configuration. CSF is a simplified interface that makes adding or removing IP addresses from your firewall more convenient.

In this article, we will look at how to open/remove a greece whatsapp data on a server using a firewall. All manipulations must be performed under a user with root privileges.

Before changing or adding rules to the firewall, it is worth making a backup copy of the configuration file. So that in case of any problems with the Iptables configuration, it is possible to restore the rules from the backup copy. We perform a backup copy with the command:

iptables-save > IPtablesbackup.txt

If you need to check the list of existing rules, use the command:

sudo iptables -L

Once the copy is made, you can proceed to adding new rules. You can open the port using the command with the following syntax .

sudo iptables -A INPUT -p tcp --dport 8888 -j ACCEPT

where 8888 is the port number that needs to be opened.

You can remove an open port in a similar way.

sudo iptables -D INPUT -p tcp --dport 8888 -j ACCEPT

There are also often cases when security measures require blocking access from certain addresses or opening access only to a specified address. For this, you can use the following commands:

block IP completely
iptables -A INPUT -s IP -j DROP

In place of the IP argument, specify the address that needs to be blocked.
To find out the IP address of a computer, use the free online service .

block IP only for a specific port:


iptables -A INPUT -p tcp -s IP --dport PORT -j DROP

grant access to the system from a specific address
iptables -A INPUT -s IP -j ACCEPT

allow access from an address to a specific port
iptables -A INPUT -p tcp -s IP --dport PORT -j ACCEPT

To check and display the current list of temporary allowed and denied IP records with their TTL and comments, use the command:.