Register 2 Trunks to same hostname with different destination IP?

Hello,

I have a provider that wants me to setup 2 trunks to 2 different IP addresses. Because we have a direct connection to them the IP addresses are not accessible over the Internet or via a public FQDN.

Here is what they want for the registration string.

TN:PASSWORD:[email protected]:5100/TN~3600

However to make FreePBX register to the correct IP address I have to enter voip.provider.tld in the hosts file and enter the IP address for the Trunk SBC I am trying to connect.

Is there any way to do that without using the hosts file? Like overwrite where the registration is going on a per Trunk setting but include the host domain still?

One trunk would register to voip.provider.tld with one the primary IP address and the other trunk would register to voip.provider.tld with the backup IP address.

Set up a pjsip trunk.

Username: TN
Auth username: TRUNKGROUPID
Secret: PASSWORD
Authentication: Ooubound
Registration: Send
SIP Server: voip.provider.tld
SIP Server Port: 5100
Outbound Proxy: sip:1.2.3.4:5100\;lr\;hide
(replace 1.2.3.4 with provider IP address)
Contact User: TN
From Domain: voip.povider.tld

Depending on how they want outbound caller ID to be sent, you may need to set From User and/or Send RPID\PAI.

If you have trouble registering, turn on pjsip logger and paste the Asterisk log for a registration attempt (and any replies) at pastebin.com and post the link here.

If registration is successful but calls fail, paste the Asterisk log for a failing call, including pjsip logger.

“Registration string” is a chan_sip concept that is not relevant for this system.

The trunk is showing as up but no inbound calls are making it.

I do not think the registration is working correctly. Maybe its because the FREEPBX system is behind a NAT statement because the provider required the connection to come from a specific IP range?

There still seems to be some options wrong/missing. We have some extra TRUNKGROUPID that gets passed in the string when its setup using chan_sip.

 TN:PASSWORD:[email protected]:5100/TN~3600
47192	[2024-03-20 17:08:43] VERBOSE[60912] chan_sip.c: Scheduling destruction of SIP dialog '0cecb99384b742c3a940899040b7712e' in 32000 ms (Method: OPTIONS)	
47193	[2024-03-20 17:08:45] VERBOSE[2646] chan_sip.c: Really destroying SIP dialog '5dff6abe6d3e4a61b39eb1297d2948b4' Method: OPTIONS	
47194	[2024-03-20 17:08:51] VERBOSE[41264] res_pjsip_logger.c: <--- Transmitting SIP request (540 bytes) to UDP:SBCIP:5100 --->	
47195	OPTIONS sip:SBCIP:5100 SIP/2.0	
47196	Via: SIP/2.0/UDP FREEPBXINTERNALIP:5160;rport;branch=z9hG4bKPj924a6285-eaaa-4a42-9755-9126ac34036d	
47197	From: <sip:[email protected]>;tag=195732d0-d499-42f9-8df4-1506bbf14647	
47198	To: <sip:[email protected]>	
47199	Contact: <sip:TN@FREEPBXINTERNALIP:5160>	
47200	Call-ID: c5ce8ec7-ec29-45f4-a797-e69afcc6529a	
47201	CSeq: 7983 OPTIONS	
47202	Route: <sip:SBCIP:5100>	
47203	Route: <sip:[email protected]:5100>	
47204	Max-Forwards: 70	
47205	User-Agent: FPBX-15.0.37.1(16.20.0)	
47206	Content-Length: 0	
47207		
47208		
47209	[2024-03-20 17:08:51] VERBOSE[2615] res_pjsip_logger.c: <--- Received SIP response (576 bytes) from UDP:SBCIP:5100 --->	
47210	SIP/2.0 200 OK	
47211	From: <sip:[email protected]>;tag=195732d0-d499-42f9-8df4-1506bbf14647	
47212	To: <sip:[email protected]>;tag=sip+1+8f320056+13ef0673	
47213	Via: SIP/2.0/UDP FREEPBXINTERNALIP:5160;received=NATIP;rport=5160;branch=z9hG4bKPj924a6285-eaaa-4a42-9755-9126ac34036d	
47214	Server: SIP/2.0	
47215	Contact: <sip:TRUNKNAME@FREEPBXINTERNALIP:5160>	
47216	Call-ID: c5ce8ec7-ec29-45f4-a797-e69afcc6529a	
47217	CSeq: 7983 OPTIONS	
47218	Route: <sip:SBCIP:5100>	
47219	Route: <sip:[email protected]:5100>	
47220	User-Agent: FPBX-15.0.37.1(16.20.0)	
47221	Content-Length: 0

Nothing shows in “sip show registry”.

I am confused about the Route headers in the OPTIONS request. The Outbound Proxy setting should have backslash semicolon in two places. Did you change this for some reason?

Please explain your network hardware setup. Is the SBC on your site? If so, why is there NAT?

Because you aren’t using chan_sip?
Do you mean “pjsip show registrations?”

Another thought: the Contact header should have NATIP, which could explain inbound failing.

External Address should be NATIP and Local Networks should not include SBCIP. Does that agree with your settings?

I was able to get this working with SIP but not PJSIP.

My register string is:

 [email protected]:PASSWORD:TRUNKGROUPID@IP:5100/TN~3600

When I try something similar with JPSIP I get a status of rejected.

[2024-03-22 15:12:10] WARNING[123263]: res_pjsip_outbound_registration.c:1055 handle_registration_response: '404' fatal response received from 'sip:SBCIP:5100' on registration attempt to 'sip:TN@SBCIP:5100', retrying in '30' seconds

Must have something wrong still. It is missing the :TRUNKGROUPID: part and the username does not have that @ in it. When I try to enter as that I get an error that the URI is invalid.

Which is it?
In the working chan_sip case, use sip debug to look at the REGISTER request and report what appears in the From and To headers, and the username parameter in the Authorization header.

Yes, sorry that is a little confusing. They want the username to include the @voip.provider.tld.

Using the @ in the username part of the register string allowed me to register to the two different SBC IP addresses and not have to modify the hosts file as they recommended. They still expect the password and TRUNKGROUPID but I have not figured out how to do all that using the UI for pjsip.

If you get an error putting an @ in Username, try using @ instead.

The password goes in Secret and TRUNKGROUPID goes in Auth Username.

If you still have trouble, using sip debug and pjsip logger, paste a successful registration using chan_sip and an unsuccessful one using pjsip.

I think this was parsed incorrectly.

So looking at the output from PJSIP logs.

30031	[2024-03-22 17:38:17] VERBOSE[140787] res_pjsip_logger.c: <--- Transmitting SIP request (617 bytes) to UDP:SBCIP:5100 --->	
30032	REGISTER sip:SBCIP:5100 SIP/2.0	
30033	Via: SIP/2.0/UDP LOCALIP:5160;rport;branch=z9hG4bKPj8854ce37-c2d4-40eb-ae22-c48151323d5b	
30034	From: <sip:TN@SBCIP>;tag=ba7d946b-7d7d-4e7f-874a-71daf09acb6f	
30035	To: <sip:TN@SBCIP>	
30036	Call-ID: e022e4a0-0767-4b11-94d6-ce6573d7d328	
30037	CSeq: 10757 REGISTER	
30038	Contact: <sip:TRUNKGROUPID@LOCALIP:5160;line=ehhhacr>	
30039	Expires: 3600	
30040	Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER	
30041	Route: <sip:SBCIP:5100>	
30042	Max-Forwards: 70	
30043	User-Agent: FPBX-15.0.37.1(16.20.0)	
30044	Content-Length: 0

I do have the From User & From Domain set under “Advanced” but that does not seem to be making it into the registration.

Is Username set to TN, [email protected], or [email protected] ?

What does sip debug show for the working chan_sip case?

I have tried a bunch of the variations in the username field:
TN
[email protected]
TN\@voip.provider.tld

I found a chan_sip result:

45349	[2024-03-22 18:02:22] VERBOSE[2646] chan_sip.c:	
45350	<--- SIP read from UDP:SBCIP:5100 --->	
45351	SIP/2.0 200 OK	
45352	Call-ID: 2d99634515c415cb038168620818dd87@[::1]	
45353	CSeq: 103 REGISTER	
45354	From: <sip:[email protected]>;tag=as54ec585a	
45355	To: <sip:[email protected];tag=sip+3+e984007c+2ec1ac7a	
45356	Via: SIP/2.0/UDP LOCALIP:5060;received=SBCIP;rport=5060;branch=z9hG4bK6c733f00	
45357	Server: SIP/2.0	
45358	Content-Length: 0	
45359	Expires: 3600	
45360	Contact: <sip:TN@LOCALIP:5060>;Expires=3600;q=0.5	
45361	Allow-Events: call-info,line-seize,dialog,message-summary,as-feature-event,x-broadworks-hoteling,x-broadworks-call-center-status,conference	
45362	

Well, you posted the reply, which may have some fields modified, but I’ll assume not.

Please try:

Username: TN
Auth username: TRUNKGROUPID
Secret: PASSWORD
SIP Server: voip.provider.tld
SIP Server Port: 5100
Outbound Proxy: sip:SBCIP:5100\;lr\;hide

If it doesn’t work, post pjsip logger showing what was sent.

Hey,

That might be working!

 TRUNKNAME-PJ/sip:voip.provider.tld:5100           TRUNKNAME-PJ   Registered

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