2
votes

I have an Asterisk box with a public IP address and two SIP clients behind the same NAT device; I also have SIP clients behind different NATs. I want to know is it possible for Asterisk to detect if both clients are behind the same NAT and use direct media between them and use other options for clients that are behind different NATs?

PS:I assumed each NAT box has a single external IP address, and this assumption is good for me.

4

4 Answers

2
votes

Asterisk 11.6 has this feature take a look at sip.conf.example and look for directmedia section.

1
votes

No, not posible.

Reason: most of modern routers have network 192.168.1.0/24, as result it will think almost ALL client in same net.

BUT you can force nat=never directmedia=yes for some clients. With that settings it will work directly, but will not work with server.

Optionaly you can put vpn(openvpn?) tunnel to your networks, add that to localnet= list and use direct routing without NAT.

0
votes

You can try set it to directmedia=nonat. That way it will only do that if the clients are not behind NAT. However I don't think it will work for your situation because you would also need the PBX behind the same NAT as the 2 clients which is useless.

0
votes

I have the same setup and it's working.

The configuration needed in Asterisk 1.8 is in sip.conf (or any other included file). I put in the [general] section:

[general]
directmediapermit=192.168.0.0/24 (local_network/netmask)
directmediadeny=0.0.0.0/0
...

And in the SIP devices definition, in this case, SIP phones:

[phones]
nat=no
directmedia=nonat
...