-3

I have a server running mysql, ssh and other services. I want to see the range for ephemeral ports available for the OS running:

cat /proc/sys/net/ipv4/ip_local_port_range

which returns 32768 - 61000. When I run

sudo netstat -anp

I get in the foreign addresses, many ips and also ports outside the range stated before. Example:

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 10.251.1.62:3306            207.81.181.89:63192         ESTABLISHED 1483/mysqld

Which looks to me that my server is assigning port 63192 to the remote host, which is not it's allocated range. How is this possible? am I not looking the ephemeral ports in the right place? am I not understanding properly the output of netstat? Am I not understanding how ephemeral ports work at all? Thanks.

1
  • It would help if you posted the output you're concerned with.
    – Spooler
    Commented Oct 10, 2018 at 0:03

3 Answers 3

5

Ephemeral ports are for outbound connections only, not inbound. You have no control over the foreign ephemeral port.

2

63192 is the port number shown under the Foreign Address column.

It's not assigned locally on your server. That's why it's foreign.

1

The connection you've shown in your question is an INBOUND connection TO your server from the foreign address to port 3306 on your server, which is the default port for MySQL.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .