How to setup Kamailio + RTPEngine to enable PSTN calling from Skype for Business/Lync. This configuration currently only supports SIP over TCP and unencrypted RTP. It is able to handle multiple domains from multiple mediation servers.
This setup is for Debian 9 Stretch.
This setup handles the green boxes in the diagram only.
All files needed to setup all components on Debian 9 Stretch.
git clone https://github.com/havfo/Skype-Kamailio-PSTN-gateway.git
cd Skype-Kamailio-PSTN-gateway
find . -type f -print0 | xargs -0 sed -i 's/XXXX-XXXX/PUT-FQDN-OF-YOUR-SIP-SERVER-HERE/g'
find . -type f -print0 | xargs -0 sed -i 's/XXX-XXX/PUT-IP-OF-YOUR-SIP-SERVER-HERE/g'
This will do the RTP handling.
The easiest way of installing is to get it from Sipwise repository:
echo 'deb http://deb.sipwise.com/spce/mr7.1.1/ stretch main' > /etc/apt/sources.list.d/sipwise.list
echo 'deb-src http://deb.sipwise.com/spce/mr7.1.1/ stretch main' >> /etc/apt/sources.list.d/sipwise.list
apt-get update
apt-get install -y --allow-unauthenticated ngcp-keyring
apt-get update
apt-get install -y ngcp-rtpengine
After you have successfully installed RTPEngine, copy the configuration from this repository.
cd Skype-Kamailio-PSTN-gateway
cp etc/default/ngcp-rtpengine-daemon /etc/default/
cp etc/rtpengine/rtpengine.conf /etc/rtpengine/
/etc/init.d/ngcp-rtpengine-daemon restart
RTPEngine handles the chain for itself, but make sure to not block the RTP-ports it is using. Take a look in iptables.sh for details, and apply it by doing the following. This will persist after reboot. You can run the iptables.sh script at any time after it is set up.
cd Skype-Kamailio-PSTN-gateway
chmod +x iptables.sh
cp etc/network/if-up.d/iptables /etc/network/if-up.d/
chmod +x /etc/network/if-up.d/iptables
touch /etc/iptables/firewall.conf
touch /etc/iptables/firewall6.conf
./iptables.sh
apt-get install kamailio kamailio-mysql-modules kamailio-tls-modules mysql-server
cd Skype-Kamailio-PSTN-gateway
cp etc/kamailio/* /etc/kamailio/
kamdbctl create
Select yes (Y) to all options.
/etc/init.d/kamailio restart
Insert the kamailio.sql
into mysql using something like:
mysql -u root -p < kamailio.sql
Take a look in kamailio.sql
for examples of numbers/domains/mediation servers/proxies.
To add a mediation server:
INSERT
the mediation server intoaddress
table withgrp
field set to something in the range 300 -> 399- Note: If you have a Skype for Business site/pool with several mediation servers, add them with the same
grp
field
- Note: If you have a Skype for Business site/pool with several mediation servers, add them with the same
INSERT
the number series belonging to the mediation server (pool/site) intocarrierroute
table withrewrite_host
set to the skype-sip-domain the number series belongs toINSERT
the mediation server intodispatcher
table withsetid
field set to same number chosen for thegrp
field in theaddress
tableINSERT
the SIP domain of the number series intodomain_lookup
table withgroupid
field set to same number chosen for thegrp
field in theaddress
table
By default, outbound calls from Skype for Business are dispatched to dispatcher group 200. Take a look in kamailio.sql
for examples on adding a proxy.
- Configure PSTN GW in topology builder using TCP and port 5065
- Configure trunk in Skype for Business/Lync Control Panel > Voice Routing > Trunk Configuration
- Change "Encryption support level:" to Disabled
- Change "Refer support:" to None
- Make sure "Enable media bypass" is unchecked
- Make sure "Centralized media processing" is checked
- Make sure "Enable RTP latching" is unchecked
- Make sure "Enable forward call history" is checked
- Make sure "Enable forward P-Asserted-Identity data" is checked
- Make sure "Enable outbound routing failover timer" is checked
- Configure voice route in Skype for Business/Lync Control Panel > Voice Routing > Voice Policy/Route/PSTN Usage
- The voice route supports all types of forwarding/delegation/park and so on
Call in/out to/from a Skype for Business user and make sure you use full E164 number format in your dial-plans.