Inbound callers get "the number you have dialed is no longer in service"

FreePBX server [v:13.0.191.11] sits behind a firewall.

I have a Twilio SIP trunk and an inbound route pointed to an IVR.

If I turn “Allow Anonymous Inbound SIP Calls” to YES, the inbound calls are routed. Is there a way to get the calls I want to route and keep the riff raff out. I am getting a lot of random inbound calls.

If you have to set “Allow Anonymous” to YES, then something probably doesn’t jive between the ‘host’ specified in your trunk settings and what’s coming into the PBX from Twillio.

If you look at the Asterisk logs (/var/log/asterisk/full) when a call comes in, it’s probably coming from an IP other than what’s specified as the ‘host’ in your inbound trunk configuration.

Here is an inbound call capture…

Record-Route: sip:10.0.1.1:65476;lr;ftag=33546565_6772d868_5b24209f-b26e-4ed9-babc-e63e48cdea86
From: sip:[email protected];isup-oli=61;pstn-params=808481808882;tag=33546565_6772d868_5b24209f-b26e-4ed9-babc-e63e48cdea86
To: sip:[email protected];user=phone
CSeq: 517692 INVITE
Max-Forwards: 73
P-Asserted-Identity: sip:[email protected]:5060
Diversion: sip:[email protected];reason=unconditional
Call-ID: [email protected]
Via: SIP/2.0/UDP 10.0.1.1:65476;branch=z9hG4bK8c0f.0c3039c2.0
Via: SIP/2.0/UDP 172.18.1.44:5060;rport=5060;received=172.18.1.44;branch=z9hG4bK5b24209f-b26e-4ed9-babc-e63e48cdea86_6772d868_308-11024207129901599555
Contact: sip:[email protected]:44225;transport=udp
Allow: INVITE,ACK,CANCEL,BYE,OPTIONS
User-Agent: Twilio Gateway
X-Twilio-AccountSid: ACeebabe53e79708f8ea96eec52da02406
Content-Type: application/sdp
X-Twilio-CallSid: CA985ab964d6543d173b5f6f16fb715b39
Content-Length:258

v=0
o=root 844458201 844458201 IN IP4 10.0.1.1
s=Twilio Media Server Edge
i=(o=IN IP4 54.172.61.205)
c=IN IP4 10.0.1.1
t=0 0
m=audio 44224 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv

===============================
sip_additional.conf
[Twilio_Inbound_Trunk]
host=clearsightokc.pstn.twilio.com
type=peer
insecure=port,invite
context=from-trunk

===============================

I have turned NAT off from my router. Traffic from my static IP address is being forwarded directly to my FreePBX server. I can now properly route inbound calls and outbound calls are still working. I had to setup a separate inbound trunk for each of Twilio’s four servers.

BUT … now my audio is not routing correctly. All TCP and UDP ports are open from the static IP on the router to the FreePBX server. Seems like I am still missing a piece of the puzzle. Since it seems RTP issues are NAT related, here are my NAT settings:

  • No NAT from router to FreePBX server
  • Settings->Asterisk SIP Settings->Chan SIP Settings->NAT = yes

What else can I look at? When I had NAT turned on in my router, the inbound calls appeared to be coming from my router and thus could not be routed. When I turned on Allow Anonymous Inbound SIP calls = Yes I got calls with audio. However, I don’t care to run the system that way.

Here are the rest of my settings (less the public IP)

Global Settings:

UDP Bindaddress: 0.0.0.0:5060
TCP SIP Bindaddress: Disabled
TLS SIP Bindaddress: Disabled
Videosupport: No
Textsupport: No
Ignore SDP sess. ver.: No
AutoCreate Peer: Off
Match Auth Username: No
Allow unknown access: Yes
Allow subscriptions: Yes
Allow overlap dialing: Yes
Allow promisc. redir: No
Enable call counters: No
SIP domain support: No
Path support : No
Realm. auth: No
Our auth realm asterisk
Use domains as realms: No
Call to non-local dom.: Yes
URI user is phone no: No
Always auth rejects: Yes
Direct RTP setup: No
User Agent: FPBX-13.0.191.11(13.14.0)
SDP Session Name: Asterisk PBX 13.14.0
SDP Owner Name: root
Reg. context: (not set)
Regexten on Qualify: No
Trust RPID: No
Send RPID: No
Legacy userfield parse: No
Send Diversion: Yes
Caller ID: Unknown
From: Domain:
Record SIP history: Off
Auth. Failure Events: Off
T.38 support: No
T.38 EC mode: Unknown
T.38 MaxDtgrm: 4294967295
SIP realtime: Disabled
Qualify Freq : 60000 ms
Q.850 Reason header: No
Store SIP_CAUSE: No

Network QoS Settings:

IP ToS SIP: CS3
IP ToS RTP audio: EF
IP ToS RTP video: AF41
IP ToS RTP text: CS0
802.1p CoS SIP: 4
802.1p CoS RTP audio: 5
802.1p CoS RTP video: 6
802.1p CoS RTP text: 5
Jitterbuffer enabled: No

Network Settings:

SIP address remapping: Enabled using externaddr
Externhost:
Externaddr: 99.99.99.99:0
Externrefresh: 10
Localnet: 10.0.1.0/255.255.255.0
10.254.254.0/255.255.255.0

Global Signalling Settings:

Codecs: (ulaw|alaw|gsm|g726)
Relax DTMF: No
RFC2833 Compensation: No
Symmetric RTP: Yes
Compact SIP headers: No
RTP Keepalive: 0 (Disabled)
RTP Timeout: 30
RTP Hold Timeout: 300
MWI NOTIFY mime type: application/simple-message-summary
DNS SRV lookup: No
Pedantic SIP support: Yes
Reg. min duration 60 secs
Reg. max duration: 3600 secs
Reg. default duration: 120 secs
Sub. min duration 60 secs
Sub. max duration: 3600 secs
Outbound reg. timeout: 20 secs
Outbound reg. attempts: 0
Outbound reg. retry 403:No
Notify ringing state: Yes
Include CID: No
Notify hold state: Yes
SIP Transfer mode: open
Max Call Bitrate: 384 kbps
Auto-Framing: No
Outb. proxy:
Session Timers: Accept
Session Refresher: uas
Session Expires: 1800 secs
Session Min-SE: 90 secs
Timer T1: 500
Timer T1 minimum: 100
Timer B: 32000
No premature media: Yes
Max forwards: 70

Default Settings:

Allowed transports: UDP
Outbound transport: UDP
Context: from-sip-external
Record on feature: automon
Record off feature: automon
Force rport: Yes
DTMF: rfc2833
Qualify: 0
Keepalive: 0
Use ClientCode: No
Progress inband: No
Language: en
Tone zone:
MOH Interpret: default
MOH Suggest:
Voice Mail Extension: *97

No help at all?