diff --git a/README.md b/README.md index a00c892..aa81a22 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,59 @@ # asterisk +## Installing Dependencies +Before installing Asterisk, you need to update your package lists and install the necessary dependencies. Open your terminal and execute the following commands: + +`sudo apt update` +`sudo apt upgrade` +`sudo apt install -y wget build-essential subversion` + +## Downloading and Installing Asterisk +With the dependencies in place, you can now download and compile Asterisk: + +`cd /usr/src` +`sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz` +`sudo tar xvf asterisk-18-current.tar.gz` + +Change into the extracted directory and install additional required packages: + +`cd asterisk-18*` +`sudo contrib/scripts/install_prereq install` + +Now, proceed to compile and install Asterisk: + +`sudo ./configure` +`sudo make menuselect` +`sudo make` +`sudo make install` +`sudo make samples` +`sudo make config` +`sudo ldconfig` + +With Asterisk installed, you can now set up its user and group permissions: + +`sudo adduser --system --group --no-create-home asterisk` +`sudo chown -R asterisk:asterisk /etc/asterisk` +`sudo chown -R asterisk:asterisk /var/{lib,log,spool}/asterisk` +`sudo chown -R asterisk:asterisk /usr/lib/asterisk` + +## Configuring Asterisk +Editing the main configuration file is the next step. Open it using your favorite text editor: + +`sudo nano /etc/asterisk/asterisk.conf` + +Make the necessary changes according to your setup, then start and enable Asterisk at boot: + +`sudo systemctl start asterisk` +`sudo systemctl enable asterisk` + +Ensure that Asterisk is running without issues: + +`sudo asterisk -vvvr` + +## Setting Up SIP Accounts +To handle VoIP calls, you need to set up SIP accounts. Edit the sip.conf and extensions.conf files: + +`sudo nano /etc/asterisk/sip.conf` +`sudo nano /etc/asterisk/extensions.conf` + +Add your SIP users in sip.conf and dial plan in extensions.conf. diff --git a/extensions.conf b/extensions.conf new file mode 100644 index 0000000..9aa4df6 --- /dev/null +++ b/extensions.conf @@ -0,0 +1,24 @@ +[general] +static=yes +writeprotect=no + +[from-trunk] +; (888)88-MOENY +exten => 18888866369,1,Answer() + same => n,Wait(0.5) + same => n,agi(googletts.agi,"Thank you for calling Moeny! No AI is available to speak right now. I'm just a Google Goog-let. But call back soon and you'll be chatting with AI so good you think it's a real person! Bye for now!",en) + same => n,Hangup() + +; (559)TALK-2-AI +exten => 15598255224,1,Goto(s,1) + +exten => s,1,Answer() +same => n,Wait(0.5) +same => n,Playback(hello-world&and&goodbye) +same => n,Wait(0.5) +;same => n,Dial(PJSIP/101) +same => n,Hangup() + +[from-internal] +exten => 1234,1,Goto(from-trunk,s,1) +exten => 5678,1,Goto(from-trunk,18888866369,1) diff --git a/pjsip.conf b/pjsip.conf new file mode 100644 index 0000000..f5fbbd6 --- /dev/null +++ b/pjsip.conf @@ -0,0 +1,55 @@ +[transport-udp] +type=transport +protocol=udp +bind=0.0.0.0:5062 + +[acl] +type=acl +deny=0.0.0.0/0 +permit=100.40.223.130/32 +permit=52.204.242.197/32 + +[101] +type=endpoint +transport=transport-udp +context=from-internal +disallow=all +allow=ulaw +auth=101 +aors=101 +direct_media=no +rtp_symmetric=yes +force_rport=yes +rewrite_contact=yes ; Necessary if endpoint does not know/register public ip:port +ice_support=yes ; This is specific to clients that support NAT traversal + ; for media via ICE,STUN,TURN. See the wiki at: + ; https://docs.asterisk.org/Configuration/Miscellaneous/Interactive-Connectivity-Establishment-ICE-in-Asterisk/ + ; for a deeper explanation of this topic. + +[101] +type=auth +auth_type=userpass +password=x9k2m5v7h3p8q4n1w6y0z9j4l8s3d7 +username=101 + +[101] +type=aor +max_contacts=10 + +[trunk-mtg01] +type=endpoint +transport=transport-udp +context=from-trunk +disallow=all +allow=ulaw +aors=trunk-mtg01-aor +direct_media=no + +[trunk-mtg01-aor] +type=aor +max_contacts=1 + +[trunk-mtg01-identify] +type=identify +endpoint=trunk-mtg01 +match=52.204.242.197