OS : Free PBX
2.10
Requirement : I
have FreePBX running VOIP server and one of ISP has provided SIP
trunk. VOIP server has run without issue and incoming and outgoing
calls are working fine. SIP trunk doesn't have any static IP. But we
do have static IP with another ISP. And that link also plugged into
the VOIP server.
I need to
configure SIP phone to make calls through my VOIP server while they
are out of the network (Out side.)
There are several
steps that you must follow to do such configuration.
All
Signaling and Media ports should forwarded to Asterisk
UDP and TCP
5060 port
2. All
Signaling and Media ports should forwarded to Asterisk.
3. The
Extensions/Devices is setup to be NATed.
This
confugration should done only if both SIP server and client behind
the NAT.
In
order to accomplish the above we need to apply some configuration
information into FreePBX, some Asterisk configuration files and on
your firewall/router.
Internal/External
Network Information
You
must edit or create the file sip.conf
typically
found in your /etc/asterisk
directory
and make sure it is owned by asterisk. We will assume that you have
an internal network of 192.168.1.0/255.255.255.0 and that you have a
static IP address of 24.72.182.16. If you have a dynamic IP, see the
notes that follow. In this situation, you need to create or edit the
following entries in your sip.conf
file:
Nat=yes
externip=24.72.182.16
localnet=192.168.1.0/255.255.255.0
This
tells Asterisk what IP address range is internal vs. external so that
it can rewrite the SIP headers appropriately. If you have a dynamic
address instead of a static address then you need to modify the
above. You will need to have a domain name for the host, let’s
assume you are using dyndns.com’s free service and have chosen the
name mydomain.dyndns.org. Then yoursip.conf
file
would look like the following:
externhost=mydomain.dyndns.org
externrefresh=120
localnet=192.168.1.0/255.255.255.0
Nat=Yes
Where
externrefresh
tells
Asterisk to recheck the IP address every 120 seconds in this case.
You should adjust this higher or lower based on the frequency that
this changes.
Firewall/Router
Configuration
The
default installation of FreePBX is configured to use UDP port 5060 as
the SIP signaling port and UDP ports 10001-20000 as the RTP Media
ports. All these ports must be forwarded to your FreePBX System. How
to do this varies widely depending on the firewall or equipment that
you are using. It is commonly referred to as Port Forwarding or maybe
Destination NAT (DNAT). However it is referred, if we assume in this
example that your FreePBX system has an internal IP address of
192.168.1.100 then you will want:
Extension
Information
We
will assume you are using FreePBX in Extension mode but if you are
using Devices/Users the same applies on the Devices page. You need to
configure the extension with NAT enabled so that Asterisk knows this
device is NATed and can apply the SIP rewriting rules that you
previously configured in the sip.conf
file.
Navigate to the desired extension and scroll down to the Device
Options Section.
The
configuration option nat
must
be set to yes,
and you may want to set qualify
to
yes
as
well although not necessary.
With
these steps, when properly configured, your external device should be
able to communicate with your FreePBX server unless you have issues
on the remote end where the device is located because of badly
behaved Firewalls. The remote device should be configured to use your
external IP address or domain name as configured above in the
sip.conf
file.