[asterisk-users] Why is this happening?

Brian Candler B.Candler at pobox.com
Tue Oct 17 01:15:49 MST 2006


On Mon, Oct 16, 2006 at 05:25:22PM -0400, Time Bandit wrote:
> >Thanks for the answer, but I don't buy it.  There are currently 0
> >calls up on that bridge, while another connection which has calls up
> >on it is on Port 4569.. please try again.  IAX2 is suppose to run on
> >ONLY one port.. this is why it is so nice for use in firewall
> >situations.
> 
> It doesn't change a thing !
> 
> Same thing happens with a webserver. It listen for connections on port
> 80 (default port) and when a connection comes in, it is handed to
> another free port on the server so the "main" server can continue
> listening on port 80. Same thing with FTP, etc. All TCP servers that
> accept more than one connection

For the benefit of the archives, I'd just like to point out that this
description is entirely wrong.

Each TCP connection has four parameters associated with it:
  - local IP address
  - local port
  - remote IP address
  - remote port

It is all four together which uniquely identifies a TCP connection.

A webserver uses local port 80 for *all* inbound connections, and that is
for the *entire* duration of each connection. It does not somehow magically
change the local port number after accepting the connection.

Additional connections can be accepted because they have a different remote
IP address (if they are coming from a different machine) or a different
remote port (if they are coming from another socket on the same machine)

> Check on your machine while you're surfing the web, your browser
> doesn't use port 80 as the originating port.

Now, that is correct; the browser (the client) picks a port >1024 for its
end of the connection. However check your netstat output and you'll also see
the far side (server) is port 80.

> Connect to an FTP server
> and check your netstats, you'll see that you're not connected to port
> 21 on the remote server

No, you'll see that you *are* connected to port 21 on the remote server.
However your local port number will be something else.

Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
tcp4       0      0  172.31.131.189.62505   69.16.138.164.21       ESTABLISHED
                                    ^^^^^                 ^^

Regards,

Brian.


More information about the asterisk-users mailing list