Asterisk

From NURDspace
Asterisk
Foon rookhok.jpg
Participants Flok
Skills
Status Active
Niche
Purpose
Tool No
Location Space
Cost
Tool category

Asterisk

Foon_rookhok.jpg {{#if:No | [[Tool Owner::{{{ProjectParticipants}}} | }} {{#if:No | [[Tool Cost::{{{Cost}}} | }}

general

  • ip address: 10.208.1.8
  • Erratic container: 109


Voip subscription

We have a VoIP subscription from budgetphone.nl. The number is: 0317-794512.

The account from budgetphone.nl can be accessed with username 'penningmeester@nurdspace.nl' and the usual password.

extensions

  • 9: main menu
    • 1 bar
    • 2 buzz
    • 3 rookhok
    • 4 zaal1
    • 5 studio
    • 6 gamers
    • 8 flok mobile
    • not making a choice will ring -all- extensions
  • 2222: Music
  • 2223: Music skip
  • 3010: Tahtkev (Softphone)
  • 3011: Tahtkev (Deskphone)
  • 4001: bar
  • 4222: rookhok
  • 4333: studio
  • 4346: Tahtkev (mifi)
  • 4455: zaal1
  • 4666: zaal3 (gamershok)
  • 4667: zaal2
  • 9999: party line (conference call)
  • 4200: buZz
  • 1990: boots
  • 4500: zarya
  • 4501: zarya lte cell (add local lte nr behind 4501)
    • 1210
    • 1211
    • 1212
    • 1216
  • 4300: niz
  • 6669: ????
  • 1234: ????
  • 2001: flunk
  • 4999: 'tester'
  • 4700: r3boot (deskphone)
  • 4701: r3boot (softphone)
  • 6002: ????
  • 9200: ????
  • 1515 Melan
  • 1111: flok
  • 1107: flok mobiel
  • 1109: flok's vaste lijn-via-omweg

configuring

  • /etc/asterisk
    • sip.conf
    • iax.conf
    • users.conf
    • extensions.conf (please keep ordering of extentions)

telefoons

MAC Address Extension Name Type
00:04:f2:6f:b1:fd 4001 Bar VVX410
00:04:f2:6f:be:7d 4666 Zaal3 VVX410
00:04:f2:6f:c2:18 4222 Rookhok VVX410
00:04:f2:6f:c8:d5 4667 Zaal2 VVX410
00:04:f2:81;9d:df 4455 Zaal1 VVX500


In extensions.conf you configure what happens when someone calls in or out. This is also the place where the /usr/local/bin/push-it.sh script is invoked when someone dials-in.

provisioning

All polycom phones are managed via DHCP and a http-based configuration provider. See the provisioning page for details.

Filename Description
<macaddress>.cfg Global configuration of phone (needed to let provisioning work)
<macaddress>-web.cfg All specific configuration wrt SIP and customization is set in this file
<macaddress>-phone.cfg All device related settings are set in this file.

phone management

The polycoms have a rest api available. Via this rest api, several automations have been written. To see documentation of this rest api, click here. To use these automations, run the /usr/local/bin/phones.sh script on the asterisk server. Run the script without any options to see what is possible:

Usage: phones.sh <list|deviceinfo|restart|reboot|configreset|factoryreset|lineinfo> [<filter>]

The script will discover managed phones via parsing of the /var/log/phones.log file to which all phones write their syslog output. By default, the tool will work on all phones which are on. To restrict the script to a specific phone, you can specify the macaddr, ipaddr or line name as a filter. Below you can find a couple of examples how to use this tool:

List all discovered phones (note, this does not imply that the phones are on):

root@asterisk:~# phones.sh list
0004f26fb1fd 10.208.42.236 Bar online
0004f26fbe7d 10.208.42.252 Zaal3 online
0004f26fc218 10.208.42.201 Rookhok online
0004f26fc8d5 10.208.43.179 Zaal2 online
0004f2819ddf 10.208.43.119 Zaal1 offline

Show information about a specific device. This also shows how to apply a label (as found in the list output) as a filter:

root@asterisk:~# phones.sh deviceinfo Rookhok
{
  "data": {
    "UpTime": {
      "Minutes": "57",
      "Seconds": "6",
      "Hours": "23",
      "Days": "0"
    },
    "DeviceType": "HardwareEndpoint",
    "IPStack": "IPv4 Only",
    "IntendToShutdown": "False",
    "IPAddress": "10.208.42.201",
    "AttachedHardware": {
      "EM": []
    },
    "DeviceVendor": "Polycom",
    "CanApplyShutdownRequest": "True",
    "Firmware": {
      "BootBlock": "3.0.4.0146 (46162-001)",
      "Application": "5.9.6.2996 30-Jan-21 15:28",
      "Updater": "5.9.7.42880"
    },
    "PreferredNetwork": "IPv6",
    "ModelNumber": "VVX 410",
    "IPv6Address": "::",
    "IPv6LinkAddress": "::",
    "IPv6ULAAddress": "::",
    "MACAddress": "0004f26fc218",
    "AppState": "AppStateCall",
    "ReadyToUse": "True"
  },
  "Status": "2000"
}

Show the current line config for a phone. This also shows how you can filter on macaddress:

root@asterisk:~# phones.sh lineinfo 0004f26fbe7d
{
  "data": [
    {
      "LineNumber": "1",
      "RegistrationStatus": "registered",
      "SIPAddress": "4666",
      "Port": "5060",
      "LineType": "private",
      "Label": "Zaal3",
      "Protocol": "SIP",
      "UserID": "Zaal3",
      "ProxyAddress": "10.208.1.8"
    }
  ],
  "Status": "2000"
}

Reset the configuration of a phone. This also shows how you can use the ip address as a filter:

root@asterisk:~# phones.sh configreset 10.208.42.201
{
  "Status": "2000"
}

MPD

audio_output {
	type 		"httpd"
	name 		"pcm wav Stream"
	encoder 	"wave"
	port 		"6666"
	format 		"8000:16:1"
}
  • musiconhold.conf
[default]
mode=custom
application=/usr/local/bin/stream.sh
format=pcm


allowing people from internet to connect to this asterisk instance

  • adjust sip.conf and extensions.conf
  • add their static ip-address to /etc/iptables/rules.v4

OR

  • let them connect via vpn

Then, create a sip account which can be used as a trunk. Add a stanza like below to sip.conf

[member_username]
type=peer
username=member_username
secret=PASSWORD_HERE
host=dynamic
canreinvite=no
insecure=invite,port
qualify=yes
context=users
trunk=yes
directmedia=no


Next, create the extension(s) you want in extensions.conf:

; When 4700 is dialed, forward the call to extension 100 running on the PBX of member_username
exten => 4700,1,Dial(SIP/member_username/100,90,rum)
exten => 4700,2,VoiceMail(member_username@default,u)
exten => 4700,3,Hangup()

Getting Access

It is possible to link your own PBX to the NURDspace PBX. This will make it possible that you can call extensions at NURDspace, and that people at nurdspace can contact you at home. To get this to work, you need to request a vpn tunnel together with a SIP account, and follow the documentation to install and configure your very own PBX.

member phones

We have a large stock of phones for people to use for voip purposes. You can pick one or more of these to hookup to your very own home PBX.

For space and personal use, we recommend:

  • ~Various Poly/Polycom VVX series phones
  • ~A handfull of Polycom CXX 300 phones (works perfect for if you only want a softphone but like the deskphone experience)
  • ~Some 48V adapters for the phones

We also have a huge stack of phones that need to be put on marktplaats

  • ~30 Aastra/Mitel 6865i gbit (~dozen complete kit inc psu)
  • ~100 Aastra/Mitel 6735i 100mbit
  • ~big box with handsets, cords and feet
  • ~dozen selection of various voip devices

extensions (27/03/2024)

[menu]
exten => s,1,Answer(500)
   same => n,Ringing()
; haal space-state op
   same => n,Set(RESULT=${SHELL(cat /tmp/open.state)})
; 1? dan open (== spring naar 'alletelefoons')
;    anders voicemail
   same => n,GotoIf($[${RESULT} == 1]?open:loop)
   same => n(loop),Background(nurdspace-welkom4)
   same => n,WaitExten(1)
   same => n,VoiceMail(4001@default,s)
   same => n,Hangup()
   same => n(open),Goto(alletelefoons,0,1)
   exten =>#,1,Goto(alletelefoons,0,1)

[alletelefoons]
; start huntgroup
   same => n,Dial(SIP/4455&SIP/4667&SIP/4666&SIP/4222&SIP/4001,30,ru)
; als niemand opneemt: voicemail
; wachtmuziek aan
   exten => 0,1,System(/usr/local/bin/mpd-play.sh)
   same => n,VoiceMail(4001@default,s)
   same => n,Hangup()

crontab:

*/1 * * * *     /usr/local/bin/check-space-open.sh

/usr/local/bin/check-space-open.sh:

/usr/bin/mosquitto_sub -h mqtt.vm.nurd.space -t space/statedigit -C 1 > /tmp/open.state