AsteriskNOW IP PBX behind NAT, clients cannot connect from outside Network - asterisk

This is my first time working with asterisk (basically i know nothing, so bear with me)
i am running Asterisk 11.6 in a virtualbox with 512/kbps internet connection, which is behind NAT.
have two extension 1001 and 1002, these are the situations that is happening to me.
Number 1: call within local using softphone works. "no problem".
Number 2: call from outside (softphone) to local works. "no problem".
Number 3: call from local to outside, just hangs up quickly. "PROBLEM".
Number 4:call from outside to outside, never works. I can hear dial tone but no response from the receiver. "PROBLEM".
I tried forwarding port 5060 both tcp and udp nothing changes...
i also read in somewhere that i have NAT loopback error, at this point it doesnt concerns me.
My problem is i want to connect these two extensions from outside networks...
(1001)Network1--->(server)Network2--->(1002)Network3
likewise backwards... am i missing anything?
here is my sip configuration.
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
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-AsteriskNOW-12.0.76(11.16.0)
SDP Session Name: Asterisk PBX 11.16.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
Call Events: On
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: Disabled
Externhost: <none>
Externaddr: (null)
Externrefresh: 10
Localnet: 192.168.2.0/255.255.255.0
Global Signalling Settings:
---------------------------
Codecs: (gsm|ulaw|alaw|g726)
Codec Order: ulaw:20,alaw:20,gsm:20,g726:20
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:0
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: <not set>
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: Never
Language:
Tone zone: <Not set>
MOH Interpret: default
MOH Suggest:
Voice Mail Extension: *97
----
Name/username Host Dyn Forcerport Comedia ACL Port Status Description
1001/1001 1.39.63.239 D Yes Yes A 28594 UNREACHABLE
1002/1002 106.200.190.71 D Yes Yes A 47695 OK (216 ms)
This is is from my last session.
Here user 1001 is "UNREACHABLE" why? i think that is where my problem is.
help me guys...
Also i am looking for methods to connect with PSTN and GSM.
(If you guys are from India and can help me i can actually pay you, please answer with solution for above problem then i will contact for other methods)

You have to add externip=your_public_ip in [general] section of sip.conf.
Also you have to forward RTP ports range. Usually it's 10000-20000 UDP. You can see/change this range in rtp.conf.

SIP will always cause problem when server is Behind Nat.
If your devices Support IAX which is Inter-Asterisk eXchange, works perfect for your situations then utilize it.
Still you are looking to solve SIP problems read this tutorial

Related

asterisk sip.conf tls encryption

I am stuck in sometime with asterisk encryption.
sip.conf reload without any problem, as dial-plan, registering sip clients - no problem at all
When I call form one zoiper sip account to another wireshark capture tcp eth traffic shows following lines:
192.168.13.252 192.168.13.253 RTP 224 PT=ITU-T G.711 PCMU, SSRC=0x4C8C7A63, Seq=2259, Time=3154311440
192.168.13.253 192.168.13.252 SKYPE 224 Audio Unk: 5
192.168.13.253 192.168.13.252 SKYPE 224 Audio Unk: 5
192.168.13.253 192.168.13.252 SKYPE 224 Audio Unk: 5
192.168.13.252 192.168.13.253 RTP 224 PT=ITU-T G.711 PCMU, SSRC=0x4C8C7A63, Seq=2260, Time=3154311600
192.168.13.252 192.168.13.253 RTP 224 PT=ITU-T G.711 PCMU, SSRC=0x4C8C7A63, Seq=2261, Time=3154311760
192.168.13.253 192.168.13.252 SKYPE 224 Audio Unk: 5 ...
192.168.13.253 - asterisk server
192.168.13.252 - android phone (zoiper)
The problem is no sound on both phones during phone calls. Both phones send packages but not receiving any.
That is the SKYPE protocol involved in it? It suppose to be all line of RTP protocol.
If you are registering through SIP but receiving no audio, then for some reason your higher ports used for RTP are not receiving the data, most likely. Usually these ports are 10000-20000. Make sure both IPs can talk to each other through ports 5060-5061 and the higher ports. Can you display your asterisk CLI output while trying to make a call?
asterisk -vvvvvvvvvvvr
Great let's get some details.
rtp.conf
[general]
rtpstart=10000
rtpend=20000
No errors reloading sip.
This is interesting:
####CLI ### asterisk -vvvvvvvvvvvr #### shows
== Using SIP RTP CoS mark 5
> 0x7fb264004c00 -- Strict RTP learning after remote address set to: 192.168.13.104:58136
-- Executing [200#phones:1] Dial("SIP/201-0000000b", "SIP/200") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/200
-- SIP/200-0000000c is ringing
> 0x7fb2440062f0 -- Strict RTP learning after remote address set to: 192.168.13.106:62856
-- SIP/200-0000000c answered SIP/201-0000000b
-- Channel SIP/200-0000000c joined 'simple_bridge' basic-bridge <9726e2bc-f161-452c-b489-c1829af2ed70>
-- Channel SIP/201-0000000b joined 'simple_bridge' basic-bridge <9726e2bc-f161-452c-b489-c1829af2ed70>
> 0x7fb264004c00 -- Strict RTP switching to RTP target address 192.168.13.104:58136 as source
> 0x7fb2440062f0 -- Strict RTP switching to RTP target address 192.168.13.106:62856 as source
> 0x7fb264004c00 -- Strict RTP learning complete - Locking on source address 192.168.13.104:58136
> 0x7fb2440062f0 -- Strict RTP learning complete - Locking on source address 192.168.13.106:62856
-- Channel SIP/201-0000000b left 'simple_bridge' basic-bridge <9726e2bc-f161-452c-b489-c1829af2ed70>
-- Channel SIP/200-0000000c left 'simple_bridge' basic-bridge <9726e2bc-f161-452c-b489-c1829af2ed70>
== Spawn extension (phones, 200, 1) exited non-zero on 'SIP/201-0000000b'
####
According to the CLI console information everything is in order. Asterisk runs on local IP, no firewall.

RTP audio stream works only in one direction in a SIP call

I'm developing software feature for a Session Boarder Controller(SBC).
I'm trying to establish a SIP call using two SIP clients and a Session Boarder Controller(SBC). Asterisk is used as the soft-switch.
When I call, the SIP signalling is working fine. But I am getting audio only in one direction. I captured rtp packets on all interfaces using wireshark. I observed that rtp packets in one direction is being dropped by asterisk.
Note: There is no send only attribute in any of the SIP/SDP messages.
I would like to know if there is any settings in asterisk that may cause this issue?
One more thing that I would like to know is that, from where a SIP client gets the RTP connection information. The port information is present in the media attribute
m=audio 16388 RTP/AVP 8 0 101
From where does the client get the transport IP address? is it from the "o=" field or "c=" field in the SDP or any other fields in the SDP or SIP?
You should troubleshoot the problem by capturing the complete call with Wireshark. Then look carefully at:
Client A initial INVITE: which port is it expecting media on (m= line) which address is it expecting media on (c= line)
SBC for Client A initial INVITE: If the SBC is anchoring the media (I assume so) check m / c lines
SBC for Client B initial INVITE: Which port / ip (m/c lines) is SBC for Client A expecting media on
Client B initial INVITE: Which port / ip (m/c lines) is SBC for Client B expecting media on
Are all nodes in this direction sending media on to the correct ports / ips (look at the RTP streams in wireshark)?
Then check the other direction (based on the SDP in the 183 or 200 (depending on your signaling flow)).
Note: In wireshark there is a nice feature which helps alot: Telephony --> VoIP Calls, which shows you the call flow more graphically

No audio in WebRTC and Asterisk

I have a strange issue with Asterisk (in this case 13.2 version) and WebRTC.
So, I have latest Asterisk 13.2, latest Crome (with Firefox - same problem) and sip.js (also tried with sipml5) and local network - no nat or firewall.
The problem: if call is answered immediately - everything works fine. But if there are some delay in answer (say, 10 seconds) - no audio in both directions.
In RTP debug I saw that if there is some delay - destination ip address is incorrect. After removing ice servers from client config - both addresses is correct, but still no audio.
Below is debug for call with audio:
rtp http://pastebin.com/EzfByCG5
sip http://pastebin.com/1Y08yF5s
and no audio call (answered after 10 seconds delay):
rtp http://pastebin.com/TNnFkz6M
sip http://pastebin.com/zG7pjcZD
Also in FreeSwitch everything works fine, no matter when call is answered.
Starting with Asterisk 12 you need to have pjproject libraries installed, otherwise you most likely won't have audio in your WebRTC calls and no warning whatsoever!
First question: have you ensured all firewall configs permit RTP streams from the chosen STUN / ICE server unconditionally?
My own experience is that audio issues with WebRTC are almost always related to STUN / ICE & Firewall.
Did you follow a tutorial for your set up? If so, which one?
Check the log...
Peer audio RTP is at port 192.168.88.187:50026
sip_route_dump: route/path hop: sip:889#df7jal23ls0d.invalid;transport=ws
[Feb 13 06:15:59] ERROR[1055][C-00000031]: netsock2.c:303 ast_sockaddr_resolve: getaddrinfo("df7jal23ls0d.invalid", "(null)", ...): Name or service not known
[Feb 13 06:15:59] WARNING[1055][C-00000031]: chan_sip.c:16158 __set_address_from_contact: Invalid host name in Contact: (can't resolve in DNS) : 'df7jal23ls0d.invalid'
I would use Freeswitch, no doubt :-)

Asterisk: Connecting an Asterisk System To SIP Provider

Setup:
Centos 6
OS: Linux CentOS 64-Bit
CPU: Intel® Core™ i7 - 4 cores
Asterisk 11
libpri 1.4
dahdi 2.9.1
I want to send calls to my SIP provider via asterisk. I want to use a softphone to make outgoing calls, when I make outgoing calls on the softphone it needs to route through my asterisk server and then out to the SIP Provider. Currently when I make an outbound call it produces a "Failed to authenticate" and status is 'CONGESTION' notices.
My question is simple: Since my softphone is calling from "User1" (as shown below) What do I need to write in my sip.conf and extensions.conf files in order for the SIP provider to make the outgoing call for me?
My Thoughts:
I feel like I am missing a part of the process, like how User1 is set up to handle outgoing calls...
See an overview of how I set these two files up currently:
notes: - all username and passwords have been removed for this post. - sip.us is the sip provider
sip.conf:
[general]
transport=udp
register => username:password#gw1.sip.us
[myprovider]
type=peer
insecure=port,invite
host=gw1.sip.us
port=5060
dtmfmode=rfc2833
canrevinvite=no
disallow=all
allow=ulaw
qualify=yes
qualifyfreq=30
nat=force_rport,comedia
trustrpid=yes
fromdomain=gw1.sip.us
username=*****
secret=*****
context=from-trunk
rfc2833compensate=yes
session-timers=refuse
[friends_internal](!)
type=friend
host=dynamic
context=users
disallow=all
allow=ulaw
allow=alaw
[user1](friends_internal)
secret=****
[user2](friends_internal)
secret=****
now the extensions.conf:
...
...
exten=>_1NXXNXXXXXX,1,Dial(SIP/${EXTEN}#gw1.sip.us)
[users]
exten=>6001,1,Dial(SIP/user1,20)
exten=>6002,1,Dial(SIP/user2,20)
now the asterisk cli output when i try making an outgoing call using softphone:
== Using SIP RTP CoS mark 5
-- Executing [12015550155#users:1] Dial("SIP/user1-0000001e",
"SIP/12015550155#gw1.sip.us") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/12015550155#gw1.sip.us
[May 4 10:02:13] NOTICE[28935][C-0000002a]: chan_sip.c:23094
handle_response_invite: Failed to authenticate on INVITE to
'<sip:user1#501.62.174.2>;tag=as798e5009'
-- SIP/gw1.sip.us-0000001f is circuit-busy
== Everyone is busy/congested at this time (1:0/1/0)
-- Auto fallthrough, channel 'SIP/user1-0000001e' status is 'CONGESTION'
asterisk cli> sip show registery
Host dnsmgr Username Refresh State Reg.Time
gw1.sip.us:5060 N username 105 Registered Sun, 04 May 2014 10:28:05
1 SIP registrations.
asterisk cli> sip show peers
Name/username Host Dyn Forcerport Comedia ACL Port Status
user1/user1 68.198.. D Auto (No) No 55461 Unmonitored
user2/user2 68.198.. D Auto (No) No 55461 Unmonitored
myprovider/username 65.254.44.194 Yes Yes 5060 OK (42 ms)
Try changing the #gw1.sip.us to #myprovider and see if there's any changes. This will force asterisk to use the configured trunk [myprovider] instead of directly forward the call to gw.sip.us directly.
Hope this helps.
Your DialPlan is not correct clearly from your configuration files.
Аs a first step change your register string like:
register => username:password#gw1.sip.us\Myprovider
and then add the outgoing and incoming dialplan in your extensions.conf and include these dialplans into your users context. like:
e.g: you use 6XXX series to dial to the provider:
[outgoing]
exten => _6XXX,1,Dial(SIP/Myprovider/${EXTEN:0})
exten => _6XXX,2,Hangup
and for incoming calls
[incoming]
include = users ; this will go into your local context and dial your extensions
and in users context add outgoing context like
[users]
include = outgoing
I hope this will help you :)

Windows 7 or Vista TCP behavior changes

Resolution, of sorts
The client computer that was showing this problem had Trend Micro Security installed. This security suite placed a service or driver on top of each network adapter in the system. I did not bother to debug further once this legacy app started working again.
Update 1
I disabled TCP window scale auto-tuning on Win7.
On Windows 7 if I unplug the ethernet cable directly connected to the server, the disconnection happens after about 5 seconds but the client process crashes. netstat on the server reports two TCP connections to the client that are no longer valid, because the client process did not gracefully shutdown and close the connections.
After putting the server in this strange state after the physical disconnect, If I restart the client process it hangs while connecting to the server (just as described in the original)
If I perform a physical disconnection on the XP side, the disconnect happens more quickly than on Win7. Some sort of keep alive value or behavior is different on XP. While ssh'd (via Putty) the ssh connection dies more quickly on XP than Win7 as well.
Original
I have a legacy TCP client/server app that appears to foul up the server only when the client is a Windows 7 machine.
The server is OpenEmbedded Linux running 2.6.11.
A Windows 7 client connects for a bit, and eventually gets to a state where the client disconnects after a second or two.
Once the server is in this state, If I immediately connect a Windows XP client, the XP client cannot connect either.
I cannot appear to get the server into the buggy state by connecting with an XP client alone.
I'd like to know what changes were made to the TCP/IP stack starting with Vista or Windows 7 so I can better debug the legacy code.
I'd also like to know what commands I can run on the Linux server that might better help me understand why the connections are failing.
Perhaps the best thing you can do is to fire up tcpdump or wireshark under linux and analyze the TCP SYN sent by both Windows XP and Windows 7. Wireshark allows you to break out bit-by-bit what TCP options are sent... for example, this is what you see from a debian lenny box making a TCP connection:
Transmission Control Protocol, Src Port: 58456 (58456), Dst Port: 23 (23), Seq: 0, Len: 0
Source port: 58456 (58456)
Destination port: 23 (23)
Sequence number: 0 (relative sequence number)
Header length: 40 bytes
Flags: 0x02 (SYN)
0... .... = Congestion Window Reduced (CWR): Not set
.0.. .... = ECN-Echo: Not set
..0. .... = Urgent: Not set
...0 .... = Acknowledgment: Not set
.... 0... = Push: Not set
.... .0.. = Reset: Not set
.... ..1. = Syn: Set
.... ...0 = Fin: Not set
Window size: 5840
Checksum: 0x8b77 [correct]
[Good Checksum: True]
[Bad Checksum: False]
Options: (20 bytes)
Maximum segment size: 1460 bytes
SACK permitted
Timestamps: TSval 136991740, TSecr 0
NOP
Window scale: 6 (multiply by 64)
My suspicion is that you'll see differences in RFC 1323 Window Scaling, but I don't have an XP machine handy to validate this.
I gave a detailed response of how to analyze TCP connections using tcptrace under linux in this answer...
How can I measure the performance and TCP RTT of my server code?
I also suspect a Window Scaling issue. I cannot find a link just at the moment, but there were complaints when Vista first came out reporting that that something was screwing with some routers (belkins If I recall). They traced it down to a problem with one of the window sizes that Vista (and thereby Windows 7) changes by default. The routers would get hung up and need to be reset every few minutes.
You can issue some commands to turn off window scaling, see if your problem goes away.
From Here:
netsh interface tcp set global autotuninglevel=disabled
Edit:
Try disabling IPv6 on windows 7. Link on how to do that. With IPv4, it should act the same as windows XP. Load up wireshark on the two systems and compare the differences

Resources