PSTN Node Access

From "PTTLink Wiki"
Revision as of 20:07, 17 July 2021 by Kg7qin (talk | contribs)
Jump to navigation Jump to search

The following configuration will allow you to dial into your AllStarLink/PTTLink node and use it like your own personal telephone portal.

Note: This is for personal node access only. For information on setting up a public autopatch on your node, refer to Setup Autopatch.

Prerequisites

  • A SIP provider to setup a trunk to
  • A provisioned telephone number (DID) with your provider that is passed over the trunk to your node
  • Forwarding of port 5060 from your cable modem/router to your AllStarLink/PTTLink node

It is recommended that you setup firewall rules to limit inbound connections on port 5060 to only your SIP provider. This will eliminate the SIP enumeration and other attacks that your ALlStarLink/PTTLink node will be subjected to.

SIP Providers

The following SIP providers have been used with this configuration.

Note: You will only need a single provider.

Configuration

Make the following changes to your AllStarLink/PTTLink node's configuration files.

sip.conf

Edit /etc/asterisk/sip.conf as follows:

Using TELNYX

Add a stanza to sip.conf similar to the following:

  [TELNYX]
  type=friend
  host=sip.telnyx.com
  disallow=all
  allow=ulaw
  insecure=private
  context=from-ptsn
  canreinvite=yes
  qualify=no
  username=USERNAME
  secret=SECRET
  nat=yes
  directtypdrtup=yes
  externalip=YOUR PUBLIC IP   ;useful if you have issues with SIP
  ;localhost=NETWORK/SUBNET         ;useful if you have issues with SIP

Using Leap

Add a stanza to sip.conf similar to the following:

  [LEAP]
  disallow=all
  allow=ulaw
  context=from-pstn
  type=friend
  insecure=invite
  dtmfmode=rfc2833
  username=USERNAME
  secret=PASSWORD
  host=FQDN OF YOUR LEAP TEL INSTANCE NAME
  fromdomain=MAKE THIS MATCH THE HOST LINE ABOVE
  canreinvite=yes
  nat=yes
  qualify=yes
  externip=YOUR PUBLIC IP
  localnet=YOUR NODE'S LOCAL NEWORK/SUBNET ; Format: 192.168.0.0/255.255.255.0

SIP registration

You will need to add a register line in the [general] section of your sip.conf file. This will allow your node to authenticate with your SIP provider and optionally use it for outbound calls.

Telnyx

register => <username>:<password>@sip.telnyx.com

Leap

register => <username>:<password>@<fqdn of leap instance>

extensions.conf

We use the context of from-pstn in both SIP providers examples above. You will need to add a dial plan stanza that matches the context calls come in on your SIP trunk.

DO NOT PUSH EXTERNAL PHONE CALLS TO YOU NODE'S DEFAULT STANZA!

This is a security concern as all calls coming in should be authenticated before they are passed to app_rpt.

You can change the greeting message and tones played to whatever you want.

We will use the node number of 2000 as the extension to dial to get node access. You will be greeted by a message to enter your password and if successful the call will then transfer over to your node.

  [from-pstn]
  exten => XXXXXXXXXX,1,Goto(s|1)  ; Replace XXXXXXXXXX with the full phone number passed from your provider (e.g., 2535551212)
  
  exten => s,1,Ringing()
  exten => s,n,Wait(3)
  exten => s,n,Answer()
  exten => s,n,Log(VERBOSE,Incoming call from ${CALLERID(all)})     ;Log the incoming call
  
  exten => s,n,GotoIf($["${CALLERID(num)}" = ""]?877)               ;Do some spam/telemarketer filtering
  exten => s,n,GotoIf($["${CALLERID(num):0:3}" = "877"]?877)
  exten => s,n,GotoIf($["${CALLERID(num):0:3}" = "800"]?877)
  exten => s,n,GotoIf($["${CALLERIDNAME:0:9}" = "Anonymous"]?877)
  exten => s,n,GotoIf($["${CALLERIDNAME:0:7}" = "Unknown"]?877)
  exten => s,n,GotoIf($["${CALLERIDNUM:0:7}" = "Private"]?877)
  exten => s,n,GotoIf($["${CALLERIDNAME:0:7}" = "Private"]?877)
  exten => s,n,GotoIf($["${CALLERIDNUM:0:10}" = "Restricted"]?877)
  exten => s,n,GotoIf($["${CALLERIDNUM:0:4}" = "PSTN"]?877)
  exten => s,n,Wait(2)
  
  exten => s,n,Background(thank-you-for-calling&privacy-please-stay-on-line-to-be-connected)
  exten => s,n,Background(or&if-u-know-ext-dial&otherwise&to-hang-up-2)
  exten => s,n,Background(press-star)
  exten => s,n,Wait(1)
  exten => s,n,Background()
  exten => s,n,Playtones(425/50,0/50)
  exten => s,n,Playtones(!914/276,!1371/276,!1777/380,0)
  exten => s,n,Wait(2)
  exten => s,n,WaitExten(20)  ; Wait for a keypress
  exten => s,n,Playback(goodbye)  ;Nothing received so hangup
  exten => s,n,Wait(2)
  exten => s,n,Hangup()
  
  ;Default of where calls will go if nothing is entered
  exten => 10,1,LOG(VERBOSE, Hanging up.)
  exten => 10,n,StopPlaytones
  exten => 10,n,Playback(goodbye)
  exten => 10,n,Wait(2)
  exten => 10,n,Hangup()
  
  exten => *,1,Playback(goodbye)
  exten => *,n,Wait(2)
  exten => *,n,Hangup()
  
  ;Drop calls with no caller ID, 800, or 877 
  exten => s,877,Congestion()
  exten => 877,1,Wait(1)
  exten => 877,n,Hangup()
  
  exten => i,1,Log(VERBOSE, Caller ${CALLERID(all)} dialed an invalid extension.  Hanging up...)
  exten => i,n,Congestion(15)
     
  exten => h,1,Log(VERBOSE, Caller ${CALLERID(all)} hung up.)
  exten => h,n,Hangup()
  
  exten => 2000,1,Log(VERBOSE, Caller ${CALLERID(all)} is attempting remote radio control....)
  exten => 2000,n,Authenticate(1234)   ; Change 1234 to a more secure password
  exten => 2000,n,Goto(pstn-radio-control|2000|1)

Now we add an additional stanza to the extensions.conf called pstn-radio-control. This stanza will take the phone call we passed to it and connect it to app_rpt.

  [pstn-radio-control]
  exten => 2000,1,Ringing
  exten => 2000,n,Wait(3)
  exten => 2000,n,Answer
  exten => 2000,n,Set(CALLERID(name)="CALLSIGN")  ; Change to your callsign
  exten => 2000,n,Playback(rpt/connected)
  exten => 2000,n,Playback(rpt/node)
  exten => 2000,n,Saydigits(${EXTEN})
  exten => 2000,n,Rpt(${EXTEN}|P|${CALLERID(name)})

Testing

  • Make sure your AllStarLink/PTTLink node is registered with your SIP provider.
  Node*CLI> sip show registry
  Host                            Username       Refresh State                Reg.Time                 
  sip.telnyx.com:5060             blahblah        105 Registered           Sat, 17 Jul 2021 12:35:43
  • Call the telephone number you have provisioned with your SIP provider and watch your AllStarLink/PTTLink node's console. If successful you will see output similar to:
   -- Executing [18005551212@from-pstn:1] Goto("SIP/LEAP-01aa5b48", "s|1") in new stack
   -- Goto (from-pstn,s,1)
   -- Executing [s@from-pstn:1] Ringing("SIP/LEAP-01aa5b48", "") in new stack
   -- Executing [s@from-pstn:2] Wait("SIP/LEAP-01aa5b48", "3") in new stack
   -- Executing [s@from-pstn:3] Answer("SIP/LEAP-01aa5b48", "") in new stack
   -- Executing [s@from-pstn:4] Log("SIP/LEAP-01aa5b48", "VERBOSE|Incoming call from "WIRELESS CALLER" <+18885551212>") in new stack
  • You will hear the greeting, be prompted to enter the extension you wish to call and hear some tones playing.
  • Enter your node number (you did change it from 2000 in the example right?) and your password when prompted.
  • If successful you will then be passed to app_rpt and hear the announcement saying you've connected to your node, your call sign as the other node connecting, and your node will now be ready to control using DTMF codes as if you were on a radio link.

References/External Links