You meant that, for TCP traffic, outgoing methods don’t require to be sent from a specific source port, like in SIP UDP traffic?
If so, do you know if this is due RFC standard, best practices or just Asterisk “source code”
The ol source vs destination port thing. Let’s take a look at this log from my ssh:
Oct 24 17:02:19 nas auth.info sshd[37553]: Received disconnect from 192.168.1.70 port 52018:11: disconnected by user
Oct 24 17:02:19 nas auth.info sshd[37553]: Disconnected from user dewdude 192.168.1.70 port 52018
Oct 24 17:02:31 nas auth.info sshd[39441]: Accepted publickey for dewdude from 192.168.1.70 port 52438
Do you see how there are two different port numbers listed? This is because my local PC connected TO the SSH server’s port using that port. My PC made the connection to port 22, the reverse path to my PC was port 52018 and 52438. One end of the connection is usually randomized to avoid conflicts. If one of my computers tried to connect to a web-server on port 443 and I was running a webserver on port 443…then a 443 to 443 connection wouldn’t work. In some cases you can force the same IP on each end…but this usually isn’t required unless you have a very broken firewall. OF course, things like NAT are the reason we do this; if you have 15 computers on a nework…then you need randomized source ports to keep traffic straight. Your firewall is counting on the fact the source ports are different.
“You meant that, for TCP traffic, outgoing methods don’t require to be sent from a specific source port, like in SIP UDP traffic?”
I wrote that because i also have pjsip over udp (transport) and im not seeing traffic from a random source port, SIP Methods flow from port 5060 to port 5060, even without mentioning it.
Instead of focusing about what is the standard or what is the proper environment, i would like to know if there is a way to set a static source port for TCP traffic just like i have for UDP (Even when i don’t have manually set 5060 port for udp traffic).
Essentially no-one ever does it, so I haven’t looked into the fine details of Posix network programming to see if you can even bind a port to the near side of a TCP connection.
I think some phones use random ports for UDP SIP, and, if you go through NAT you risk that happening anyway.
But, currently i need to do port forward in an external firewall since an external platform always replies to the TCP source port of the SIP Methods instead of “reading” the ports mentioned in the SIP CONTACT/VIA/FROM headers.
Maybe the external platform is not working properly, but besides that, I want to make sure if with Asterisk i could have a static source port for TCP traffic.
Not sure why for UDP traffic, source port is always 5060, i thought by default Asterisk always uses a static port, and if you require to modify it, using external_signalling_port would do the trick.