Linux, windows, asterisk, vmware

When trying to connect an external sip client to my home Asterisk (Trixbox) after setting up the extension with nat=yes and qualify=yes I could connect and register to the machine, you can check this by using ‘sip show peers‘ from the asterisk CLI

To resolve this issue, I manually edited the sip_nat.conf file, below is my configuration.

nat=yes
externhost=XXXXXXX.dyndns.org
localnet=192.168.1.0/255.255.255.0
externrefresh=120

If you have a static ip, you can use externip=xxx.xxx.x.xx instead of externhost

Also, in my sip.conf file I have the following.

bindport=5060 ; UDP Port to bind to
bindaddr=0.0.0.0 ; (0.0.0.0 binds to all)
rtpstart=10000
rtpend=20000

You can edit these files via the config editor built into trixbox, or from an SSH terminal using Putty with the easy to use nano text editor

You may also need to point the following ports to your asterisk / trixbox from your router

SIP port: 5060
RTP Ports: 10000 – 20000

Popularity: 13% [?]


Tags: , , ,

I had alot of trouble trying to find updated information in regards to Asterisk configuration when connecting to iiNet, i’m using Naked DSL with iiNet, the package comes with a free voip service *claps*

Here is my trunk configuration for asterisk.

Sip Trunk

Outbound Caller ID:07XXXXXXXX (Your iiNet number)

Outgoing Settings

Trunk Name: iiNetOut

Peer Details:

disallow=all
allow=alaw&ulaw
canreinvite=no
context=from-trunk
fromdomain=iinetphone.iinet.net.au
fromuser=07XXXXXXXX (Your iiNet number)
host=203.55.228.194
insecure=very
dtmfmode=auto
nat=no
pedantic=no
secret=XXXXXXX (Your iiNet voip password)
type=friend
registersip=yes
username=07XXXXXXXX (Your iiNet number)

Incoming Settings

User Context: iiNetin

User Details:

canreinvite=no
context=from-trunk
fromuser=07XXXXXXXX (Your iiNet number)
host=203.55.228.194
insecure=very
secret=XXXXXXX (Your iiNet voip password)
type=friend
username=07XXXXXXXX (Your iiNet number)
qualify=yes
nat=no

Registration String:

07XXXXXXXX@iinetphone.iinet.net.au:voippassword:07XXXXXXXX@iiNetOut/07XXXXXXXX

Popularity: 12% [?]


Tags: , ,

Nokia, has very limited information and support in regards to the sip client, asterisk and nokia phones ‘took hours’ to figure out!

So, here is a working configuration, tested with Nokia 6100 Navigator and Nokia N95

Got into the Menu -> settings -> Phone Settings – > Connection -> SIP settings

Profile Name: Your desired profile name
Service Profile: IETF
Default Access Point: Your service provider access point, in my case ‘Planet 3
Public user name: sip:206@domain.com

Public username is in the format ’sip:ext@ip/domain’ ext is the extension setup on your asterisk server, the IP is the public IP of your asterisk server, if you do not have a static IP, use dyndns.org service.

Use Compression: No
Registration: When needed

You can set this to ‘Always On‘ if you want your sip client ready when you are

Use security: No

Proxy server

Proxy server address: sip:domain/ip
Realm: asterisk
Username: ext ‘Asterisk extention’
Password: pass ‘Asterisk extentsion password’
Allow loose routing: No
Transport type: UDP
Port: 5060


Registrar server

Registrar server address: sip:ip/domain
Realm: ip/domain
Username: ext ‘Asterisk extention’
Password: pass ‘Asterisk extentsion password’
Transport type: UDP
Port: 5060

Have fun :-) Hopefully everything will register for you with those settings, you will need to have the appropriate ports in your router and your sip_nat.conf and sip.conf configuration corrected as  outlined in the bottom of my previous post Trixbox – External sip clients, no audio

Popularity: 10% [?]


Tags: , , ,

After having further issues with using externhost=yourdomain.dyndns.org in my sip_nat.conf file I decided to use the dynamic IP address and have trixbox update the sip_nat.conf file automatically using a bash script coupled with a cron job.

Your sip clients can still connect with the Dynamic DNS name without any troubles as long as the externip= is the valid public IP.

Please refer to my previous post Trixbox – External sip clients, no audio for additional information on how to setup your external sip clients.

The process is as follows.

1. Create a bash script
2. Update crontab to include an hourly update check against the IP
3. Sit back and relax :-)

Log into your trixbox via SSH, once logged in issue the command: nano /root/update_dyndns.sh

Paste the below contents into your new file, you should only need to change the following two values

localnet=
mask=

#interogates whatismyip.org to determine the outside IP of the
#!/bin/bash
# Interogates whatismyip.org to determine the outside IP of the
# machine and checks it against what it was at the last check.
# Then it creates a sip_nat.conf file, moves it to the proper
# directory and performs a sip reload.

# set some variables
localnet=”192.168.1.0″ #change this number to your local network subnet
mask=”255.255.255.0″ #change this to your subnet mask
nat=”yes” #Set the nat parameter if you like. If set to no
#this line will not be included in the final file

# change to a working directory. Make sure this directory exists
cd /root/

rm -f index.html # Remove the last file

wget whatismyip.org

read newaddy < “index.html”

read oldaddy < “oldindex.html”

if [ $newaddy != $oldaddy ]
then
mv index.html oldindex.html
echo “externip=$newaddy” > sip_nat.conf
echo “localnet=$localnet/$mask” >> sip_nat.conf

if [ $nat == "yes" ]
then
echo “nat=$nat” >> sip_nat.conf
fi

chmod 775 sip_nat.conf
chown asterisk:asterisk sip_nat.conf
cp sip_nat.conf /etc/asterisk/sip_nat.conf
asterisk -rx “sip reload”
fi

#THE LAST THING IN YOUR NEW FILE SHOULD BE fi DO NOT PASTE ANYTHING ELSE BELOW.

The above script was taken and modified from an unknown website, if it’s yours! thanks and let me know so I can link back to you.

Once you have pasted the above contents into the new file, save the file ctrl+x then enter y then press enter.

The first time you run the script it will fail with errors, here is the work around.

1. run the script, command: /root/update_dyndns.sh

This will create an index.html file in the /root/ dir.

2. command: mv /root/index.html /root/oldindex.html
3. command: nano /root/oldindex.html

Edit one of the numbers where you see the IP address, this will force the script to notice the change and update your sip_nat.conf file for the first time!

4. command: /root/update_dyndns.sh

You should see the following output.

[trixbox1.localdomain ~]# /root/update_dyndns.sh

–16:57:50–  http://whatismyip.org/
Resolving whatismyip.org… 75.147.234.41
Connecting to whatismyip.org|75.147.234.41|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: unspecified [text/plain]
Saving to: `index.html’

[ <=>                                                                                                                  ] 13          –.-K/s   in 0s

16:57:51 (147 KB/s) – `index.html’ saved [13]
[trixbox1.localdomain ~]#

If you have followed the above steps correctly, looking at your /etc/asterisk/sip_nat.conf file should look like this..

[trixbox1.localdomain ~]# less /etc/asterisk/sip_nat.conf

externip=203.xx.xx.xx
localnet=192.168.1.0/255.255.255.0
nat=yes

Now comes the question? I don’t want to run this script each time I feel like updating the IP address, you want this to happen automatically, this is where the magic of cron jobs come into play *claps*, the basic concept is to run our script at a predefined time.

Using the website below, I created a cron task that runs, every day, every hour of every month of every year, you can use the website link below in order to customize this to suite your own needs.

58 * * * * /root/update_dyndns.sh > /dev/null

information taken from http://www.htmlbasix.com/crontab.shtml

  1. At the prompt, type in ‘crontab -e‘. This will open up your crontab file, or create a new one if it doesn’t exist.
    When this file opens, you will see other cron jobs listed in here, or if you haven’t any – you’ll see a bunch of lines with ‘~’ on them.
  2. Use the cursor to go down until you can’t move the cursor down any more. This is where you start your new line. Press ‘o‘ to insert a new line.
  3. Press ‘o‘ to insert a new line. If you want to edit a line, press ‘i‘.
  4. Copy the code above, then right click into your SSH or telnet client to paste the above code in. This should all go in as a new line.
  5. Press the ‘esc‘ key to exit out of edit mode.
  6. To save the changes and exit, type the following in: ZZ
    If you want to exit without saving changes, type in: :q!

  7. Once you have exited, to view the new entry in your crontab file type crontab -l in at the prompt. This will list the contents of your crontab file.

That’s it! everything is now done :-)

Comments or questions welcome.

Download the Bash Script here!

Or use the following command from your terminal

wget http://blog.simplic8.com/wp-content/uploads/update_dyndns.sh

Popularity: 23% [?]


Tags: , ,

Powered by Wordpress
Theme © 2005 - 2009 FrederikM.de
BlueMod is a modification of the blueblog_DE Theme by Oliver Wunder

1,759 views