I have Tomcat and I am trying to bind to 2 specific ports (using custom connectors). E.g. port A
and port B
.
Problem:
When I do netstat -a |grep A
I do NOT see the port listed.
If I do netstat -antp
I see both ports A
and B
listed.
What is the difference between the commands?
By specifying
-n
you tell netstat to use the port number instead of the service name. If you look at the output ofnetstat -a
you will see that the port numbers are instead human-readable service names. These are mapped from/etc/services
, so if you are listening on port 80 you will see*:http
orhostname:http
, and if you are listening on port 8080 you will see*:webcache
orhostname:webcache
.From the netstat man page on Fedora 16:
The
-n
option is the difference. Without it,netstat
converts well-known ports such as 3306 and 80 into names such as mysql and http.If
A
is a well-known port andB
isn't, only one of your ports will be listed by the first command.If a port is well-known, it should be listed in
/etc/services
.