Steps to check the opened ports in IP tables

Introduction

IPTables is a user-space utility in Linux used to configure and manage the Netfilter firewall framework. It helps administrators control incoming and outgoing network traffic based on defined security rules. Checking opened ports in IPTables is an essential task for system administrators to verify firewall configurations, troubleshoot connectivity issues, and ensure that only required services are accessible from external networks.

This guide explains how to check opened ports configured through IPTables on a Linux server

Prerequisites

Before proceeding, ensure the following requirements are met:

  • A Linux server with IPTables installed and configured
  • Root or sudo access to the server
  • Basic knowledge of Linux command-line operations
  • SSH access to the server terminal

You can verify whether IPTables is installed by running:

iptables --version

IMPLEMENTATION

To view the ports that are already opened in the server, execute the following command.

netstat -plan |grep LISTEN

Steps to open a new port in IP tables

Before opening a port, you should be aware of why are you opening the port and what is the port being used for.

Save the existing IP tables.

root@server [~]# /etc/init.d/iptables save
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]

To open a port, execute the commands below.

iptables -A allowed -p tcp –dport portno -s IPaddress -j ACCEPT
iptables -A allowed -p udp –dport portno -s IPaddress -j ACCEPT

To allow all IP address,

iptables -A INPUT -i eth0 -p tcp -m tcp –dport portno -j ACCEPT

Check whether the Port is allowed.

root@server [~]# iptables -nL | grep :3306
ACCEPT tcp — 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306
ACCEPT tcp — 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306

 

CONCLUSION

Checking opened ports in IPTables is an important step in maintaining Linux server security and troubleshooting network access issues. By reviewing INPUT chain rules, filtering ACCEPT entries, and verifying active listening services, administrators can ensure that only necessary ports are exposed to external traffic. Regular firewall audits help reduce security risks and maintain proper server access control.

admin

Our team has expertise across software and web development, WordPress, e-commerce, mobile applications, UI/UX, cloud and infrastructure, DevOps, CI/CD, API integration, security, testing, automation, and technical support. The team also works with AI-based software solutions, LLMs, AI workflows, AI agents, and intelligent application development to help businesses automate processes and build smarter digital solutions. We focus on developing, deploying, maintaining, and optimising secure, scalable, and reliable technology solutions while helping businesses adopt modern technologies and drive digital transformation.

Leave a Reply

Scroll to Top