Setting up a telephone handset

There are times, like with myself, that you are underneath the node, it is connected to a repeater, and you want to use it. Sure you can talk in reverse to the node, except those on the repeater cannot hear you.. Causing an issue that has happened quite often with the IRLP node and Mt Big Ben....

With some software changes, you can connect a SIP phone directly into the your node. This allows you to speak to the node as though you were an external user, without the desense.

Not only that, you can monitor your node at work, or anywhere around the world with the right port forwarding.

Creating a user(Edit)

A user has to be created to ensure that not just anybody can log into your SIP Phone port.

Create a file called users.conf:

nano /etc/asterisk/users.conf

and insert the following information into that file:

[VKNXXX]                                  ;Name
registersip = no
host = dynamic
type = peer
username = vknxxx                           ;Username
transfer = no
context = from-handset                      ;Context
cid_number = 0000
hasvoicemail = no
threewaycalling = no
hasdirectory = no
callwaiting = no
hasmanager = no
hasagent = no
hassip = yes                                ;has to be yes
hasiax = no
secret = password                           ;Your Password
nat = yes
canreinvite = no
dtmfmode = rfc2833
insecure = no
pickupgroup = 1
autoprov = yes
linenumber = 1
LINEKEYS = 1

SIP setup(Edit)

Next SIP configurations have to be made. The default port for SIP is 5060. Any port other than that port is recommended so you dont get any chinese hackers trying to make international phone calls through your node. (It happens.....)

nano /etc/asterisk/sip.conf

Add these lines. Noting I have used port 9798 here:

[general]
context=default			; Default context for incoming calls
allowoverlap=no			; Disable overlap dialing support. (Default is yes)
bindport=9798			; UDP Port to bind to (SIP standard port is 5060)
bindaddr=0.0.0.0		; IP address to bind to (0.0.0.0 binds to all)
srvlookup=yes			; Enable DNS SRV lookups on outbound calls
				; Note: Asterisk only uses the first host 
				; in SRV records
				; Disabling DNS SRV lookups disables the 
				; ability to place SIP calls based on domain 
				; names to some other SIP users on the Internet

The amount of rtp ports need to be limited as well, to save holes in your router.

nano /etc/asterisk/rtp.conf

add or change the file to look like this:

[general]
rtpstart=16384
rtpend=16388

Creating the route stanza's(Edit)

As you cannot Dial straight into your node from a SIP phone, a path and conversion needs to be created to allow it to happen. The VKLink channel will not accept SIP, and the SIP phone will not accept IAX.

Edit extensions:

nano /etc/asterisk/extensions.conf

Now noting the context in users.conf add these two sections into extensions.conf:

........
[dial-in]
exten = s,1,rpt,1999|SX
exten = s,n,Hangup()

[from-handset]                                       ;Context from users.conf
exten = 99,1,Dial(local/s@dial-in,,)
exten = 99,n,hangup()
......

So What happens here?

By picking up your SIP phone and dialing 99, Asterisk directs your phone call to the dial-in stanza, and converts the format for us. The dial-in stanza takes your audio and shoves it into the node..

The |SX on the back of the node number (1999), tells VKLink how to use drive the node with the phone. The X means no logging in, and the S means simple control from the phone. The phone cannot connect to any nodes, it listens and transmits to its own node.

Using it(Edit)

In this example, it works as follows:

  1. pick up the phone
  2. dial 99
  3. to transmit, press *
  4. to drop ptt, press #
  5. to disconnect the phone, hang up

Now this works when you are on the same network as the node with your sip phone. What about externally? here's the mods:

Using the SIP phone from another network(Edit)

To do this, another few changes need to happen to sip.conf:

nano /etc/asterisk/sip.conf

We need to add our external IP address, the internal network, and a NAT traversal. Add these lines to sip.conf

externip=XXX.XXX.XXX.XXX
localnet=192.168.1.0/255.255.255.0         ;your own network address
                                           ;in this case the node address is 192.168.1.161
nat = route

We also need to bash open holes in our router to work.....

As a minimum to work, you need, in our example anyway:

  • port 9798 TCP/UDP to the node internal IP; and
  • port 16384 UDP to the node internal IP

This varies on all routers, so you are on your own.

What if I dont have a static IP?(Edit)

Most of us aren't lucky enough to have a static IP address, so we can use the fqdn set up for the node list. A simple script has to be written. I have chosen /usr/sipup.sh as the script. so:

nano /usr/sipup.sh

In this file:

#!/bin/bash
extip=$(ping $1 -c 1 | grep PING | sed 's/).*//' | sed 's/.*(//')
eval "sed -i 's/externip=.*/externip=$extip/g'" /etc/asterisk/sip.conf
asterisk -rx "module reload"

What this does is extract the IP address from the PING command, shove that into the sip.conf file and reload asterisk to accept the change.

Save the file and change it to executable:

chmod +x /usr/sipup.sh

Now we need to insert it into the crontab to run periodically:

crontab -e

Down the bottom insert the following line, inserting your fqdn:

....
*/5 * * * * /usr/sipup.sh [fqdn] & > /dev/null

This will mean at most, you wont be able to connect for 5 minutes.

Sip Softphone(Edit)

Whilst I use a normal SIP house phone to access my node, you can do it with a SIP softphone. In Google Play, there is a nice little piece of open source software called CSip Simple. It is very simple.

  • load the sofware
  • add your username (this is the one in the square brackets, in our example above it is VKNXXX).
  • enter the IP address of your node, external IP address or fqdn followed by a colon and the sip port. In our example above, it would look like XXX.XXX.XXX.XXX:9798 OR my.domain.name:9798
  • enter the password (secret above); and
  • connect.

Again, use * to PTT and # to drop PTT.

Advanced Stuff | Main page

Menu

Article:

Search: