ISP Router SIP VOIP as SIP Trunk in Asterisk

Hello,

I’m trying to “move” the telephone service provided by my ISP to my own internal asterisk server. Is this possible? I managed to get the SIP account credentials from my ISP and “bridged” the VOIP VLAN interface to go directly into asterisk.

I’m running my instance of asterisk/freepbx on a VM inside network 10.0.31.254/19, while another port on my VM acts as the network interface coming from the VOIP VLAN. This second interface is getting the correct network IP address from the ISP VOIP network and can ping the voip server ip addresses. This VOIP network is internal only to the ISP and not routable outside the internet.

I first tried to use one of my PC directly as a SIP client and I was able to use the SIP credentials and I can make outgoing and incoming calls using Zoiper. However, when I try to put the SIP settings to freepbx as SIP Trunk, I’m getting “Invalid User” warning followed by “Endpoint in now reachable” but the voip number is unreachable when I tried to call it from outside (using another mobile phone).

My objective here is when my ISP phone number receives an incoming call, it will ring an extension in my private VOIP or directed to an IVR. I would also want the other extensions the ability to call “outside” through the ISP line.

Any idea or help is much appreciated. Thanks in advanced!

Yes, but please explain the networking in more detail. ISP router make/model? Does it have two RJ45 LAN jacks, one for internet access and one for VoIP? Or, one jack with untagged packets for internet and tagged packets for VoIP? Or something else?

On the successful test with Zoiper, how was the PC connected to the router? Was the PC configured for tagged packets? Using a VLAN-aware switch?

In Zoiper, what parameters (if any) did you have to set, other than Username, Password and Hostname?

Which virtualization system are you using? Is it set up to use anything other than bridged networking? If so, why? With FreePBX shut down, can you run successfully run Zoiper on the host?

I assume that you created a pjsip trunk. If you used chan_sip, please delete the trunk and set it up with pjsip.

This merely means that Asterisk got a response to an OPTIONS request, which it uses to see whether the endpoint is still alive. It does not imply that the connection is usable to make or receive calls.

I don’t know what that means, but if you post a few lines of the Asterisk log leading up to that message, it may be clearer.

From the Asterisk command prompt, what is the output of
pjsip show registrations
?

If registered, what if anything appears in the Asterisk log when an incoming call is attempted?

If not registered, at the Asterisk command prompt, type
pjsip set logger on
wait for a failing registration retry, paste the relevant section of the Asterisk log at pastebin.com and post the link here.

ISP router is a Nokia G-2425G-A Fiber ONU gateway configured with 2 VLANs, one for internet in route mode, and the VOIP (originally on DHCP client route mode, now set as bridged mode on LAN4). Then I connect to a Mikrotik device and feeds the internet untagged and VOIP tagged on a single ethernet cable going to my host PC. My PC is VLAN-aware and I made a Hyper-V virtual Ethernet Adapter to let the tagged VOIP VLAN out.

I checked the “use auth username” on the optional SIP credentials with the same Username, “outbound proxy” as :5060, and “Don’t use STUN”.

I’m using VirtualBox running on Ubuntu 20.04.6 LTS. Originally I’m using this for ACS/TR-069 server but now it has asterisk and freepbx alongside.
The VM is configure with 2 bridged adapters - one is bridged to the physical broadcom adapter (enp0s3 configured static LAN IP) while the other one is bridged to the Hyper-V virtual ethernet adapter (enp0s8 DHCP client for VOIP Vlan).

Yes, I can successfully run and connect to ISP VOIP with no issues at all. But I intend to use the Zoiper as an extension in asterisk, receiving and making calls to and from the ISP Voip number.

Yes, I created the trunk as pjsip. I also tried chan_sip but it has less options and still gives same result, I just found pjsip “friendly” to me so I chose to do that.

I have 1 entry (trunk that I made) in “Rejected” status.

https://pastebin.com/FnH67v6t

I’m confused here. You mention both Hyper-V and VirtualBox. Are you using nested virtualization? If so, why? If these are separate machines, explain the connections between them.

Most Mikrotik routers have a SIP ALG enabled by default, which may be related to your trouble.
Go to IP → Firewall → Service Ports and confirm that the sip entry is disabled.

A Google search for “Flexible routing failed” yielded only two hits, one Russian and one Chinese, I read neither. Google Translate handled the Russian competently, but it’s fairly clear that the poster’s problem was not resolved in the thread. The Chinese link was mostly images, so straightforward translate failed. If you want to pursue this path and don’t read Chinese, you can probably save the images and do image translate.

I couldn’t see anything wrong with the REGISTER request (as captured at the PBX).

However, given that you can easily capture traffic at LAN4 with the Mikrotik, I think that a good way to troubleshoot is to compare the REGISTER requests sent by FreePBX and by the successful Zoiper setup. With luck, that will show what needs to be tweaked on the PBX.

OP meant to say:

where < and > are meta-characters.

Note this is still wrong; it should be: sip:<hostname IP>:5060\;lr or sip:<hostname IP>:5060\;lr\;hide, again with the angle brackets as meta characters.

1 Like

There is no evidence of attempting to use a proxy, and, as a private address is in use, no need to hide the proxy IP.

If in Zoiper, the setting for Outbound Proxy includes an IP address, that could explain your issue with FreePBX. Please state what you have there, marking it as preformatted text, so the forum doesn’t alter what you write. Select the text then click the </> symbol.

I just used the Hyper-V on my Windows 10 host to create the network interface to bind to VOIP VLAN, and then used this interface on the VM host.

I did wireshark capture while connecting my Win10 host Zoiper app:

REGISTER sip:voip.isp-internal.com;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 10.77.11.22:64458;branch=z9hG4bK-524287-1---b6e299d340ac634d;rport
Max-Forwards: 70
Contact: <sip:[email protected]:64458;rinstance=5cb6443daaf7d2e5;transport=UDP>
To: <sip:[email protected];transport=UDP>
From: <sip:[email protected];transport=UDP>;tag=20240e45
Call-ID: Qu0WU_iUI3yRERRb7U4DDQ..
CSeq: 4 REGISTER
Expires: 3600
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Z 5.5.14 v2.10.18.6
Authorization: Digest username="[email protected]",realm="voip.isp-internal.com",nonce="Lt6cAIA8SBev1tnyT3jMlA==",uri="sip:voip.isp-internal.com;transport=UDP",response="51aba4f149290ca8bfbd1fc9d3712b6f",cnonce="1be9bd0d11cd583d11281dad7a619417",nc=00000001,qop=auth,algorithm=MD5
Allow-Events: presence, kpml, talk
Content-Length: 0


SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.77.11.22:64458;branch=z9hG4bK-524287-1---b6e299d340ac634d;rport=64458
Call-ID: Qu0WU_iUI3yRERRb7U4DDQ..
From: <sip:[email protected];transport=udp>;tag=20240e45
To: <sip:[email protected];transport=udp>;tag=HvLBAABx
CSeq: 4 REGISTER
Accept-Resource-Priority: wps.4
P-Associated-URI: <sip:[email protected]>,<sip:[email protected];user=phone>
Contact: <sip:[email protected]:64458;transport=udp;rinstance=5cb6443daaf7d2e5>;expires=3600
Content-Length: 0


NOTIFY sip:[email protected]:64458;transport=udp;rinstance=5cb6443daaf7d2e5 SIP/2.0
Via: SIP/2.0/UDP 10.99.55.33:5060;branch=z9hG4bKppax9uevkg88ckbuuah7grpeh;Role=3;Hpt=8e82_36;X-HwDim=4
Call-ID: [email protected]
From: <sip:[email protected]>;tag=2lhGREVG
To: <sip:[email protected]>
CSeq: 1 NOTIFY
Contact: <sip:10.99.55.33:5060;Dsp=ee8a-200;Hpt=8e82_16;CxtId=4;TRC=ffffffff-ffffffff>
Max-Forwards: 68
Supported: 100rel
Event: ua-profile
Subscription-State: active
P-Asserted-Identity: <sip:[email protected]>,<tel:+61234567890>
P-Called-Party-ID: <sip:[email protected]>
Content-Length: 232
Content-Type: application/simservs+xml
<?xml version="1.0"?>
<simservs>
  <dial-tone-management>
    <dial-tone-pattern>standard-dial-tone</dial-tone-pattern>
  </dial-tone-management>
  <three-party-conference active="true"/>
  <call-waiting active="true"/>
</simservs>


SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.99.55.33:5060;branch=z9hG4bKppax9uevkg88ckbuuah7grpeh;Role=3;Hpt=8e82_36;X-HwDim=4
Contact: <sip:10.77.11.22:64458>
To: <sip:[email protected]>;tag=cb572447
From: <sip:[email protected]>;tag=2lhGREVG
Call-ID: [email protected]
CSeq: 1 NOTIFY
User-Agent: Z 5.5.14 v2.10.18.6
Content-Length: 0


REGISTER sip:voip.isp-internal.com;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 10.77.11.22:64458;branch=z9hG4bK-524287-1---f97342f9a30d64ca;rport
Max-Forwards: 70
Contact: <sip:[email protected]:64458;rinstance=c0202e4e396a706e;transport=UDP>
To: <sip:[email protected];transport=UDP>
From: <sip:[email protected];transport=UDP>;tag=184c7d48
Call-ID: g6w1P2jTRYLwXc2vk2qyfg..
CSeq: 4 REGISTER
Expires: 60
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Z 5.5.14 v2.10.18.6
Allow-Events: presence, kpml, talk
Content-Length: 0

I noticed that instead of the hostname IP address, I see the actual URL of the ISP voip server. I already tried putting [email protected] as the Auth Username on the pjsip trunk settings but the console log still shows ip address instead of the hostname.

I have it as 10.99.55.33:5060 while auth username is [email protected]

OK, I believe that explains a problem, though not necessarily all of them. Please try for your trunk settings:

Username: +61234567890
Auth Username: [email protected]
Secret: (same as Password in Zoiper)
SIP Server: voip.isp-internal.com
Outbound Proxy: sip:10.99.55.33\;lr\;hide
Contact User: +61234567890
From Domain: voip.isp-internal.com
From User: +61234567890

If no luck, paste a new log with pjsip logger on.

Hey it worked!
It looks like I need to add \;lr\;hide on the outbound proxy IP to make the trunk work. When I tried to remove the \;lr\;hide it didn’t register, so I assumed this was the missing piece for my configuration.

I can now receive incoming calls and let it ring one extension, and outgoing calls from the extension is coming out through the ISP Voip correctly and it was received by the called number.

Thank you very much :slight_smile:

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