Asterisk access from the Internet NAT

I have configured my server it works perfectly in the local network, but doesn’t work from the Internet.

My network topology is following

Router is connected to the Internet over PPPoE.
I set up port forwarding and range port forwarding
Here is settings from my router.

And port 5060 for SIP (but it doesn’t make sense, because it fits the range)

Asterisk Server is in the local network.

Consider situation I am calling from Internet via mobile phone network.
The problem is that I can hear well person inside my home local network, but he doesn’t hear me. And usually after few seconds connection is dropped.
But I can call this person or any other member of the network.
So SIP protocol works, but the problem I guess with RTP protocol, as far as all media data is transferred over RTP.

In case of two clients calling from the internet neither of them can hear anything.

As you can see, I opened all required ports.

Here is my sip.conf file

[general]
context=main-context                  ; Default context for incoming calls. Defaults to 'default'
allowguest=no                  ; Allow or reject guest calls (default is yes)
allowoverlap=no                 ; Disable overlap dialing support. (Default is yes)
udpbindaddr=0.0.0.0             ; IP address to bind UDP listen socket to (0.0.0.0 binds to all)
limitonpeers=yes
tcpenable=no                    ; Enable server for incoming TCP connections (default is no)
tcpbindaddr=0.0.0.0             ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces)
transport=udp                   ; Set the default transports.  The order determines the primary default transport.
srvlookup=yes                   ; Enable DNS SRV lookups on outbound calls
nat=route                               ; in SRV records
externip=193.151.106.238
externaddr=193.151.106.238         ; use this address.
limitonpeers=yes; may override the address/port information specified in the SIP/SDP messages,

[authentication]

[managers-phones](!)
type=friend
context=main-context
secret=123
host=dynamic
qualify=yes
nat=route
canreinvite=no
callgroup=1
pickupgroup=1
dtmfmode=auto
disallow=all
allow=alaw
allow=ulaw
allow=g729
allow=g723
allow=g722

Here is log SIP log of such call

https://paste.ee/p/Xqvky

RTP packets are sent only to my mobile phone and not back.

Sent RTP P2P packet to 37.73.222.249:49232 (type 08, len 000160)
Sent RTP P2P packet to 37.73.222.249:49232 (type 08, len 000160)
Sent RTP P2P packet to 37.73.222.249:49232 (type 08, len 000160)
Sent RTP P2P packet to 37.73.222.249:49232 (type 08, len 000160)
Sent RTP P2P packet to 37.73.222.249:49232 (type 08, len 000160)
Sent RTP P2P packet to 37.73.222.249:49232 (type 08, len 000160)

Of course over VPN it works perfectly.

Please suggest what should I check or maybe I missed something.

Thanks in advance.

You have not configured the localnet setting so chan_sip will not know when it should put your external IP address in and when it shouldn’t. The following line is probably what you’d need:

localnet=192.168.0.0/255.255.255.0

1 Like

Its awesome !!! Thank you so much, only one line solved huge problem, now everything works like a charm !!!