Help! ;o)
I’m having a NAT issue I can’t figure out yet.
Problem: Asterisk is sending a private IP out with nat=yes, externip set, etc.
here’s what’s going out according to the provider’s tech support:
##################################################################
Here is the INVITE for your outbound call:
U 2008/12/17 19:34:15.804432 192.168.1.50:5060 -> 64.192.112.13:5060
INVITE sip:[email protected] SIP/2.0…Record-Route: <sip:1724328140
[email protected]:5060;nat=yes;ftag=as273420d1;lr=on>…Via: SIP/2.0/UDP 66.23
.129.253:5060;branch=z9hG4bK047f.baf7edc1.0…Via: SIP/2.0/UDP 192.168.1.20:
5060;received=207.255.135.207;branch=z9hG4bK607d6f23;rport=5060…From: "724
4194556" sip:[email protected];tag=as273420d1…To: <sip:17243281404@66.
23.129.253>…Contact: sip:[email protected]:5060…Call-ID: 566b21403
[email protected]…CSeq: 103 INVITE…User-Agent: Asteris
k PBX…Max-Forwards: 16…Date: Wed, 17 Dec 2008 19:34:15 GMT…Allow: INVITE
, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY…Supported: replaces.
.Content-Type: application/sdp…Content-Length: 284…Remote-Party-ID: <sip:
[email protected]>;party=calling;screen=no;privacy=off…v=0…o=roo
t 29255 29256 IN IP4 192.168.1.20…s=session…c=IN IP4 192.168.1.20…t=0 0.
.m=audio 15324 RTP/AVP 0 8 101…a=rtpmap:0 PCMU/8000…a=rtpmap:8 PCMA/8000.
.a=rtpmap:101 telephone-event/8000…a=fmtp:101 0-16…a=silenceSupp:off - -
-
-..a=ptime:20..a=sendrecv..a=direction:active..
Here is the 200 OK for your inbound call:
U 2008/12/17 19:33:15.699476 207.255.135.207:5060 -> 192.168.1.50:5060
SIP/2.0 200 OK…Via: SIP/2.0/UDP 66.23.129.253:5060;branch=z9hG4bK433f.d0e3
86b3.0;received=66.23.129.253…Via: SIP/2.0/UDP 63.214.44.25:5060;branch=z9
hG4bK47af1199;rport=5060…Record-Route: <sip:[email protected]:5060
;nat=yes;ftag=as478f7460;lr=on>…From: “Cell Phone PA” <sip:17243281404@6
3.214.44.25>;tag=as478f7460…To: sip:[email protected];tag=as0c51
7e36…Call-ID: [email protected]…CSeq: 102 INV
ITE…User-Agent: Asterisk PBX…Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, RE
FER, SUBSCRIBE, NOTIFY…Supported: replaces…Contact: <sip:17244194556@192.
168.1.20>…Content-Type: application/sdp…Content-Length: 240…v=0…o=roo
t 29255 29255 IN IP4 192.168.1.20…s=session…c=IN IP4 192.168.1.20…t=0 0.
.m=audio 19308 RTP/AVP 0 101…a=rtpmap:0 PCMU/8000…a=rtpmap:101 telephone-
event/8000…a=fmtp:101 0-16…a=silenceSupp:off - - - -…a=ptime:20…a=sendr
ecv…
In both cases, you are populating the PRIVATE IP of your Asterisk of 192.168.1.20 as the RTP connection address (c= string). This will ALWAYS result in audio problems, as this is an invalid IP address in the public internet space.
################################################################################
Quick rundown of network:
Cable modem from Atlantic Broadband hooked to linksys WRT54GS Firmware Version: 7.2.03
public ip is 207.255.135.207 rarely changes, and I have the domain rhammack.com registered with custom DNS at dyndns.org (paid service, not the free one)
and the router’s set to update the DNS record if it changes (hasn’t since I got the connection on Dec 1st)
3 computers with static ip’s
workstation [Minerva] running Kubuntu 8.04 workstation 192.168.1.10
Asterisk box [isis]running Ubuntu 8.10 server 192.168.1.20
Laptop in docking Station [rhammack_us] WinXP 192.168.1.30
variable # of computers connect via DHCP and get addresses from 100-150
Port Forwards on router are:
5060 to 5060 both 192.168.1.20 enabled
5091 to 5092 both 192.168.1.20 enabled
10000 to 20000 both 192.168.1.20 enabled
I also have 80,8080,25,22,6881 going to 192.168.1.10
extension softphones on any box in the private network register fine and ring on trunk calls, etc.
audio is fine extension to extension.
and if I shut down asterisk and just run a twinkle softphone on Minerva (192.168.1.10) with no changes to the router’s port forwarding, set to register direct to the sip trunk it works fine. Audio is good both ways, etc.
my sip.conf is:
root@ISIS:~# cat /etc/asterisk/sip.conf
;--------------------------------------------------------------------------------;
; Do NOT edit this file as it is auto-generated by FreePBX. All modifications to ;
; this file must be done via the web gui. There are alternative files to make ;
; custom modifications, details at: http://freepbx.org/configuration_files ;
;--------------------------------------------------------------------------------;
;
[general]
; These files will all be included in the [general] context
;
#include sip_general_additional.conf
;sip_general_custom.conf is the proper file location for placing any sip general
;options that you might need set. For example: enable and force the sip jitterbuffer.
;If these settings are desired they should be set the sip_general_custom.conf file.
;
; jbenable=yes
; jbforce=yes
;
;It is also the proper place to add the lines needed for sip nat’ing when going
;through a firewall. For nat’ing you’d need to add the following lines:
; nat=yes , externip= , localhost= , and optionally fromdomain= .
;
include sip_general_custom.conf
;sip_nat.conf is here for legacy support reasons and for those that upgrade
;from previous versions. If you have this file with lines in it please make
;sure they are not duplicated in sip_general_custom.conf, if so remove them
from sip_nat.conf as sip_general_custom.conf will have precedence.
;include sip_nat.conf
;sip_registrations_custom.conf is for any customizations you might need to do to
;the automatically generated registrations that FreePBX makes.
;
#include sip_registrations_custom.conf
#include sip_registrations.conf
; These files should all be expected to come after the [general] context
;
#include sip_custom.conf
#include sip_additional.conf
;sip_custom_post.conf If you have extra parameters that are needed for a
;extension to work to for example, those go here. So you have extension
;1000 defined in your system you start by creating a line 1000 in this
;file. Then on the next line add the extra parameter that is needed.
;When the sip.conf is loaded it will append your additions to the end of
;that extension.
;
#include sip_custom_post.conf
register=> [email protected]:removed for security:[email protected]
and sip_general_custom.conf is:
root@ISIS:~# cat /etc/asterisk/sip_general_custom.conf
externip=207.255.135.207
externhost = rhammack.com
localnet=192.168.1.0/255.255.255.0
nat=yes
externrefresh=15
[nexvortex.com]
username=oracle
user=phone
type=peer
secret=removed for security
nat=yes
insecure=very
host=66.23.129.253
authname=oracle
fromuser=7244194556
dtmfmode=rfc2833
dtmf=rfc2833
context=from-trunk
canreinvite=no
sip_nat.conf is empty.
The trunk is registering with the provider OK, although for some reason
[email protected]:removed for security:[email protected]
shows up to the provider as
[email protected]:removed for security:[email protected]
(the n in nexvortex is stripped) so I had to enter it in the freePBX trunk screen as
[email protected]:removed for security:[email protected]
and that works. not sure if it’s significant or not.
System details:
dedicated box with no hardware, only SIP Trunk and softphones
Linux ISIS 2.6.27-9-server #1 SMP Thu Nov 20 22:53:41 UTC 2008 i686 GNU/Linux
Ubuntu 8.10 \n \l
model name : Intel® Pentium® 4 CPU 2.80GHz
MemTotal: 1025224 kB
I first installed asterisk using adept manager, then purged it to do a manual install with freePBX
############### Long, boring bash history from asterisk / freePBX setup #############
So you can see exactly what I did, mistakes and all
wget http://mirror.freepbx.org/freepbx-2.5.1.tar.gz
aptitude install linux-headers-$(uname -r)
ln -s /usr/src/linux-headers-$(uname -r) /usr/src/linux-2.6
sudo groupadd asterisk
useradd -c “asterisk PBX” -d /var/lib/asterisk -g asterisk asterisk
mkdir /var/run/asterisk
chown asterisk:asterisk /var/run/asterisk/
/usr/src/
cd /usr/src/
wget http://downloads.digium.com/pub/asterisk/releases/asterisk-1.4.22.tar.gz
tar -zxvf asterisk-1.4.22.tar.gz
cd asterisk-1.4.22
make clean
make
./configure –with-curl
./configure --with-curl
[was getting some errors due to missing perl modules]
aptitude install cvs build-essential automake autoconf bison flex libtool libncurses5-dev libssl-dev php5 php5-cli php5-curl php5-gd php5-mysql mysql-server php-pear php-db curl sox apache2 subversion libssl-dev libmysqlclient15-dev libcurl4-gnutls-dev
make clean
./configure --with-curl [worked this time]
make
make install
make samples
cd …
wget http://downloads.digium.com/pub/asterisk/asterisk-addons-1.4.7.tar.gz
tar -zxvf asterisk-addons-1.4.7.tar.gz
cd asterisk-addons-1.4.7
sudo perl -p -i.bak -e ’s/CFLAGS.*D_GNU_SOURCE/CFLAGS+=-D_GNU_SOURCE\nCFLAGS+=-DMYSQL_LOGUNIQUEID/’ Makefile
sudo perl -p -i.bak -e ’s/CFLAGS.*D_GNU_SOURCE/CFLAGS+=-D_GNU_SOURCE\nCFLAGS+=-DMYSQL_LOGUNIQUEID/’ Makefile
[The backticks were the problem]
sudo perl -p -i.bak -e ‘s/CFLAGS.*D_GNU_SOURCE/CFLAGS+=-D_GNU_SOURCE\nCFLAGS+=-DMYSQL_LOGUNIQUEID/’ Makefile
./configure
make clean
make
make install
cd …
mkdir asterisk-sounds
cd asterisk-sounds/
wget http://downloads.digium.com/pub/telephony/sounds/asterisk-core-sounds-en-wav-current.tar.gz
wget http://downloads.digium.com/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz
wget http://downloads.digium.com/pub/telephony/sounds/asterisk-moh-freeplay-wav.tar.gz
tar -zxvf asterisk-core-sounds-en-wav-current.tar.gz
tar -zxvf asterisk-extra-sounds-en-wav-current.tar.gz
tar -zxvf asterisk-moh-freeplay-wav.tar.gz
cp -rf * /var/lib/asterisk/sounds/
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
chown asterisk:asterisk /etc/asterisk -R
chown asterisk:asterisk /var/lib/asterisk -R
chown asterisk:asterisk /var/log/asterisk -R
chown asterisk:asterisk /var/spool/asterisk/ -R
nano /etc/asterisk/asterisk.conf
cd …
wget http://mirror.freepbx.org/freepbx-2.5.0.tar.gz
tar -zxvf freepbx-2.5.0.tar.gz
cd freepbx-2.5.0
mysql_install_db
mysqladmin u root password 'removed for security’
ysqladmin create asteriskcdrdb -p[OOPS! cut n paste is great, assuming you get everything!]
mysqladmin create asteriskcdrdb -p
mysql –user=root –password=removed for security asterisk < ./SQL/newinstall.sq
[was having some issues here - the instruction I was using were wrong, and the asterisk db hadn’t been created]
ls -lh
ls -lh sql
ls -lh ./sql
ls -lh ./SQL
mysql –user=root –password=removed for security asterisk < ./SQL/newinstall.sql
mysql –user=root –password=removed for security asterisk < ./SQL/cdr_mysql_table.sql
pwd
mysql –user=root –password=removed for security asterisk < ./SQL/newinstall.sql
mysql --user=root --password=removed for security asterisk < ./SQL/newinstall.sql
mysqladmin create asteriskcdrdb -p
mysql --user=root --password=removed for security asteriskcdrdb < ./SQL/newinstall.sql
mysql --user=root --password=removed for security asteriskcdrdb < ./SQL/cdr_mysql_table.sql
mysql –user root -p
mysql --user root -p
nano /etc/apache/envvars
aptitude install apache2
nano -w /etc/apache2/sites-enabled/000-default
nano /etc/php5/apache2/php.ini
nano /etc/php5/cli/php.ini
chown asterisk:asterisk /var/lib/php5 -R
chown asterisk:asterisk /var/www -R
nano /etc/apache/envvars
nano /etc/apache2/envvars [set apache to run as asterisk]
/etc/init.d/apache2 restart
cd /usr/src/freepbx-2.5.0
sudo ln -sf /bin/bash /bin/sh
./start_asterisk start
./install_amp
./install_amp --username=root --pasword=removed for security
./install_amp --username=root --password=removed for security
./install_amp --username=root --password=removed for security
./install_amp --username=root --password=‘removed for security’
./install_amp --username=root --password='removed for security’
nano -w ./install_amp
mysql --user=asteriskuser --password=amp109
nano -w ./install_amp
./install_amp
nano -w ./install_amp
./install_amp --debug
./install_amp --debug --username=asteriskuser --password=amp109
mysql --user=asteriskuser --password=amp109
ls -lh
nano -w ./SQL/newinstall.sql
nano -w ./SQL/cdr_mysql_table.sql
mysqladmin create asterisk -p
[ DUH! no asterisk db - finally fixed]
mysql --user=asteriskuser --password=amp109
mysql --user=root --password=removed for security asterisk < ./SQL/newinstall.sql
[sql import ran fine now]
./install_amp --debug [had a problem with php not running]
a2enmod php5
nano -w /var/www/info.php
/etc/init.d/apache2 restart [php still not running]
nano -w /etc/mime.types [here I corrected a php problem - the php mimetypes were commented out]
/etc/init.d/apache2 restart [php running now]
nano /etc/init.d/asterisk
[contents of init.d/asterisk ]
root@ISIS:~# cat /etc/init.d/asterisk
#! /bin/sh
asterisk start the asterisk PBX
© Mark Purcell [email protected]
© Tzafrir Cohen [email protected]
© Faidon Liambotis [email protected]
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Based on:
skeleton example file to build /etc/init.d/ scripts.
This file should be used to construct scripts for /etc/init.d.
Written by Miquel van Smoorenburg [email protected].
Modified for Debian GNU/Linux
by Ian Murdock [email protected].
Version: @(#)skeleton 1.9 26-Feb-2001 [email protected]
BEGIN INIT INFO
Provides: asterisk
Required-Start: $local_fs zaptel
Required-Stop: $local_fs
Should-Start:
Should-Stop:
Default-Start: 2 3 4 5
Default-Stop: 0 1 6
Short-Description: Asterisk PBX
Description: Controls the Asterisk PBX
END INIT INFO
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Asterisk"
NAME=amportal
DAEMON=/usr/local/sbin/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
test -x $DAEMON || exit 0
d_start() {
amportal start
}
d_stop() {
amportal stop
}
d_reload() {
amportal restart
}
case “$1” in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo “.”
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo “.”
;;
restart|force-reload)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 10
d_start
echo “.”
;;
*)
echo “Usage: $SCRIPTNAME {start|stop|restart|force-reload}” >&2
exit 3
;;
esac
exit 0
[end contents]
chmod 775 /etc/init.d/asterisk
update-rc.d asterisk defaults 90 10
rm /etc/asterisk/*.0
shutdown -r now
[rebooted]