How to change source SIP port?

I’m looking for a way to change the UDP port which is used as a source when Asterisk is registering to external provider as a user.

I don’t want to change the bindport globally in sip.conf, but I want to change it for specific peer if possible.


You can change port= for each connecting peer/user within the settings for that peer/user.

I’m talking about the UDP port which is used as a source by Asterisk, not the destination port.

why is the source port important? some sort of nat issue?

I have Nokia E60 phone which is SIP-enabled. Unfortunately it has no setting for the SIP source port, dislike many hardware and software SIP-phones around. So it registers as with my SIP provider. My NAT device preserves the port number, so port 5060 on E60 became port 5060 on my WAN ip. Dynamic rule is created on the NAT device to pass all the traffic (from the external SIP proxy) which is coming on WAN:5060 to E60:5060.

Now, when I’m using my Asterisk, which is, and it registers with the same external SIP proxy, the duplicate rule on the NAT cannot be created. I.e. I cannot have 2 NAT rules working at the same time:

Ext.Proxy —> WAN:5060 —> E60:5060
Ext.Proxy —> WAN:5060 —> Asterisk:5060

If I will change the source port used by Asterisk for specific peer/registration only then the different port will be used on the NAT device and absolutely separate return path will be created.

So, I need something like this:
Ext.Proxy —> WAN:5077 —> Asterisk:5077

Generally, I can change the bindport globally, but this will force me to change the destination SIP ports on all the SIP phones connected to my Asterisk.

yuck, i feel your pain. i doubt asterisk has any hooks for this, since it is not a normal thing to have to do. maybe you could have the asterisk box’s linux iptables change the source port from the E60 to some higher numbered port?

You will see the option to change the source (or listen) port almost in any SIP phone, hardware or software!

i meant normal for asterisk, not the client. in any event, i find this whole problem very odd, to say the least. this issue is why it is not recommended for a tcp or udp client to specify the source port - you let the tcp/ip stack pick a random one for you. a proper stateful firewall should not have a problem directing the return packets. oh well…

Unless Nokia has released a firmware up then the Nokia e 60 are not designed for working with NAT.

From the mouth of Nokia …you can do a google search I am sure and find it.

As with any sip device it does not matter about the port 5060 it is the media ports which matter. (this is where STUN comes in to play)…

Until nokia’s put in a place for a STUN server; those phones are just about worthless in many cases.

E60 and other E-series phones are working perfectly with my provider through NAT, without any port forwarding on router.
I’ve also used E60 with public hot spots without any troubles.

The only problem I see with Nokia is the luck of user-configurable parameters, like SIP source port for example.