Trying to connect devices in different networks

Dear community,

Currently, I am able to establish SIP communication between a mobile phone and a PC within the same (private) network by means of Asterisk. My sip.conf file contains something like the following:

[general]
type=global
context=local_test
callevents=yes
notifyhold=yes
allowoverlap=no
udpbindaddr=0.0.0.0

[ste]
type=friend
secret=ste
host=dynamic
context=local_test

[steand]
type=friend
secret=steand
host=dynamic
context=local_test

Now, I want to replicate this experiment by having both devices in different networks, so it is expected to deal with the public network and, therefore, NAT. The scenario I prepared is as follows:

  • The call receiver, which is a PC also having the Asterisk server, is in the same private network as the caller, which is a mobile phone. Optionally, the mobile phone is connected to the data network so both devices are indeed in different networks.

  • I added the following under the [general] tab in the sip.conf file:
    port=5060
    bindaddr=0.0.0.0:5060
    externip=83.48.67.242
    localnet=192.168.5.0
    localmask=255.255.255.0

As well as the following under each user tab, i.e., [ste] and [steand]:
nat=force_rport,comedia
ice_support=yes

  • When trying to make a call, I see that the caller is not registered and it seems that Asterisk sees nothing. To make such a call, I set the public IP 83.48.67.242 for Asterisk.

  • As I am also using PJSIP, I also tried by modifying the pjsip.conf file as follows:
    [transport-udp-nat]
    type=transport
    protocol=udp
    bind=0.0.0.0:5060
    local_net=192.168.5.0/24
    external_media_address=83.48.67.242
    external_signaling_address=83.48.67.242

This way, I also fixed “transport=transport-udp-nat” under each user tab, i.e., [ste] and [steand]. Nevertheless, when reloading the SIP configuration at Asterisk, I get the following message: chan_sip.c:32405 reload_config: ‘transport-udp-nat’ is not a valid transport type. if no other is specified, udp will be used.

In summary I am not able to make it work. Any help will be really appreciated.

Thank you very much in advance.

You can’t configure transports in chan_pjsip and use them in chan_sip as you attempted to do. They are limited to their respective channel drivers.

Dear jcolp, thank you!

I tried again with the following configuration of the sip.conf file:

[general]
type=global
context=local_test
callevents=yes
notifyhold=yes

bindaddr=0.0.0.0:5060
externip=83.48.67.242
localnet=192.168.5.0
localmask=255.255.255.0

[ste]
type=friend
secret=ste
host=dynamic
context=local_test
nat=force_rport,comedia
ice_support=yes

[steand]
type=friend
secret=steand
host=dynamic
context=local_test
nat=force_rport,comedia
ice_support=yes

Now I reload the SIP configuration with no warnings (transport=udp). Indeed, my WAN IP address is 83.48.67.242 and the PC with both Asterisk and the application that receives the call is in 192.168.5.17.

Asterisk seems to be unreachable and the calling device returns the following error: Called handleMessage with state info:State:LIB_CONNECTION_FAILED:Connection Failed: Code:408 Request Timeout.

Any ideas?

Thank you again!

408 means it sent the request but got no reply. You need to trace the request through the network to find out where it is getting lost, and if it reaches the other end, you need to trace the response. Firewalls are a common problem, but check that your NAT setting are resulting in the correct addresses in the SIP messages.

Thank you, david551, I will search through what you suggest.

I will write again when I have some news.

These facts confirm that the issue is related to your IP network rather than Asterisk itself.
Your Asterisk turns to be running on a private IP, behind NAT. If it is unreachable from the outside world, make sure that you have configured port forwarding to direct inbound IP traffic to the internal IP and port.

Dear @santipc santipc …did you find the solution???