5 Easy Ways to Check for Open Ports on Linux

Open network ports are the easiest entry points to your network. Sometimes, there might be unwanted services running on ports that are externally visible from the internet. In case these services are vulnerable, your network would be at constant threat of an attack as every day the entire internet is being mass scanned for vulnerable services on open ports.

Learn how you may scan and view open ports on your Linux systems, so you can defend your network from threats.

4

What Are Network Ports?

Network ports are logical access points of your system that can be used as a channel to host multiple services. A port is represented by a 16-bit integer so, the highest port number is 65535.

you’re able to think of ports like windows and doors of a house—basically all the different entry points to a house or, a computer. Ports are of three types: system ports (1-1023), registered ports (1024-49151), and ephemeral, or dynamic ports (49152-65535).

image of earth from outer space

When you start an application that requires connection to the internet, it uses dynamic ports to transmit and receive data over the network. However, when you start a web server or an SSH server, it typically binds to the system ports or registered ports.

For HTTP serving web servers, the default system port is 80 and for SSH it’s 22. These regulations such as the ranges of ports are developed by the Internet Assigned Numbers Authority (IANA). You can go through theRFC regarding portsto get a full list of all the ports and their functions.

netsat command demo to show open ports

It’s important that you know themost commonly vulnerable portsso that you’re able to ensure they are closed or protected.

1. Check for Open Ports With netstat

netstat is a popular utility that you can use to view the network statistics of your Linux system. It is part of the net-tools package.

The net-tools package is now depreciated due to a lack of proper maintenance by the developer. This is also the reason why you may encounteran “ifconfig: command not found” errorwhen running the popular ifconfig command on Linux.

checking open ports with ss command

So on modern systems, you might have to first install the net-tools package, and then you’ll be able to run the netstat command. Here’s how to check for open ports with netstat:

Explanation of the command:

how to scan ports using network mapper

2. Check for Open Ports With ss

ss is the modern equivalent of the netstat tool. You’ll find this pre-installed in all modern Linux distributions. The syntax to check open ports with ss is identical to netstat.

Here’s how to check for open ports with ss:

3. Check for Open Ports With Nmap

Nmap is one of the most popular tools in cybersecurity and networking. It’s a staple name when it comes to network security penetration testing. Its primary use case is port scanning so not only will you get information about the ports open in your system but also if they are vulnerable and exploitable.

Moreover, if you wish to check open ports in a remote system with IDS/IPS set up and firewalls in place, worry not because Nmap can also bypass firewalls and IDS/IPS with the right switches.

Check out thiscomprehensive guide on Nmap for beginnersto explore the diverse features of Nmap and how to use them. Although it’s possible to, it’s not recommended to attempt and bypass firewalls as it’s not entirely reliable, so it’s best you SSH into the remote server and then run Nmap on it locally.

Here’s the command to check for open ports with Nmap:

4. Check for Open Ports With lsof

The lsof command in Linux is used to list open files. However, if you add a few switches to it, you’ll be able to see the open internet connections and ports on your local machine. Here’s how to check for open ports with lsof:

5. Check for Open Ports With netcat

netcat is a command-line utility that lets you read and write from and to TCP/UDP connections. Note that this is just one feature of netcat. you’re able to check out its manual page using theman netcatcommand to explore all its features and how to use them.

Here’s how you can use netcat to scan open ports:

The Deeper You Know Your Network the Better You Can Defend It

Knowing which ports are open and what services are running on your system is a great step to defending it from potential external attacks. This allows you to search for and shut down unnecessary services, find outdated services, and also detect if there are any malicious files such as bind or reverse shell backdoors running on your system.

If you’re serious about network security, you should consider installing and setting up an IDS solution to monitor all activity on your network and enforce rulesets to prevent unsolicited connections.

Protect your network from intruders and unsolicited attacks by installing and setting up Snort IDS.

Freeing up vital memory on Windows only takes a moment, and your computer will feel much faster once you’re done.

Unlock a world of entertainment possibilities with this clever TV hack.

Make sure you don’t miss these movies and shows before Netflix removes them.

This small feature makes a massive difference.

I found my TV was always listening—so I shut it down.

Technology Explained

PC & Mobile