I have problem with figuring out how to make Asterisk use different source IPs in SIP messaging when going through different trunks. I did a lot of Google, but ended up not finding any useful info.
My provider gave me extra cable for telephony. I have 5 SIP trunks on 5 different VLANs on that cable. Every trunk is authenticated by source IP in SIP Header. Every trunk uses same SIP Proxy address provided by my VoIP provider. Is there any way to configure vanilla Asterisk to chose specific source IP (and put it in SIP Headers) for each trunk to pass providers authentication?
I don’t think so because of all trunks are from same provider. Since VoIP providers in my country don’t provide VoIP via Internet connection, but rather bring in a dedicated intranet link that is dedicated for VoIP, I ended up making a system with many disjoint networks. Precisely, they provide /30 private IP range on each VLAN so I have now five /30 private networks, with all 5 networks being able to communicate with providers SIP server. Only thing standing on my way is unability to set source IP in SIP headers (Contact) when talking to providers SIP server.
The peer should not care what is in the Contact header other than that it can route it back to the Asterisk box.
If systems want to identify peers by other than the IP address, they will normally use from header information.
I think the best advice for multiple non-internetted external networks, is to have a instance of Asterisk for each network bound to an interface on that network, and use something like IAX on 127.0.0.1 to intercommunicate.
In the case of chan_sip you have less control. In chan_pjsip you can have multiple UDP transports bound to each interface and control in the configuration which is used.
Not sure if this applies to your situation but have you looked at outboundproxy=
?
It’s a little tricky to set up. I don’t know how you do it with IP authentication because it uses the registration string. This is the setting for birch.com which requires a different setting for ouboundproxy.
You are not finished yet. To use the outboundproxy= setting you need to set your registration string in a special way.
someusername:password@SomeTrunkName/someusername ;(“SomeTrunkName” MUST match whatever you’ve named this trunk)
This is one of the trickier trunk provider settings. The trunk providers often don’t provide this information for whatever reason. It’s also not a very well documented feature in Asterisk.