diff --git a/asterisk/asterisk.conf b/asterisk/asterisk.conf index 2723ac9..0542c93 100644 --- a/asterisk/asterisk.conf +++ b/asterisk/asterisk.conf @@ -1,3 +1,4 @@ +; ; /etc/asterisk/asterisk.conf [directories](!) diff --git a/asterisk/asterisk.service b/asterisk/asterisk.service index 6400d3e..e05cd96 100644 --- a/asterisk/asterisk.service +++ b/asterisk/asterisk.service @@ -1,3 +1,5 @@ +# /etc/systemd/system/asterisk.service + # "Borrowed" from https://g1fef.co.uk/asterisk-systemd-startup-script/ [Unit] diff --git a/asterisk/extensions.conf b/asterisk/extensions.conf new file mode 100644 index 0000000..aa53c34 --- /dev/null +++ b/asterisk/extensions.conf @@ -0,0 +1,79 @@ +; /etc/asterisk/extensions.conf + +; Remember, context names for each SIP account are specified in pjsip_wizard.conf. + +; First, some safeguards against abuse of the built-in contexts. +[default] +exten => _X.,1,Hangup(3) + +[globals] + +; trunk caller IDs. +TRUNK_ONE_CID = +442012345678 +TRUNK_TWO_CID = +442087456210 + +; Default queue +QUEUE_ONE = queue-one + +[subscribe] +exten => _X.,hint,PJSIP/${EXTEN} + +[from-trunk-one] +exten => _X.,1,Queue(${QUEUE_ONE},nr,,,50) +; same => n,Answer(500) +; same => n,Voicemail(${VOICEMAIL_BOX},su) + same => n,Hangup() + + +[outbound-one] +exten => _X.,1,Verbose(1, "OUTBOUND TRUNK ONE ${TRUNK_ONE_CID}") + same => n,Set(CALLERID(all)=${TRUNK_ONE_CID}) + same => n,Dial(PJSIP/${EXTEN}@trunk-one) + same => n,GotoIf($["${DIALSTATUS}"="CONGESTION"]?outbound-two,${EXTEN},1) + same => n,GotoIf($["${DIALSTATUS}"="CHANUNAVAIL"]?outbound-two,${EXTEN},1) + same => n,Hangup() + +[outbound-two] +exten => _X.,1,Verbose(1, "OUTBOUND TRUNK TWO ${TRUNK_TWO_CID}") + same => n,Set(CALLERID(all)=${TRUNK_TWO_CID}) + same => n,Dial(PJSIP/${EXTEN}@trunk-two) + same => n,GotoIf($["${DIALSTATUS}"="CONGESTION"]?default,${EXTEN},1) + same => n,GotoIf($["${DIALSTATUS}"="CHANUNAVAIL"]?default,${EXTEN},1) + same => n,Hangup() + +[app-lastcallreturn] +exten => 1471,1,Wait(1) + same => n,Answer(1) + same => n,Playback(last-num-to-call) + same => n,Set(number=${DB(lastcaller/${CALLERID(num)})}) + same => n,GotoIf($["${number}" = ""]?s-nonum,1) + same => n,SayDigits(${number}) + same => n,Wait(2) + same => n,SayDigits(${number}) + same => n,Wait(1) + same => n,Playback(to-call-num-press) + same => n,Playback(digits/1) + +exten => 1,1,Goto(outbound-one,${number},1) + +exten => s-nonum,1,Playback(unidentified-no-callback) + same => n,Hangup() + + +[from-ext] +exten => 123,1,goto(default,${EXTEN},1) + same => n,Hangup() + +exten => 1471,1,Goto(app-lastcallreturn,${EXTEN},1) + same => n,Hangup() + +exten => _X.,1,Dial(PJSIP/outbound-one/${EXTEN}) + same => n,GotoIf($["${DIALSTATUS}"="CONGESTION"]?outbound-two,${EXTEN},1) + same => n,GotoIf($["${DIALSTATUS}"="CHANUNAVAIL"]?outbound-two,${EXTEN},1) + same => n,Hangup() + +[to-ext] +exten => _X.,1,Set(DB(lastcaller/${ARG1})=${CALLERID(num)}) + same => n,Dial(PJSIP/${EXTEN}) + same => n,Hangup() + diff --git a/asterisk/logger.conf b/asterisk/logger.conf index a708f0f..5f8dcb4 100644 --- a/asterisk/logger.conf +++ b/asterisk/logger.conf @@ -1,3 +1,4 @@ +; ; /etc/asterisk/logger.conf ; ; Logging Configuration diff --git a/asterisk/modules.conf b/asterisk/modules.conf index 0a3b82f..76bc9c7 100644 --- a/asterisk/modules.conf +++ b/asterisk/modules.conf @@ -1,3 +1,4 @@ +; ; /etc/asterisk/modules.conf ; ; Asterisk configuration file diff --git a/asterisk/pjsip.conf b/asterisk/pjsip.conf new file mode 100644 index 0000000..0d795ee --- /dev/null +++ b/asterisk/pjsip.conf @@ -0,0 +1,27 @@ +; +; /etc/asterisk/pjsip.conf +; +; Modifed and "borrowed" (read: stolen) from https://www.sacredheartsc.com/blog/building-a-personal-voip-system/ + +; This template contains default settings for all transports. +[transport-defaults](!) +type = transport +bind = 0.0.0.0:15000 + +; For communication to any addresses within local_nets, Asterisk will not apply +; NAT-related workarounds. +local_net = 127.0.0.0/8 +local_net = 10.0.0.0/8 +local_net = 172.16.0.0/12 +local_net = 192.168.0.0/16 + +; If you have a public static IP for your Asterisk server, set it here. +;external_media_address = xxx.xxx.xxx.xxx +;external_signaling_address = xxx.xxx.xxx.xxx + +; The following UDP and TCP transports will inherit from the defaults. +[transport-udp](transport-defaults) +protocol = udp + +;[transport-tcp](transport-defaults) +;protocol = tcp diff --git a/asterisk/pjsip_wizard.conf b/asterisk/pjsip_wizard.conf new file mode 100644 index 0000000..f1ea9ab --- /dev/null +++ b/asterisk/pjsip_wizard.conf @@ -0,0 +1,56 @@ +; +; /etc/asterisk/pjsip_wizard.conf +; +; Modifed and "borrowed" (read: stolen) https://www.sacredheartsc.com/blog/building-a-personal-voip-system/ +; +; This template contains default settings for all SIP trunks. +[trunk-defaults](!) +type = wizard + +; Send media to the address and port on the incoming packet, regardless of what +; the SIP headers say (NAT workaround). +endpoint/rtp_symmetric = yes + +; Rewrite the SIP contact to the address and port of the request (NAT workaround). +endpoint/rewrite_contact = yes + +; Send the Remote-Party-ID SIP header. Some providers need this. +endpoint/send_rpid = yes + +; We use alaw mainly in Europe. +endpoint/allow = !all,alaw + +; Call encryption. +endpoint/media_encryption = no + +; Load trunks. +#tryinclude pjsip_wizard_trunk_one.conf +; + +; +; This template contains default settings for all local extensions. +[extension-defaults](!) +type = wizard + +; Require clients to register. +accepts_registrations = yes + +; Require clients to authenticate. +accepts_auth = yes + +; When simultaneous logins from the same account exceed max_contacts, disconnect +; the oldest session. +aor/remove_existing = yes + +; allow just alaw +endpoint/allow = !all,alaw + +; Context name for BLF/presence subscriptions. This can be any string of your +; choosing. +endpoint/subscribe_context = subscribe + +; Load user extensions. +#tryinclude pjsip_wizard_users.conf + + + diff --git a/asterisk/pjsip_wizard_trunk_one.conf b/asterisk/pjsip_wizard_trunk_one.conf new file mode 100644 index 0000000..3f430f9 --- /dev/null +++ b/asterisk/pjsip_wizard_trunk_one.conf @@ -0,0 +1,24 @@ +; +; /etc/asterisk/pjsip_wizard_trunk_one.conf +; +; For a local system to register as a trunk. +; +[trunk-one](trunk-defaults) +; Accept inbound auth for this trunk. +accepts_auth = yes + +; UDP transport please. +transport = transport-udp + +; What's the username? +inbound_auth/username = trunk-one + +; The Password? +inbound_auth/password = BedknobsArentSupposedToWorkThatWayUNLESSYOUREBRAVE + +; Choose a context name for incoming calls from this account. You'll use this +; name in your dialplan. +endpoint/context = from-trunk-one + +; Only one registration please. +aor/max_contacts = 1 diff --git a/asterisk/pjsip_wizard_trunk_two.conf b/asterisk/pjsip_wizard_trunk_two.conf new file mode 100644 index 0000000..85abd82 --- /dev/null +++ b/asterisk/pjsip_wizard_trunk_two.conf @@ -0,0 +1,34 @@ +; +; /etc/asterisk/pjsip_wizard_trunk_two.conf +; +; Modifed and "borrowed" (read: stolen) https://www.sacredheartsc.com/blog/building-a-personal-voip-system/ +; +[trunk-two](trunk-defaults) +; Require SIP authentication. +sends_auth = yes + +; Require SIP registration. +sends_registrations = yes + +; If registration fails, keep trying until x tries. +registration/max_retries = 1000 + +; Don't assume an authentication failure is permanent. +registration/auth_rejection_permanent = no + +; Perform a connectivity check every 30 seconds. +aor/qualify_frequency = 30 + +; UDP transport please. +transport = transport-udp + +; Hostname and port for your SIP provider. +remote_hosts = voiceless.aa.net.uk:5060 + +; Choose a context name for incoming calls from this account. You'll use this +; name in your dialplan. +endpoint/context = from-trunk-two + +; Your SIP provider will give you these credentials. +outbound_auth/username = +442012345678 +outbound_auth/password = NoIDontHaveAnyMONEY diff --git a/asterisk/pjsip_wizard_users.conf b/asterisk/pjsip_wizard_users.conf new file mode 100644 index 0000000..a269d73 --- /dev/null +++ b/asterisk/pjsip_wizard_users.conf @@ -0,0 +1,37 @@ +; /etc/asterisk/pjsip_wizard_users.conf +; +; Modifed and "borrowed" (read: stolen) https://www.sacredheartsc.com/blog/building-a-personal-voip-system/ +; +[1000](extension-defaults) +; Dialplan context name for calls originating from this account. +endpoint/context = from-ext + +; Voicemail address. +endpoint/mailboxes = 1000@default + +; Internal Caller ID string for this device. +endpoint/callerid = 1000 <1000> + +; Username for SIP account. By convention, this should be the extension number. +inbound_auth/username = 1000 + +; Password for SIP account (you can choose whatever password you like). +inbound_auth/password = IfYouTolerateThisThenYourChildrenWillBeNext! + +; Maximum number of simultaneous logins for this account. +aor/max_contacts = 1 + +; Check connectivity every 30 seconds. +aor/qualify_frequency = 30 + +; Set connectivity check timeout to 3 seconds. +aor/qualify_timeout = 3.0 + +; IMPORTANT! This setting determines whether the audio stream will be proxied +; through the Asterisk server. +; +; If this device is directly reachable by the internet (either by a publicly +; routable IP, or static port mappings on your router), choose YES. +; +; Otherwise, if this device is hidden behind NAT, choose NO. +endpoint/direct_media = no diff --git a/asterisk/queues.conf b/asterisk/queues.conf new file mode 100644 index 0000000..629e59c --- /dev/null +++ b/asterisk/queues.conf @@ -0,0 +1,49 @@ +; /etc/asterisk/queues.conf +; +; Global queue settings go in this section. +; +; Modifed and "borrowed" (read: stolen) https://www.sacredheartsc.com/blog/building-a-personal-voip-system/ +; +[general] +; Persist dynamic member lists in the astdb. +persistentmembers = yes + +; Some options for more intuitive queue behavior. +autofill = yes +monitor-type = MixMonitor +shared_lastcall = yes +log_membername_as_agent = yes + +;;;;;;;;;;;;;;;;;;; +; Queue Definitions +;;;;;;;;;;;;;;;;;;; + +; The first queue is for incoming calls to our lines. +[queue-one] +; For each incoming call, ring all members of the queue. +strategy = ringall + +; Max number of seconds a caller waits in the queue. +timeout = 90 + +; Don't announce estimated hold time, etc. +announce-frequency = 0 +announce-holdtime = no +announce-position = no +periodic-announce-frequency = 0 + +; Allow ringing even when no queue members are present. +joinempty = yes +leavewhenempty = no + +; Ring member phones even when they are on another call. +ringinuse = yes + +; Queue Members +; +; Each member is specified with the following format: +; member => INTERFACE,PENALTY,FRIENDLY_NAME,PRESENCE_INTERFACE +; +; The "penalty" value is not interesting for our use case. +; With PJSIP, the BLF/Presence interface is identical to the standard interface name. +member => to-ext/1000,0,1000,to-ext/1000 diff --git a/asterisk/res_stun_monitor.conf b/asterisk/res_stun_monitor.conf new file mode 100644 index 0000000..6ce21df --- /dev/null +++ b/asterisk/res_stun_monitor.conf @@ -0,0 +1,7 @@ +; +; /etc/asterisk/rtp.conf +; +[general] + +stunaddr = stun.aa.net.uk:3478 +stunrefresh = 30 diff --git a/asterisk/rtp.conf b/asterisk/rtp.conf new file mode 100644 index 0000000..07d4938 --- /dev/null +++ b/asterisk/rtp.conf @@ -0,0 +1,8 @@ +; +; /etc/asterisk/rtp.conf +; +; Modifed and "borrowed" (read: stolen) from https://www.sacredheartsc.com/blog/building-a-personal-voip-system/ +; +[general] +rtpstart=15010 +rtpend=15999 diff --git a/asterisk/voicemail.conf b/asterisk/voicemail.conf new file mode 100644 index 0000000..59abc8e --- /dev/null +++ b/asterisk/voicemail.conf @@ -0,0 +1,47 @@ +[general] +format = wav49|gsm|wav + +[zonemessages] +; Users may be located in different timezones, or may have different +; message announcements for their introductory message when they enter +; the voicemail system. Set the message and the timezone each user +; hears here. Set the user into one of these zones with the tz= attribute +; in the options field of the mailbox. Of course, language substitution +; still applies here so you may have several directory trees that have +; alternate language choices. +; +; Look in /usr/share/zoneinfo/ for names of timezones. +; Look at the manual page for strftime for a quick tutorial on how the +; variable substitution is done on the values below. +; +; Supported values: +; 'filename' filename of a soundfile (single ticks around the filename +; required) +; ${VAR} variable substitution +; A or a Day of week (Saturday, Sunday, ...) +; B or b or h Month name (January, February, ...) +; d or e numeric day of month (first, second, ..., thirty-first) +; Y Year +; I or l Hour, 12 hour clock +; H Hour, 24 hour clock (single digit hours preceded by "oh") +; k Hour, 24 hour clock (single digit hours NOT preceded by "oh") +; M Minute, with 00 pronounced as "o'clock" +; N Minute, with 00 pronounced as "hundred" (US military time) +; P or p AM or PM +; Q "today", "yesterday" or ABdY +; (*note: not standard strftime value) +; q "" (for today), "yesterday", weekday, or ABdY +; (*note: not standard strftime value) +; R 24 hour time, including minute +; +eastern=America/New_York|'vm-received' Q 'digits/at' IMp +central=America/Chicago|'vm-received' Q 'digits/at' IMp +central24=America/Chicago|'vm-received' q 'digits/at' H N 'hours' +military=Zulu|'vm-received' q 'digits/at' H N 'hours' 'phonetic/z_p' +european=Europe/Copenhagen|'vm-received' a d b 'digits/at' HM +uk=Europe/London|'vm-received' a d b 'digits/at' HM + +[default] +; Note: The rest of the system must reference mailboxes defined here as mailbox@default. + +1000 => 1000,Default Mailbox,,,,Tz=uk