How to find the number of open ports in linux? I want to see if I am running out of ports. Also, how do I see the limit of my OS?
feedback
|
|
As others have mentioned, netstat is the tool to use to determine what ports are in use currently. As to the limits, the number of ports available are a 16bit unsigned integer which gives you the range 0-65535. The ports that are available for applications to bind to are the reserved privileged/root ports (0-1024) plus whatever is not covered by your ephemeral port range. You can view your ephemeral ports by running To modify that persistently, you would have to add/modify "net.ipv4.ip_local_port_range" in the /etc/sysctl.conf file, or interactively with | |||||
feedback
|
|
On modern linux, use the ss (socket stats) utility.
| |||
|
feedback
|
compared to
| |||||||
feedback
|
|
netstat will allow you to see what ports are open, do "netstat -" to see what fits your needs best. | |||||||||||
feedback
|
|
Personally I prefer nmap. You can find the state of all ports by issuing nmap -P 1-65535 target. Most distributions should have this package available via their package manager. | |||
|
feedback
|
|
'nmap localhost' will give you all your open ports and services running on them. | |||
|
feedback
|
|
netstat -tulnp The arguments to the netstat program are listed below:
| |||
|
feedback
|