[Asterisk-Users] Re: Asterisk behind NAT << How to do it.

Darren McIntosh dmcintosh at optushome.com.au
Fri Nov 28 16:23:22 MST 2003


> Message: 9
> From: Leif Madsen <leif at hacklocalhost.com>
> To: asterisk-users at lists.digium.com
> Organization: http://www.hacklocalhost.com
> Date: 27 Nov 2003 23:10:42 -0500
> Subject: [Asterisk-Users] Asterisk behind NAT << How to do it.
> Reply-To: asterisk-users at lists.digium.com
>
> Thanks to ww and his patch on bug #104, I have successfully implemented
> Asterisk behind NAT without using STUN or anything crazy.  It's quite
> straight forward.
>
> Until this gets tested enough and put into CVS, you will have to patch
> your chan_sip.c file to do this.  I'm sure within the next few days this
> will get put merged into CVS if no one finds any problems.
>
> I tried this on chan_sip.c version 1.249 (the version the patch was
> written for) and the latest as of today 1.258.  Both work great.
>
> Open ports 5060 and your RTP range (found in /etc/asterisk/rtp.conf).
> Default is 10000 -> 20000
>
> Forward ports 5060 and your RTP range to your internal Asterisk box.
>
> For your sip.conf, you need to add three lines:
>
> ; sip.conf snippet
> [general]
> port=5060                       ; make sure you have this line :)
> inside_net=192.168.1.100        ; this is the internal ip address of
> the                                ;
> asterisk server
> inside_mask=255.255.255.0       ; internal ip mask.  /24 as this example
> outside_addr=216.239.33.100     ; this can also be a FQDN! ie.
>                                 ; my.domain.com
> ; ... plus whatever else you have in your sip.conf
>
> Download the patch at:
> http://bugs.digium.com/file_download.php?file_id=430&type=bug
>
> Either update your Asterisk or verify you have at least version 1.249 of
> chan_sip.c:
>
> cd /usr/src/asterisk/channels/
> cvs status chan_sip.c
>
> ===================================================================
> File: chan_sip.c        Status: Locally Modified
>
>    Working revision:    1.258
>    Repository revision: 1.258
> /usr/cvsroot/asterisk/channels/chan_sip.c,v
>
> While in pwd /usr/src/asterisk/channels/
> patch -p0 < /path/to/patch
>
> Nothing should fail.
>
> cd /usr/src/asterisk/
> make
> cp /usr/src/asterisk/channels/chan_sip.so /usr/lib/asterisk/modules/
>
> Restart your Asterisk and try it.  If you want to call a NAT'd Asterisk
> box, my Free World Dialup number is 18924.  Currently online.
>
> -- 
> Leif Madsen <leif at hacklocalhost.com>
> http://www.hacklocalhost.com
>
I can confirm this works for my NAT'd setup as well. Just one comment though
that the inside_net variable is your internal subnet address not the
asterisk server address.

cheers,
darren




More information about the asterisk-users mailing list