# Multiple SIP phones behind NAT to external asterisk

**URL:** <https://community.asterisk.org/t/multiple-sip-phones-behind-nat-to-external-asterisk/20421>\
**Category:** Asterisk Support\
**Created:** [April 17, 2008, 4:51pm UTC](https://community.asterisk.org/t/multiple-sip-phones-behind-nat-to-external-asterisk/20421 "2008-04-17T16:51:02Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmlco](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@pmlco](https://community.asterisk.org/u/pmlco)\
**Post date:** [April 17, 2008, 4:51pm UTC](https://community.asterisk.org/t/multiple-sip-phones-behind-nat-to-external-asterisk/20421/1 "2008-04-17T16:51:02Z")

</div>

As the title suggests, I am trying to use several SIP phones behind a NAT router to connect to asterisk on an external network, i.e. all the phones have the same external IP address. Individually, the phones work fine, I can make and receive calls. However, they can’t call each other, or rather they can, but there is no audio. On the asterisk side, I have set NAT=yes in sip.conf (I have tried other values, but it makes no difference) and I have set the phones to use different RTP port ranges. RTP debug output from asterisk suggests that asterisk is using the correct IP address, but only two RTP ports - I would have thought that four were necessary, two for each phone:

Got RTP packet from 99.145.91.37:13000 (type 00, seq 026986, ts 003840, len 000160)  
Sent RTP packet to 99.145.91.37:16422 (type 00, seq 001408, ts 003840, len 000160)  
Got RTP packet from 99.145.91.37:13000 (type 00, seq 026987, ts 004000, len 000160)  
Sent RTP packet to 99.145.91.37:16422 (type 00, seq 001409, ts 004000, len 000160)  
Got RTP packet from 99.145.91.37:16422 (type 00, seq 011237, ts 466542103, l en 000160)  
Sent RTP packet to 99.145.91.37:13000 (type 00, seq 058280, ts 466542096, l en 000160)

‘sip show peers’ for the two phones in question:  
60/60 99.145.91.37 D N 6060 OK (342 ms)  
41/41 99.145.91.37 D N 5060 OK (147 ms)

Any suggestions?  
Thanks,  
Ian.

---

<div class="post-metadata">

**Author:** ![Dovid](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@Dovid](https://community.asterisk.org/u/Dovid)\
**Post date:** [April 17, 2008, 8:16pm UTC](https://community.asterisk.org/t/multiple-sip-phones-behind-nat-to-external-asterisk/20421/2 "2008-04-17T20:16:49Z")

</div>

Check to see if you have externip set in sip.conf as well as see if you have set localnet ? Try putting this in under the general section of sip.conf

```auto

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
```

---

<div class="post-metadata">

**Author:** ![pmlco](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@pmlco](https://community.asterisk.org/u/pmlco)\
**Post date:** [April 18, 2008, 8:50pm UTC](https://community.asterisk.org/t/multiple-sip-phones-behind-nat-to-external-asterisk/20421/3 "2008-04-18T20:50:13Z")

</div>

I think it’s ok:

[general]  
context=phones  
bindport=5060  
bindaddr=0.0.0.0  
recordhistory=yes  
disallow=all ; disallow all codecs  
trustrpid=yes  
sendrpid=yes  
realm=asterisk  
localnet=192.168.1.0/255.255.255.0  
externip=xx.xx.xx.xx ; Florida IP  
externrefresh=15  
insecure=port,invite  
qualify=2500  
nat=yes  
subscribemwi=yes ; Maybe necessary for Siemens C470IP, may break other phones!  
checkmwi=60 ; seconds between checks for voicemail  
vmexten=500

---

<div class="post-metadata">

**Author:** ![mazilo](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@mazilo](https://community.asterisk.org/u/mazilo)\
**Post date:** [April 18, 2008, 9:44pm UTC](https://community.asterisk.org/t/multiple-sip-phones-behind-nat-to-external-asterisk/20421/4 "2008-04-18T21:44:50Z")

</div>

> [@pmlco](#):
>
> disallow=all ; disallow all codecs

You failed to specify CoDec(s) to use.

---

<div class="post-metadata">

**Author:** ![pmlco](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@pmlco](https://community.asterisk.org/u/pmlco)\
**Post date:** [April 18, 2008, 10:21pm UTC](https://community.asterisk.org/t/multiple-sip-phones-behind-nat-to-external-asterisk/20421/5 "2008-04-18T22:21:31Z")

</div>

I do this for each phone:

phonesets ;Defaults for all extention phones  
type=friend  
context=phones  
host=dynamic  
allow=ulaw  
allow=alaw  
subscribecontext=internal

---

<div class="post-metadata">

**Author:** ![mazilo](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@mazilo](https://community.asterisk.org/u/mazilo)\
**Post date:** [April 19, 2008, 1:34am UTC](https://community.asterisk.org/t/multiple-sip-phones-behind-nat-to-external-asterisk/20421/6 "2008-04-19T01:34:21Z")

</div>

> [@pmlco](#):
>
> As the title suggests, I am trying to use several SIP phones behind a NAT router to connect to asterisk on an external network, i.e. all the phones have the same external IP address.

What exactly did you mean by connect to asterisk on an external network?

---

<div class="post-metadata">

**Author:** ![pmlco](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@pmlco](https://community.asterisk.org/u/pmlco)\
**Post date:** [April 19, 2008, 11:15am UTC](https://community.asterisk.org/t/multiple-sip-phones-behind-nat-to-external-asterisk/20421/7 "2008-04-19T11:15:56Z")

</div>

Network F (Florida) has the asterisk machine. It’s behind a NAT router, but that does not seem to pose a problem since I can connect to it quite happily from Network C (Chicago), which is another NATed network, or for that matter from Network P (Paris). The problem is that two phones in network C or P cannot call each other via asterisk in F, at least with audio.

Thanks,  
Ian.

---

<div class="post-metadata">

**Author:** ![mazilo](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@mazilo](https://community.asterisk.org/u/mazilo)\
**Post date:** [April 19, 2008, 12:13pm UTC](https://community.asterisk.org/t/multiple-sip-phones-behind-nat-to-external-asterisk/20421/8 "2008-04-19T12:13:08Z")

</div>

OK. Now, I understand better.

[quote=“pmlco”]realm=asterisk  
localnet=192.168.1.0/255.255.255.0  
externip=xx.xx.xx.xx ; Florida IP[/quote]  
Shouldn’t the realm line contain your FQDN? Also, despite not being recommended for production environments, I prefer to use externhost over externip mainly because I can have my router automatically updated the FQDN of my new IP Address, instead of having me to keep changing the IP Address pointed to by externip. In your case, make sure your externip value matches with the external IP Address on net F. When you said On the asterisk side, I have set NAT=yes in sip.conf, did you mean you have specified each extension with NAT=yes?

---

<div class="post-metadata">

**Author:** ![pmlco](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@pmlco](https://community.asterisk.org/u/pmlco)\
**Post date:** [April 29, 2008, 12:44am UTC](https://community.asterisk.org/t/multiple-sip-phones-behind-nat-to-external-asterisk/20421/9 "2008-04-29T00:44:23Z")

</div>

I have set the realm to the FQDN, although this doesn’t seem to help. However, setting the infamous ‘canreinvite’ to ‘no’ does the trick.

Thanks for your suggestions,  
Ian.

---

<div class="post-metadata">

**Author:** ![Dovid](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@Dovid](https://community.asterisk.org/u/Dovid)\
**Post date:** [April 29, 2008, 10:18am UTC](https://community.asterisk.org/t/multiple-sip-phones-behind-nat-to-external-asterisk/20421/10 "2008-04-29T10:18:58Z")

</div>

Who is your ISP in FL ? I know that Bright House has lots of issues with VOIP in general.

---

<div class="post-metadata">

**Author:** ![pmlco](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@pmlco](https://community.asterisk.org/u/pmlco)\
**Post date:** [April 29, 2008, 12:11pm UTC](https://community.asterisk.org/t/multiple-sip-phones-behind-nat-to-external-asterisk/20421/11 "2008-04-29T12:11:19Z")

</div>

AT&T, formerly BellSouth
