Cannot connect with SIP using Asterisk - asterisk

I configured SIP connection with Asterisk. Server is running successfully but when i try to connect sip with X-Lite. Its giving Sip Error 408.
disallow=all ; First disallow all codecs
allow=ulaw ; Allow codecs in order of preference
externip = **.**.***.***; Address that we're going to put in outbound SIP
; messages if we're behind a NAT
;localnet=192.168.0.0/255.255.0.0; All RFC 1918 addresses are local networks
localnet=10.0.0.0/255.0.0.0 ; Also RFC1918
;localnet=172.16.0.0/12 ; Another RFC1918 with CIDR notation
;localnet=169.254.0.0/255.255.0.0 ;Zero conf local network
nat=route ; Global NAT settings (Affects all peers and users)
; yes = Always ignore info and assume NAT
; no = Use NAT mode only according to RFC3581 (;rport)
; never = Never attempt NAT mode or RFC3581 support
; route = Assume NAT, don't send rport
; (work around more UNIDEN bugs)
This is my sip.conf file
and my extensions.conf is:
exten => *98,1,VoiceMailMain
exten => *98,2,Hangup
Please check the details and help me to connect. THANKS

If you are using Asterisk 13 then you should configure the extensions in pjsip.conf (and not in sip.conf file). Asterisk 13 have moved to pjsip.
Otherwise the error code 408 means "Request Timeout" so most probably X-Lite doesn't receive any answer for the REGISTER request. Double check your IP/port/NAT configurations.
If still doesn't then you should have a look at the logs.
(Enable logs by sipdebug=yes and in logger.conf set the Verbose config to "notice,warning,error,debug,verbose,dtmf" below the [logfiles] section)

Related

Cannot Find BACnet Device

I am quite new to the BACnet protocole but I am facing some troubles finding a device on a network.
Basically, I have a setup on a network 128.10.100.XXX/24 where I have multiple devices, as my nmap scan will show
root#xxx:/home/xxx# nmap -sP 128.10.100.120/24
Starting Nmap 7.80 ( https://nmap.org ) at 2022-11-02 05:11 UTC
Nmap scan report for 128.10.100.1
Host is up (0.00076s latency).
MAC Address: 00:50:06:XX:XX:XX (TAC AB)
Nmap scan report for 128.10.100.150
Host is up (0.00059s latency).
MAC Address: 00:80:4F:XX:XX:XX (Daikin Industries)
Nmap scan report for 128.10.100.160
Host is up (0.00024s latency).
MAC Address: 00:50:06:XX:XX:XX (TAC AB)
Nmap scan report for xxx (128.10.100.120)
Host is up.
When I run specific scans for BACnet, all devices have an open 47808 port:
Starting Nmap 7.80 ( https://nmap.org ) at 2022-11-02 13:08 UTC
Nmap scan report for 128.10.100.150
Host is up (0.0093s latency).
Not shown: 999 closed ports
PORT STATE SERVICE
47808/udp open|filtered bacnet
MAC Address: 00:80:4F:XX:XX:XX (Daikin Industries)
However, when I am trying to use BACnet utilities (BACpypes in python or bacnet-stack in node.js), no device is found. I tried multiple libraries and various setups (modifying the broadcast address, etc...) without any success.
I struggle to understand the reason...
Thank you in advance for your help,
A.
Have you validated your setup using 3rd party tools such as YABE ?
Fire up wireshark with a capture filter "port 47808", then look at the who-is from your app vs the who-is from YABE.
Also check the netmask on both devices match... this will affect the broadcast messages.
Speaking of which, try a directed who-is message to the controller from your app to see if the controller responds.
Things worth considering :-
Tools such as YABE, VTS and Wireshark - to learn from the success cases/successful instances of communication.
The network card (NIC) that your tools and/or libraries are using/selecting to send the ('service' request) messages - e.g. definitely don't mix routable addresses with non-routable 'private' addresses (between the BACnet 'client' IP & the 'server' IP).
(UDPv4-only) 'Broadcasts' will only work upon the local network (- if a BBMD is not present & correctly set-up to relay the broadcast on to another part/hop of the "internetwork"/connected networks).
If you're unlucky - with a particular device, your client port just might have to be 47808/0xBAC0; and just possibly for the broadcasts too.
Also try directed/'unicast' traffic/'service' requests too - e.g. attempting to read the device object instance # (DOIN) of a target device; check you've got/are specifying the correct DOIN when targeting/firing a request at a device.
Does the target device have a BACnet router or BACnet gateway in front of it (- therefore would also need the inclusion of a DNET & DADR paired values as part of addressing it)?
If so, are you talking the same variant of BACnet, e.g. IP - as in BACnet/IP between both the (BACnet) 'client' & 'server'/serving device?
If it's a commercial/enterprise device, does it have a IP whitelist - to allow for the processing of incoming requests?

Can't get RTPEngine to work with Kamailio and Asterisk

I just can't get rtpengine to work. i have tried multiple configurations, but to no avail. I would appreciate any help/advice I can get. Note that calls work good if rtpengine is disabled.
Here is my setup =>
Public IP: 20.20.20.20
Private IP 10.10.10.10
flow =>
webrtc client <-> kamailio+rtpengine <-> asterisk <-> kamailio <-> legacy sip phone
rtpenngine startup (I have tired a few different startups) =>
rtpengine --interface=int/10.10.10.10 --interface=ext/10.10.10.10!20.20.20.20 --listen-ng=127.0.0.1:12221 --pidfile=/var/run/rtpengine --dtls-passive -f -m 10000 -M 20000 -E
kamailio =>
Invites: rtpengine_manage("trust-address replace-origin replace-session-connection direction=ext direction=int ICE=remove RTP/AVP");
Reply's: rtpengine_manage("trust-address replace-origin replace-session-connection ICE=force RTP/SAVPF");
I have tried direction ext ext; and many other combinations, each producing it's own incorrect behavior.
I would really appreciate any help!
Thank you,
Steve
Try using the actual interface name in your configuration and listen on the loopback and the internal IP.
--interface=eth1/10.10.10.10!20.20.20.20
--listen_ng=127.0.0.1:12221
--listen_ng=10.10.10.10:12221
Configure Kamailio to contact rtpengine on 10.10.10.10:12221.
Rtpengine modified packets can exceed the UDP size limit, therefore if you are using UDP for signaling anywhere, check if these packets are being fragmented as a result. If that is the case, then the only real solution is to use TCP for all legs.

webrtc2sip + sipml5 + asterisk no audio issue

I am having a trouble in having a sipml5 to call other sipml5 via webrtc2sip and asterisk.
I have installed configured asterisk(version 11.10.0) + webrtc2sip(latest) + sipml5(chrome version 30.0.1599.66) to call from one box to other over websocket.
I can make a SIP call through and answer from other side but seems like there is no audio/voice packets gets exchanged as is evident by rtp and sip debug log and tcpdump.
asterisk and users are on separate servers and they do establish sip call but it's just a audio packet that does not appear.
I've created 2 users(1060 and 1061) and when I make a call I get these asterisk response.
rtp set debug on
RTP Debugging Enabled
*CLI> == Spawn extension (default, 1060, 1) exited non-zero on 'SIP/1061-00000000'
== Using SIP RTP CoS mark 5
-- Executing [1060#default:1] Dial("SIP/1061-00000002", "SIP/1060") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/1060
-- SIP/1060-00000003 is ringing
-- SIP/1060-00000003 answered SIP/1061-00000002
Asterisk settings are..
sip.conf
[general]
port=5060
bindaddr=0.0.0.0
context=default
transport=ws,wss,udp
srvlookup=yes
users.conf
[1060]
type=peer
username=1060
host=dynamic
secret=1234
context=default
disallow=all
allow=ulaw
transport=udp,ws,wss
encryption=yes
avpf=yes
icesupport=yes
nat=yes,force_rport
[1061]
type=peer
username=1061
host=dynamic
secret=1234
context=default
encryption=yes
avpf=yes
icesupport=yes
nat=yes
disallow=all
allow=ulaw
transport=udp,ws,wss
extensions.conf
[general]
static=yes
writeprotect=no
[default]
exten=>1060,1,Dial(SIP/1060)
exten=>1061,1,Dial(SIP/1061)
rtp.conf
[general]
icesupport=yes
stunaddr=stun.l.google.com:19302
strictrtp=no
rtcpinterval=6000
rtpchecksums=no
I can hear dialling sound on one end and ringing on the other end but as soon as the call is connected, can't hear anything.
Could anyone kindly help please.. I am very very desperate..
Thanks in advance!
You set rtp debug on but there's no rtp flow output, so call setup has gone wrong, you should check inside the dump of sip packets the sdp data they tried to share.
But you also have a better option: latest versions of Asterisk work with WebSocket and WebRTC like a charm without any external layer or component, so configuration will be much easier.
In addition you could use apache (at least 2.4) as websocket tunnel reverse proxy to the asterisk server, so you can do all the things (but rtp) with a single connection and a single ssl certificate use (another common problem is that the same selfsigned certificate is required to be explicitly accepted by user even if for the same server but on different port...and browser don't ask users to do that but just silently refuse to connect to websocket)
remove avpf option, it is not needed when using webrtc2sip.
If still no voice - check sipml5 log (firefox or chrome debug console ) while SIP registration and while the call.

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 :)

how to write a program to report the local IP address such as 192.168.1.102?

since my Linksys router doesn't assign a fixed local IP to the computers (PC and Mac and Linux), i'd like to write a script so that every minute, the computers will update to each other so that
http://localhost/list.html
on each machine will contain a list of names of all PC and Mac and a link to their apache server (pointing to http://192.168.1.102, etc)
it looks like a way to find out the local IP address is by ipconfig on PC, and ifconfig on the Mac and Linux, and to do it programmatically, it will be gethostbyname().
But I tried on Ruby, that
irb(main):001:0> require 'socket'
=> true
irb(main):002:0> p Socket::gethostbyname("localhost")
["Core2Duo", [], 2, "\177\000\000\001"]
irb(main):005:0> p Socket::gethostbyname("core2duo")
["Core2Duo", [], 2, "\300\250\001g"]
=> nil
and ipconfig actually shows
IPv4 Address. . . . . . . . . . . : 192.168.1.103
so is this the right way to do it? I can hack it by executing "ipconfig" in Ruby and use regular expression to get the result, but would be nice to do it using a more standard way.
Socket::getaddrinfo might be more of what you're looking for:
Socket::getaddrinfo('localhost', 'http')
[["AF_INET", 80, "localhost", "127.0.0.1", ...]]
Socket::getaddrinfo('core2duo', 'http')
[["AF_INET", 80, "Core2Duo", "192.168.1.103", ...]]
Or, you might just try:
Socket::getaddrinfo('core2duo', 'http')[0][3]
"192.168.1.103"
You can do this in Java using:
Socket s = new Socket();
s.getLocalSocketAddress();
If you run Bonjour on your Windows systems and avahi on your Linux systems, you can do away with the need to determine each system's IP address. You can then simply address each system using "hostname.local". More info here.
Why not just turn off DHCP for those machines and assign them fixed IP addresses?
Edit in response to comments: At least as-of three years or so ago (last time I bought a router), Linksys routers allowed you to set the bottom IP address for the built-in DHCP server. Then, you go into the individual machines' network setup, disable DHCP, and assign physical addresses. For example, on my home network the router is 192.168.1.1, the Terastation is 1.2, the printer is 1.3, my Linux box is 1.99, and the router is configured to give out 1.100 and above.
The problem in the Ruby script might be that there is no DNS name resolution on your network, this is often hidden if you usually share stuff between computers with SMB/CIFS because that has it's own name discovery protocol.
If you are going to be broadcasting datagrams with the name/ip info in, then you don't really need a PC to know its own IP address. Just send the datagram containing its name, then use recvfrom() - or equivalents - to catch it at the other PCs. That way the receivers can extract the sender's IP address directly via the recvfrom() function.
As a bonus, that should work where the sending PC has more than one network adapter.

Resources