Multiple trunks to same destination, multiple source IPs?

Hello everyone,

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?

You probably want fromdomain.

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.

You have a very non internet type configuration!

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 to intercommunicate.

1 Like

So there is no way to tell Asterisk which IP to put in Contact header?

Asterisk will put the IP of the interface it uses in the Contact header.

1 Like

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 which requires a different setting for ouboundproxy.

dtmfmode=auto ;substitute “atl0” with whatever market you’re in

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.