SIP Trunk Configuration

Hello,

As background I have two different SIP providers with different phone numbers. I have successfully set up my FreePBX server on AWS with one of my SIP providers, everything works together with all the voice recordings, time conditions, etc.

The problem that I’m having is with the second SIP provider. I am not able to get the correct configuration on the trunk setup for them, and their support is not being helpful. After much trial and error I’ve managed to get a successful “105 registered” status for the trunk, however, I am not able to receive or make calls. Everything goes straight to the SIP provider’s own voicemail.

As a quirk, this SIP provider provides a separate “authentication name” and “username”, the username being 5 numbers and appearing to be more like a kind of extension, and the registration only succeeds with the following registration string:

[authname]:[password]@[host domain]/[username]

This SIP provider also separately provides a 3CX service that allows me to take and receive calls on their web interface. However, I have confirmed that the SIP configuration details that they have provided me successfully works on third party VOIP softphones and deskphones very easily.

I have tried (unsuccessfully) virtually all the combinations that I’ve found online in the outgoing and incoming tabs of the FreePBX SIP Settings, does anyone have a clue on which PEER details and USER details will work? I think I may have to set some wonky settings because of the separate authname and username.

Thank you!

Please post all the settings that work correctly in a softphone or desk phone.
For privacy, replace the username with UUUU, the auth name with AAAA and the password with PPPP. If a phone number also appears, use NNNN.
Leave everything else exactly as you entered it.
I’m familiar with Zoiper, Linphone, MicroSIP, PhonerLite and X-Lite; if possible show the settings for one of those.

Or, a Yealink, Grandstream, HTek or Cisco SPA desk phone.

2 Likes

Hi Stewart,

I’ve got it to work with my VTech VOIP phone as well as Zoiper.

Zoiper settings are as follows:

Host: DDDD
Username: UUUU
Password: PPPP
Authentication User: AAAA
Outbound Proxy: (IP address that is the same as DDDD)

VTech settings are as follows:

User Identifier: UUUU
Authentication Name: AAAA
Authentication Password: PPPP
SIP Server
Server Address: DDDD
Port: 5060
Registration
Server Address: DDDD
Port: 5060
Expiration: 3600 seconds
Registration Freq: 10 seconds
Outbound Proxy
Server Address: DDDD
Port: 5060

Try these settings in PEER Details. Leave the USER Details section completely blank, except for the Register String (which you already have entered correctly).

type=peer
host=DDDD
outboundproxy=DDDD
username=AAAA
fromuser=UUUU
fromdomain=DDDD
secret=PPPP
insecure=port,invite
disallow=all
allow=ulaw&alaw

If you still have trouble, at the Asterisk command prompt, type
sip set debug on
make a failing call, paste the Asterisk log for the call (redacted as desired) at pastebin.freepbx.org and post the link here. Also post details of what the caller hears, any long delays, etc.

For incoming, if anything appears in the Asterisk log for the attempt, paste it as above. If not, post details about your router/firewall.

1 Like

Fantastic outgoing works!!

Incoming as usual is still not working. No long delays, it rings about 5 times but then it just gets redirected to my SIP provider’s own voicemail box. My PBX connected phones do not ring.

See the logs:

https://pastebin.freepbx.org/view/09948cc6

It appears that the incoming call is not hitting FreePBX at all. Possibilities include:

  1. Something set up incorrectly at the provider (if the Vtech or Zoiper could receive calls on the same account, this is ruled out).
  2. The provider supports only a single registration per account and another device is stealing it. Confirm that all devices that previously registered to the account have been shut down or reconfigured.
  3. Asterisk is sending an incorrect address in the Contact header of its REGISTER request. Confirm that in Asterisk SIP Settings, External Address and Local Networks are correctly set. On the chan_sip tab, Override External IP should be left blank. If you have changed any of these since the last restart, restart Asterisk now.
  4. The AWS firewall is blocking the incoming INVITE. Do you have the UDP port corresponding to the value of Bind Port passed to the PBX?
  5. FreePBX firewall is blocking it. It shouldn’t by default, but possibly the association has timed out or you changed some setting. Run sngrep (which listens ahead of the firewall) and see whether INVITEs appear when you attempt an incoming call.

A few questions: Is this a new setup, or did you add a new trunk to an otherwise working system? Normally (for new systems) pjsip listens on port 5060 and chan_sip is on 5160. Did you change any of these ports? Is B3Networks the trunk with failing incoming calls, or is it the one that’s working?

1 Like

(for some reason I can’t login to my account from a different machine, so new account created)

As for your points:

  1. VTech and Zoiper receive calls on the same account

  2. Provider actually supports multiple registrations, but I have shut down the account on all other devices previously.

  3. General SIP Settings -> NAT Settings - I used “detect network settings” and everything seems in order, given that I can receive calls from the other VOIP provider. Chan_sip override external IP is blank.

  4. Not to sure what you mean by “bind port”. But my AWS firewall is open to the problematic provider’s SIP server IP address, UDP/TCP port 5060, 10000-30000. Also my other VOIP provider is able to receive calls just fine.

  5. I specifically whitelisted the problematic provider’s SIP server IP address under FreePBX Firewall->Networks as Trusted (Excluded from Firewall). I’ve just rebooted the system as well, still not able to receive inbound calls. I tried sngrep and it only shows “REGISTER” followed by “OPTIONS”, there’s no INVITE.

This is a new setup, I added a trunk first from the VOIP provider that is currently working correctly. Then after that I went to add a second trunk from this problematic VOIP provider. B3Networks is the trunk with the one that is working correctly, so the relevant logs should be the first one that I included, the latest one has extra stuff (I think the bottom half) from the working VOIP provider.

I have modified chan_sip to listen on 5060.

Could there be something that I have to setup on the incoming “USER Context” and “USER Details” area? For the VOIP provider that’s working, I followed the instructions and these sections have to be filled up with some details.

Unlikely, based on what you already posted for Zoiper. In any case, that configuration would only determine how Asterisk would process the call; if the call doesn’t reach Asterisk at call it can’t make a difference.

I am guessing that the provider sends some or all calls from servers different from the one to which you registered. If they have documentation about this, allow all these addresses through the AWS firewall and FreePBX firewall.

Otherwise, in the AWS firewall, temporarily allow packets to UDP port 5060 from any address. Now make a test incoming call and see whether the INVITEs show up in sngrep. These won’t reach Asterisk because the FreePBX firewall will still be blocking them. You also may see INVITEs from hacker addresses but you should be able to determine which are from your provider. The provider’s call should result in several INVITEs; they get no response and retransmit a few times.

If you see the INVITEs now, you should be able to set up the firewalls properly. You may need to add an additional trunk (with no registration or outbound proxy, but with host set to the IP from which the call was sent).

If there are still no INVITES in sngrep, check that Asterisk still sees the trunk as registered (Reports → Asterisk Info, select Registries). If the provider’s portal shows registration, confirm that your PBX address appears there. In sngrep, select a REGISTER packet (for the failing provider) and confirm that the Contact header has the correct public IP address of the PBX and port 5060.

1 Like

Okay so this is what I’ve done. I disabled the AWS firewall for UDP port 5060. No “INVITE”. I disabled my whole AWS firewall (allowed type=all traffic, from=anywhere). Unless there’s some lag between me setting the firewall rules and the changes actually going into place (I reactivated the firewall the moment I was sent to the provider’s own voicemail), still no “INVITE” in sngrep lol.

Asterisk still sees trunk as registered, “State: Registered”.

In sngrep, the REGISTER packet for the failing provider is showing a “source” that appears to be the internal IP of the PBX server, and not the public facing one. The destination is the IP of the target provider’s hostname/domain with port 5060. This is the same for the provider that is working.

The provider does not have a portal that shows whether it is registered or not unfortunately.

Edit: for good measure I registered on the line with Zoiper and tested the incoming calls… works fine.

In sngrep, select the REGISTER packet with the up and down keys, then press space and enter to view all the headers. Or, type
sip set debug on
at the Asterisk console to see the REGISTER there.
Check the Contact header for correct public IP and port.

1 Like

Since your provider allows multiple registrations, you could register both Asterisk and Zoiper, then look with Wireshark on the PC at the 200 OK response to REGISTER, which should have two Contact headers. The one for Asterisk should show the correct IP and port of the PBX.

1 Like

Okay I’ve done that, for my FreePBX, the “CONTACT” header shows <sip:UUUU@[PBX Public IP]:5060>, appears to be fine and consistent with what I’ve seen in the Zoiper logs.

I am currently looking through the Zoiper logs to see if there is any stray IP address, but haven’t found any.

Edit: I’ve spotted one difference, for the From/To headers, the FreePBX one shows

sip:AAAA@DDDD

while the Zoiper one shows

sip:UUUU@DDDD;transport=UDP

Wow, I think you’ve got something there. For the Register String, try
UUUU:PPPP:AAAA@DDDD/UUUU

1 Like

Registered successfully with the amended register string. However, still not getting incoming calls.

The logs now show the corrected From/To though!

Another difference I spotted between FreePBX and Zoiper is that, Zoiper has a line that starts with “Proxy-Authorization”, while the FreePBX one just says “Authorization”. Any fix for that?

Just guessing here, provider is using DNS SRV and/or NAPTR records (which chan_sip doesn’t handle properly, though there may be workarounds, and switching to pjsip is a possibility). Check the IP address to which Zoiper is sending REGISTERs. I’m guessing it’s different from where Asterisk is sending them.

1 Like

Try this Register String:
UUUU@DDDD:PPPP:AAAA@IIII:5060/UUUU
Where IIII is the numeric IP address you used for Outbound Proxy in Zoiper.

1 Like

As for which IP address to which Zoiper is sending registers:

REGISTER sip:DDDD;transport=UDP SIP/2.0
Via: SIP/2.0/UDP [internal IP of softphone:random port number];branch=…

FreePBX shows:

REGISTER sip:DDDD SIP/2.0
Via: SIP/2.0/UDP [Public IP of PBX:5060]:branch=…

From the Zoiper logs I haven’t seen any stray or unrecognized IP address.

Your suggested register string successfully registers, but it still shows “Authorization” and not “Proxy-Authorization”

Edit: Apologies, I checked the SIP debug logs, and it correctly shows “Proxy-Authorization” for the FreePBX. The “Authorization” was show in sngrep.

FreePBX debug mode on, register logs https://pastebin.freepbx.org/view/6028a65b

Zoiper register logs: https://pastebin.freepbx.org/view/36176a6f

Under the SIP settings I changed it to Public IP instead of Static IP, and I managed to get Invite logs, but the caller simply hears silence and nothing goes through to the caller.

Edit: after studying the logs, it appears that while changing to Public IP gets the “INVITE” to hit asterisk, when it tries to send out, we get:

Contact: <sip:UUUU@[internal IP of FreePBX]:5060>

I think what it should be doing is:

Contact: < sip:UUUU@[external IP of FreePBX]:5060>

Any idea what’s next to tweak?

Edit 2: After setting to Public IP instead of Static IP, outgoing calls no longer work. They connect (can pick up the call) but there is no audio.

Edit 3: After setting it back to Static IP, incoming calls now magically work… serious what is going on lol. The only thing I can put my finger on is that I opened up more ports on my AWS firewall for HTTPS/TLS stuff. Now fingers crossed that it doesn’t break on Monday.

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