How to check empty port using netstat?

Hi,
How to check empty port using netstat please help
Thanks
Ashfaque

Hi Ashfaque

What do you mean by empty, ports that are available/ don't have a service on them?

Which version of netstat (Solaris,Linux,Aix,BSD all produce differing output and take different flags)?

available/ don't have a service on them using linux

Probably easier to list those that do have services and then work backwards:-

netstat -na | grep LISTEN

Also it would be well worth checking in /etc/services that the port is not allocated to something that may periodically pop up and do something. Perhaps you have an application that uses port 12345 during the online day for a business user GUI, but switches to 54321 overnight for the batch monitoring team. If you have a look and decide to use 54321, then you might inhibit the overnight work.

Of course, it depends how your application is written as to whether it will be easy to determine which ports are always free.

Robin