How to Check Opened Port on Linux VPS Server

In the Linux operating system, the “netstat” command can be used to check the opened ports on a VPS (Virtual Private Server) server. Opened ports are important to identify because they are a gateway for incoming and outgoing traffic to the server. Sometimes, the server’s firewall or other configuration can prevent traffic from reaching the intended port, leading to service disruptions or unexpected results. Checking opened ports can help diagnose these issues and ensure that the server is functioning as intended. In this guide, we will go through the steps to check opened ports on a Linux VPS server.

Step 1: Connect to the VPS server

Before we can check the opened ports, we need to connect to the VPS server. This can be done using an SSH (Secure Shell) client. On a Mac or Linux machine, you can use the built-in terminal application. On Windows, you can use a third-party application like PuTTY. To connect, open the terminal application and enter the following command, replacing “server_ip_address” with the IP address of your VPS server:

ssh root@server_ip_address

You will be prompted to enter the password for the root user. Enter the password and press Enter.

See also  How to Check SELinux Status on RHEL 6

Step 2: Check the opened ports

Once connected to the VPS server, we can use the “netstat” command to check the opened ports. Enter the following command:

netstat --listen --tcp -n

This command will display a list of all opened TCP ports on the server that are actively listening for incoming connections. The –listen option specifies that we want to see only the sockets that are in listening mode, and the –tcp option specifies that we want to see only the TCP sockets. The -n option specifies that we want to see the numerical addresses instead of service names.

See also  How to Setup Squid Proxy Service on CentOS 5.9

alternatively, type:

netstat -tuln

This command will display a list of all opened ports on the server. The “-tuln” options specify that we want to see the list of TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) ports with numerical addresses instead of service names.

Step 3: Interpret the results

The output of the “netstat” command will display a list of all opened ports on the server with the following information:

“Proto”: the protocol used by the port (TCP or UDP)
“Recv-Q” and “Send-Q”: the amount of data waiting to be received and sent
“Local Address”: the IP address and port number of the server
“Foreign Address”: the IP address and port number of the client
“State”: the current state of the connection (e.g., “LISTEN” for waiting for incoming connections)
Make sure to look for the ports that you are interested in, such as the ports used by a specific service or application.

[root@vps-server ~]# netstat --listen --tcp -n
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN

Commands Mentioned:

  • ssh – connect to a remote server using the Secure Shell protocol
  • netstat – display network connections, routing tables, and network interface statistics
See also  How to Install Zimbra 8.6.0 on RHEL 7/CentOS 7

Conclusion:

In this guide, we have learned how to check opened ports on a Linux VPS server using the “netstat” command. By knowing the opened ports, we can diagnose issues related to the server’s firewall or other configuration and ensure that the server is functioning as intended. We hope this guide was helpful. If you have any comments or suggestions for improvements, please let us know!

Comments

1 Comment

Leave a Reply

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