PJSIP with two Asterisk servers on same network & Anveo DID routing [SOLVED]

Hi. I have two Asterisk servers on my local network (ServerA & ServerB). I have purchased seperate DID numbers (DIDA & DIDB) for both servers from Anveo Direct, and have created two destination SIP trunks:

trunkA: 11231231234@mynetwork.duckdns.org:5060
trunkB: 12342342345@mynetwork.duckdns.org:5060

Both servers have the same PJSIP conifguration (see attached pjsipA.txt). With ServerA booted, inbound from both trunkA & trunkB are received correctly by my dialplan. With both servers booted, calls from trunkA & trunkB both arrive on a single server, not on both.

I was under the impression that PJSIP would allow for multiple registrations. So, with both servers having the same PJSIP config, I expected incoming calls for trunkA & trunkB to be routed to both servers. Then, I could use the dialplan on each server to filter DIDA into ServerA, and DIDB into ServerB.

I have also tried setting trunkB to port 5070 via Anveo:

trunkA: 12342342345@mynetwork.duckdns.org:5070

In this case, I also correctly forwarded ports on my router for port 5070 to ServerB. Here, ServerA is running pjsipA.txt, and ServerB is using attached pjsipB.txt. The pjsipB.txt tries to route incoming calls to ServerB from port 5070. However, calls from trunkA & trunkB still only arrived on a single server, not on both.

I am pretty new to Asterisk, and especially to PJSIP, so I am wondering if someone can provide me more info, context, or suggestions. Is it possible for me to run the pjsipA.txt on both servers, and route the DID via dialplan? And if so, is there a setting I am missing in my pjsipA.txt to enable this? Or, alternatively is there an obvious reason why my pjsipB.txt is not routing trunkB via port 5070 to ServerB? Thank you in advance for any help.
pjsipA.txt (1.7 KB)
pjsipB.txt (1.7 KB)

It allows multiple INCOMING registrations. You are referring to outbound registrations, and that behavior is dictated by the upstream provider - not Asterisk. They may allow it, they may not. They may require you to do extra things to support it, they may not.

1 Like

It allows multiple INCOMING registrations. You are referring to outbound registrations, and that behavior is dictated by the upstream provider - not Asterisk. They may allow it, they may not.

Hi @jcolp, thank you for this info. I’m hopeful that Anveo Direct allows my desired behaviour.

I’ve been doing some further investigation today. . . and its possible my issue is caused by something as simple as port forwarding. I have a feeling that just duplicating my port forward routes in OpenWRT is not enough, I think as soon as the data reaches one server, it cannot be forwarded elsewhere.

I need to conduct some further research and will return to this thread. Thanks again.

So, I have resolved my issue! It was basically a port forwarding problem. I could never get the pjsipB.txt config in my original post to function. However, I kept the same pjsipA.txt config on both servers, and did the following:

Set trunkB on anveo direct to port 5070:
trunkA: 11231231234@mynetwork.duckdns.org:5060
trunkB: 12342342345@mynetwork.duckdns.org:5070

On my router, I have duplicated port forwards for the necessary Anveo IPs. For the forwarding to ServerB, the incoming port was modified to 5070, and that is remapped by the router to port 5060 before being sent to the ServerB. In this case, each server only receives incoming calls from its associated DIDA or DIDB, not both.

I’m sure this kind of Asterisk/network config is obvious to most people around here, but anyway, that’s how it’s done for anyone else who finds this. Thank you again @jcolp for providing some further context to me.

If you have multiple asterisk servers, behind the same NAT router, you’re in for a rough time. Using different ports for the two servers, for both the SIP traffic, and the RTP traffic (set in rtp.conf) can get you some of the way, but it really all comes down to how your NAT router handles the SIP traffic, if it has support for SIP traffic, it can be buggy, if it does not, it’s not always easy to get the RTP traffic to flow.

Also I would personally try to keep the outside and inside SIP ports the same. That is, if you forward port 5060 to server A and 5070 to server B, you make Asterisk listen to the same port. This avoids some of the problems I’ve seen with SIP behind NAT.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.