How to Test Open Ports in Linux

Configurare noua (How To)

Situatie

Whether you are troubleshooting network connectivity issues or configuring a firewall, one of the first things to check is what ports are actually opened on your system.

View the listening ports with the netstat command:

netstat -lntu

Viewing open ports with the netstat command.

The output above shows the port 8080 is opened.

List the open sockets with the ss command:

ss -lntu

The port appears as part of the socket.

Viewing open ports with the ss command.

Test the port by specifying its number to the nmap command.

nmap localhost -p 8080

Using the nmap command to see port status in linux.
Test the Port with the Netcat Utility

The Netcat tool features the nc command that you can use to test an open port. To do so:

1. Use a command such as echo to pipe output to Netcat and specify the port to listen to. The example below pipes a message to test port 8

echo “Testing port 8080” | nc -l -p 8080

2. Leave the command running and open another terminal window.

3. In that terminal window, use a command such as telnet to query the local socket.

telnet localhost 8080

If the port is open, the output of the telnet command contains the message piped to nc in step 1.

Using the telnet command to probe a port in Linux.

Solutie

Tip solutie

Permanent

Voteaza

(6 din 15 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?