# \[NAT Troubles\] - Two Asterisk PBXs behind the same public IP

**URL:** <https://community.asterisk.org/t/nat-troubles-two-asterisk-pbxs-behind-the-same-public-ip/43904>\
**Category:** Asterisk General\
**Created:** [September 13, 2013, 2:37pm UTC](https://community.asterisk.org/t/nat-troubles-two-asterisk-pbxs-behind-the-same-public-ip/43904 "2013-09-13T14:37:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [September 13, 2013, 2:37pm UTC](https://community.asterisk.org/t/nat-troubles-two-asterisk-pbxs-behind-the-same-public-ip/43904/1 "2013-09-13T14:37:27Z")

</div>

Hi everybody,  
I need your help to undersand how can I solve what, in my opinion, is a NAT problem.  
This is my configuration:

VoIP Provider \<–\> Asterisk 11.5.x + A2Billing server \<–\> PBX A + PBX B (each one Asterisk 1.8.x)

I can act without problems everywhere except on VoIP provider systems (I’ve to ask what I need and they say me if it’s possible or not…)  
PBX A and PBX B are on the same network behind the same firewall and the same router + public IP (I’ve only one public IP so I had to NAT my PBXs).

THE PROBLEM: I’ve a SIP trunk open from the PBX A to the A2Billing server for a geographical number A and another trunk open (obviusly with different credentials) from the PBX B to the A2Billing server for a geographical number B. When I call number A from a cell phone, the call arrive to PBX A. When I call number B from a cell phone, the call still arrive to PBX A! And obviusly, here I don’t have an inbound route for that number… so the call fail and I ear ss-noservice audio file.

If I launch netstat-nat -n on my firewall I see:

`udp 192.168.1.7:5060 theIPofA2BillingServer:5060 ASSURED  
udp 192.168.1.9:5060 theIPofA2BillingServer:5060 ASSURED `

Some configurations… Some of my A2Billing VoIP settings are:

qualify=yes  
type=friend  
host=dynamic  
nat=comedia  
canreinvite=yes

Some of my PBX config :

type=peer  
trustrpid=yes  
sendrpid=yes  
qualify=yes  
port=5060  
nat=yes  
maxexpirey=3600  
insecure=invite,port  
canreinvite=yes

In my firewall iptables I have:

-A PREROUTING -i eth0 -p udp -m multiport --dports 5060:5070 -j DNAT --to-destination 192.168.1.9  
-A PREROUTING -i eth0 -p udp -m multiport --dports 10000:20000 -j DNAT --to-destination 192.168.1.9  
-A FORWARD -d 192.168.1.9/32 -i eth0 -o eth1 -j fwd\_wanlan\_pbx  
-A fwd\_wanlan\_pbx -p udp -m multiport --dports 5060:5070 -j ACCEPT  
-A fwd\_wanlan\_pbx -p udp -m multiport --dports 10000:20000 -j ACCEPT

where 192.168.1.9 is PBX A. Do you think I need some modify for PBX B (192.168.1.7)?  
How do you think I can solve this problem? Thank you so much!

---

<div class="post-metadata">

**Author:** ![abw1oim](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@abw1oim](https://community.asterisk.org/u/abw1oim)\
**Post date:** [September 17, 2013, 4:45pm UTC](https://community.asterisk.org/t/nat-troubles-two-asterisk-pbxs-behind-the-same-public-ip/43904/2 "2013-09-17T16:45:11Z")

</div>

You need to distinct the signalling (SIP) as well as the RTP ports used ny the Asterisk-servers behind the same IP-Adress.  
Your firewall actully delivers all SIP/RTP-traffic to server A.  
to avoid this, change server B e.g to bindport 5062 and set up the rtp-range in Server A to start 10000  
and stop 15000 as well as on server B from 15001 to 20000.  
Afterwards Your firewall config may look like

```auto
-A PREROUTING -i eth0 -p udp -m multiport --dports 5060:5061 -j DNAT --to-destination 192.168.1.9
-A PREROUTING -i eth0 -p udp -m multiport --dports 10000:15000 -j DNAT --to-destination 192.168.1.9
-A FORWARD -d 192.168.1.9/32 -i eth0 -o eth1 -j fwd_wanlan_pbx
-A PREROUTING -i eth0 -p udp -m multiport --dports 5062:5063 -j DNAT --to-destination 192.168.1.7
-A PREROUTING -i eth0 -p udp -m multiport --dports 15001:20000 -j DNAT --to-destination 192.168.1.7
-A FORWARD -d 192.168.1.7/32 -i eth0 -o eth1 -j fwd_wanlan_pbx
-A fwd_wanlan_pbx -p udp -m multiport --dports 5060:5063 -j ACCEPT
-A fwd_wanlan_pbx -p udp -m multiport --dports 10000:20000 -j ACCEPT
```
