Search Our Database

How to check open port via SSH

Last updated on |

Introduction

To check the firewall status and determine which ports are open or blocked on a Linux system, there are several tools and commands available. The specific method depends on the type of firewall installed and in use on your system. Knowing how to check the firewall status and port accessibility is crucial for managing system security, troubleshooting connectivity issues, and ensuring that only the necessary services are exposed to the network.

 

Prerequisites

  • SSH access to the server with root privilege. If you SSH the server as a non-root user, switch to root with sudo su

 

Step 1: Check on netstat/ss

  • You may use netstat or ss to view the running ports on your server
telnet -tulnp
ss -tulnp
  • You can grep a specific port for a deeper look
telnet -tulnp | grep :80
ss -tulnp :80
Note : You may change :80 to the port you are checking on

 

Step 2: Check on firewall

Next, you may check if the port is allowed in your firewall configurations

csf

  • Open /etc/csf/csf.conf with your desired text editor. For this example, we may use vi /etc/csf/csf/conf.
Note : You may refer this article to guide you on using text file editor in SSH
  • Once inside the file, look for TCP_IN, TCP_OUT, UDP_IN and UDP_OUT to inspect allowed inbound and outbound ports for both TCP and UDP

iptables

  • You can check allowed ports in iptables by viewing existing rules with :
iptables -L -n

Note : If there is no rules when you check with iptables -L -n, iptables will allow all ports by default

 

Step 3: Test with telnet

  • From your local machine, you can try to test the port connectivity with telnet
telnet [IP ADDRESS] [PORT]
  • If the port is accessible, it will show output such as :
# telnet 216.58.199.238 80
Trying 216.58.199.238...
Connected to 216.58.199.238.
Escape character is '^]'.

 

Conclusion

By using tools like , you can effectively inspect firewall rules and identify which ports are open or blocked on your Linux system—even over an SSH session. Understanding and regularly auditing open ports is essential for maintaining a secure server environment.

If you have any technical inquiries, feel free to contact us at support@ipservervone.com