SlideShare une entreprise Scribd logo
1  sur  37
Télécharger pour lire hors ligne
Astricon 2020 Fred Posner
Scaling with Kamailio
Using Kamailio and Asterisk to
Create Secure and Scalable Solutions
Astricon 2020 Fred Posner
Kamawhat?
●
Kah-mah-illie-oh
●
Hawaiian Word
●
To communicate
Astricon 2020 Fred Posner
Who am I?
●
Fred Posner
●
qxork.com
●
@fredposner
●
Consultant
Astricon 2020 Fred Posner
Agenda
●
What is Kamailio?
●
What’s new in
Kamailio 5.4?
●
Common Deployment
Scenarios
●
Examples
Astricon 2020 Fred Posner
What is Kamailio?
Astricon 2020 Fred Posner
Astricon 2020 Fred Posner
What is Kamailio
●
SIP proxy server
●
SIP registrar server
●
SIP location server
●
SIP application server
●
SIP dispatcher server
●
SIP websocket server
Astricon 2020 Fred Posner
What isn’t Kamailio?
Astricon 2020 Fred Posner
Kamailio cannot be...
●
B2BUA
●
SIP Phone
●
Media server*
Astricon 2020 Fred Posner
Selected Benefits
●
Open Source
●
Longevity
●
Small Footprint
●
Interoperability
●
Fast
●
Modular
Astricon 2020 Fred Posner
Kamailio is Modular
Astricon 2020 Fred Posner
Selected Modules: HTABLE
●
Hash Table Module
●
Stored in shared
memory
●
Custom cache system
●
Replication via DMQ
Astricon 2020 Fred Posner
Selected Modules: KEMI
●
Python
●
LUA
●
JavaScript
●
Ruby
●
Squirrel
●
https://kamailio.org/docs/
tutorials/devel/kamailio-
kemi-framework/
●
Use other scripting
languages to write SIP
routing
Astricon 2020 Fred Posner
Selected Modules: DMQ
●
Distributed Message
Queue
●
Replicate data to
other Kamailio nodes
Astricon 2020 Fred Posner
Selected Modules: Dispatcher
●
SIP Load Balancer
●
Stateless, Lightweight
●
Various Algorithms
●
New: Latency based
dispatching
Astricon 2020 Fred Posner
What’s new in 5.4?
Astricon 2020 Fred Posner
New Modules: Kafka / DLGS
●
Produces and sends
messages to a Kafka
server
●
Tracks dialogs in
stateless mode
Astricon 2020 Fred Posner
New Modules: MQTT / SECSIPID
●
Bidirectional
publish/subscribe
communication to a
MQTT Broker
●
STIR and SHAKEN IETF
extensions for SIP
(RFC8224, RFC 8588)
Astricon 2020 Fred Posner
New in 5.4
●
New modules: 5
●
Updated modules: 70
●
KEMI optimizations
●
Core updates
●
And mucho, mucho mas
Astricon 2020 Fred Posner
Common Deployment Scenarios
Astricon 2020 Fred Posner
Simple Edge Router
Astricon 2020 Fred Posner
Bridge
Astricon 2020 Fred Posner
Bridge
Astricon 2020 Fred Posner
Dispatcher / Load Balancer
Astricon 2020 Fred Posner
Dispatcher / Load Balancer
Astricon 2020 Fred Posner
Astricon 2020 Fred Posner
Astricon 2020 Fred Posner
Astricon 2020 Fred Posner
Examples
Astricon 2020 Fred Posner
Blocking by User-Agent - $ua
if($ua =~ "friendly-scanner|sipcli|sipvicious|VaxSIPUserAgent") {
# silent drop for scanners - uncomment next line if want to reply
# sl_send_reply("200", "OK");
exit;
}
Astricon 2020 Fred Posner
Adding to HTABLE
if($sht(ipban=>$si)!=$null) {
# ip is already blocked
xdbg("request from blocked IP - $rm from $fu (IP:$si:$sp)n");
exit;
}
...
if($ua =~ "friendly-scanner|sipcli|sipvicious|VaxSIPUserAgent") {
$sht(ipban=>$si) = 1;
# silent drop for scanners - uncomment next line if want to reply
# sl_send_reply("200", "OK");
exit;
}
Astricon 2020 Fred Posner
Dispatching Requests
# Dispatch requests
route[DISPATCH] {
# round robin dispatching on gateways group '1'
if(!ds_select_dst("1", "4")) {
send_reply("404", "No destination");
exit;
}
xdbg("--- SCRIPT: going to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs))n");
t_on_failure("RTF_DISPATCH");
route(RELAY);
exit;
}
Astricon 2020 Fred Posner
Dispatching Requests
# Try next destionations in failure route
failure_route[RTF_DISPATCH] {
if (t_is_canceled()) {
exit;
}
# next DST - only for 500 or local timeout
if (t_check_status("500")
or (t_branch_timeout() and !t_branch_replied())) {
if(ds_next_dst()) {
xdbg("--- SCRIPT: retrying to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs))n");
t_on_failure("RTF_DISPATCH");
route(RELAY);
exit;
}
}
}
Astricon 2020 Fred Posner
Dispatching Requests
event_route[dispatcher:dst-down] {
xlog("L_ERR", "Destination down: $rm
$ru ($du)n");
http_client_query("$var(pagerduty)",
"$var(response)");
}
Astricon 2020 Fred Posner
Failure Routes FTW
●
Check for reply, CANCEL, status code
●
Can be set as needed
if (t_check_status("5[0-9][0-9]")){
# I do not like the 5xx responses,
# so I give another chance to "foobar.com",
# and I drop all the replies to make sure that
# they are not forwarded to the caller.
t_drop_replies();
rewritehostport("foobar.com");
append_branch();
t_relay();
}
Astricon 2020 Fred Posner
Fail / Reply / Branching / Serial
●
Status checks
●
CANCEL checks
●
Use your own logic to supply what to do
●
Great also for PSTN
Astricon 2020 Fred Posner
Thank You!
●
kamailio.org
●
Mail lists, IRC, Matrix
●
YouTube (kamailioworld)
●
@kamailio

Contenu connexe

Tendances

Tendances (20)

Kamailio :: A Quick Introduction
Kamailio :: A Quick IntroductionKamailio :: A Quick Introduction
Kamailio :: A Quick Introduction
 
Kamailio on Docker
Kamailio on DockerKamailio on Docker
Kamailio on Docker
 
Three Ways Kamailio Can Help Your FreeSWITCH Deployment
Three Ways Kamailio Can Help Your FreeSWITCH DeploymentThree Ways Kamailio Can Help Your FreeSWITCH Deployment
Three Ways Kamailio Can Help Your FreeSWITCH Deployment
 
Kamailio - API Based SIP Routing
Kamailio - API Based SIP RoutingKamailio - API Based SIP Routing
Kamailio - API Based SIP Routing
 
Aynchronous Processing in Kamailio Configuration File
Aynchronous Processing in Kamailio Configuration FileAynchronous Processing in Kamailio Configuration File
Aynchronous Processing in Kamailio Configuration File
 
Continuous Integration and Kamailio
Continuous Integration and KamailioContinuous Integration and Kamailio
Continuous Integration and Kamailio
 
Kamailio - Secure Communication
Kamailio - Secure CommunicationKamailio - Secure Communication
Kamailio - Secure Communication
 
Why is Kamailio so different? An introduction.
Why is Kamailio so different? An introduction.Why is Kamailio so different? An introduction.
Why is Kamailio so different? An introduction.
 
SIPREC RTPEngine Media Forking
SIPREC RTPEngine Media ForkingSIPREC RTPEngine Media Forking
SIPREC RTPEngine Media Forking
 
FreeSWITCH as a Kickass SBC
FreeSWITCH as a Kickass SBCFreeSWITCH as a Kickass SBC
FreeSWITCH as a Kickass SBC
 
Getting started with SIP Express Media Server SIP app server and SBC - workshop
Getting started with SIP Express Media Server SIP app server and SBC - workshopGetting started with SIP Express Media Server SIP app server and SBC - workshop
Getting started with SIP Express Media Server SIP app server and SBC - workshop
 
Sipwise rtpengine
Sipwise rtpengineSipwise rtpengine
Sipwise rtpengine
 
Astricon 10 (October 2013) - SIP over WebSocket on Kamailio
Astricon 10 (October 2013) - SIP over WebSocket on KamailioAstricon 10 (October 2013) - SIP over WebSocket on Kamailio
Astricon 10 (October 2013) - SIP over WebSocket on Kamailio
 
Kamailio - Load Balancing Load Balancers
Kamailio - Load Balancing Load BalancersKamailio - Load Balancing Load Balancers
Kamailio - Load Balancing Load Balancers
 
Using ARI and AGI to Connect Asterisk Instances
Using ARI and AGI to Connect Asterisk Instances Using ARI and AGI to Connect Asterisk Instances
Using ARI and AGI to Connect Asterisk Instances
 
SIP Attack Handling (Kamailio World 2021)
SIP Attack Handling (Kamailio World 2021)SIP Attack Handling (Kamailio World 2021)
SIP Attack Handling (Kamailio World 2021)
 
Implementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in AsteriskImplementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in Asterisk
 
ARI and AGI, a powerful combination
ARI and AGI, a powerful combinationARI and AGI, a powerful combination
ARI and AGI, a powerful combination
 
Kamailio - Large Unified Communication Platforms
Kamailio - Large Unified Communication PlatformsKamailio - Large Unified Communication Platforms
Kamailio - Large Unified Communication Platforms
 
Kamalio and Asterisk: What, Why & How
Kamalio and Asterisk: What, Why & HowKamalio and Asterisk: What, Why & How
Kamalio and Asterisk: What, Why & How
 

Plus de Fred Posner

Plus de Fred Posner (7)

Security Asterisk or FreePBX with APIBAN
Security Asterisk or FreePBX with APIBANSecurity Asterisk or FreePBX with APIBAN
Security Asterisk or FreePBX with APIBAN
 
Protect Kamailio Against DoS Attacks With APIBan
Protect Kamailio Against DoS Attacks With APIBanProtect Kamailio Against DoS Attacks With APIBan
Protect Kamailio Against DoS Attacks With APIBan
 
Kamailio, FreeSWITCH, and the Half-Blood Prince
Kamailio, FreeSWITCH, and the Half-Blood PrinceKamailio, FreeSWITCH, and the Half-Blood Prince
Kamailio, FreeSWITCH, and the Half-Blood Prince
 
CommCon 2020: Kamailio for RTC Stability, Scaling, and Security
CommCon 2020: Kamailio for RTC Stability, Scaling, and SecurityCommCon 2020: Kamailio for RTC Stability, Scaling, and Security
CommCon 2020: Kamailio for RTC Stability, Scaling, and Security
 
Introduction to Kamailio (TADSummit 2020 Asia)
Introduction to Kamailio (TADSummit 2020 Asia)Introduction to Kamailio (TADSummit 2020 Asia)
Introduction to Kamailio (TADSummit 2020 Asia)
 
Three Ways Kamailio Can Help Your Asterisk Deployment
Three Ways Kamailio Can Help Your Asterisk DeploymentThree Ways Kamailio Can Help Your Asterisk Deployment
Three Ways Kamailio Can Help Your Asterisk Deployment
 
Advanced SIP: Communicating with Humans (Kamailio World 2019)
Advanced SIP: Communicating with Humans (Kamailio World 2019)Advanced SIP: Communicating with Humans (Kamailio World 2019)
Advanced SIP: Communicating with Humans (Kamailio World 2019)
 

Dernier

Dernier (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 

Scaling Asterisk with Kamailio

  • 1. Astricon 2020 Fred Posner Scaling with Kamailio Using Kamailio and Asterisk to Create Secure and Scalable Solutions
  • 2. Astricon 2020 Fred Posner Kamawhat? ● Kah-mah-illie-oh ● Hawaiian Word ● To communicate
  • 3. Astricon 2020 Fred Posner Who am I? ● Fred Posner ● qxork.com ● @fredposner ● Consultant
  • 4. Astricon 2020 Fred Posner Agenda ● What is Kamailio? ● What’s new in Kamailio 5.4? ● Common Deployment Scenarios ● Examples
  • 5. Astricon 2020 Fred Posner What is Kamailio?
  • 7. Astricon 2020 Fred Posner What is Kamailio ● SIP proxy server ● SIP registrar server ● SIP location server ● SIP application server ● SIP dispatcher server ● SIP websocket server
  • 8. Astricon 2020 Fred Posner What isn’t Kamailio?
  • 9. Astricon 2020 Fred Posner Kamailio cannot be... ● B2BUA ● SIP Phone ● Media server*
  • 10. Astricon 2020 Fred Posner Selected Benefits ● Open Source ● Longevity ● Small Footprint ● Interoperability ● Fast ● Modular
  • 11. Astricon 2020 Fred Posner Kamailio is Modular
  • 12. Astricon 2020 Fred Posner Selected Modules: HTABLE ● Hash Table Module ● Stored in shared memory ● Custom cache system ● Replication via DMQ
  • 13. Astricon 2020 Fred Posner Selected Modules: KEMI ● Python ● LUA ● JavaScript ● Ruby ● Squirrel ● https://kamailio.org/docs/ tutorials/devel/kamailio- kemi-framework/ ● Use other scripting languages to write SIP routing
  • 14. Astricon 2020 Fred Posner Selected Modules: DMQ ● Distributed Message Queue ● Replicate data to other Kamailio nodes
  • 15. Astricon 2020 Fred Posner Selected Modules: Dispatcher ● SIP Load Balancer ● Stateless, Lightweight ● Various Algorithms ● New: Latency based dispatching
  • 16. Astricon 2020 Fred Posner What’s new in 5.4?
  • 17. Astricon 2020 Fred Posner New Modules: Kafka / DLGS ● Produces and sends messages to a Kafka server ● Tracks dialogs in stateless mode
  • 18. Astricon 2020 Fred Posner New Modules: MQTT / SECSIPID ● Bidirectional publish/subscribe communication to a MQTT Broker ● STIR and SHAKEN IETF extensions for SIP (RFC8224, RFC 8588)
  • 19. Astricon 2020 Fred Posner New in 5.4 ● New modules: 5 ● Updated modules: 70 ● KEMI optimizations ● Core updates ● And mucho, mucho mas
  • 20. Astricon 2020 Fred Posner Common Deployment Scenarios
  • 21. Astricon 2020 Fred Posner Simple Edge Router
  • 22. Astricon 2020 Fred Posner Bridge
  • 23. Astricon 2020 Fred Posner Bridge
  • 24. Astricon 2020 Fred Posner Dispatcher / Load Balancer
  • 25. Astricon 2020 Fred Posner Dispatcher / Load Balancer
  • 29. Astricon 2020 Fred Posner Examples
  • 30. Astricon 2020 Fred Posner Blocking by User-Agent - $ua if($ua =~ "friendly-scanner|sipcli|sipvicious|VaxSIPUserAgent") { # silent drop for scanners - uncomment next line if want to reply # sl_send_reply("200", "OK"); exit; }
  • 31. Astricon 2020 Fred Posner Adding to HTABLE if($sht(ipban=>$si)!=$null) { # ip is already blocked xdbg("request from blocked IP - $rm from $fu (IP:$si:$sp)n"); exit; } ... if($ua =~ "friendly-scanner|sipcli|sipvicious|VaxSIPUserAgent") { $sht(ipban=>$si) = 1; # silent drop for scanners - uncomment next line if want to reply # sl_send_reply("200", "OK"); exit; }
  • 32. Astricon 2020 Fred Posner Dispatching Requests # Dispatch requests route[DISPATCH] { # round robin dispatching on gateways group '1' if(!ds_select_dst("1", "4")) { send_reply("404", "No destination"); exit; } xdbg("--- SCRIPT: going to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs))n"); t_on_failure("RTF_DISPATCH"); route(RELAY); exit; }
  • 33. Astricon 2020 Fred Posner Dispatching Requests # Try next destionations in failure route failure_route[RTF_DISPATCH] { if (t_is_canceled()) { exit; } # next DST - only for 500 or local timeout if (t_check_status("500") or (t_branch_timeout() and !t_branch_replied())) { if(ds_next_dst()) { xdbg("--- SCRIPT: retrying to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs))n"); t_on_failure("RTF_DISPATCH"); route(RELAY); exit; } } }
  • 34. Astricon 2020 Fred Posner Dispatching Requests event_route[dispatcher:dst-down] { xlog("L_ERR", "Destination down: $rm $ru ($du)n"); http_client_query("$var(pagerduty)", "$var(response)"); }
  • 35. Astricon 2020 Fred Posner Failure Routes FTW ● Check for reply, CANCEL, status code ● Can be set as needed if (t_check_status("5[0-9][0-9]")){ # I do not like the 5xx responses, # so I give another chance to "foobar.com", # and I drop all the replies to make sure that # they are not forwarded to the caller. t_drop_replies(); rewritehostport("foobar.com"); append_branch(); t_relay(); }
  • 36. Astricon 2020 Fred Posner Fail / Reply / Branching / Serial ● Status checks ● CANCEL checks ● Use your own logic to supply what to do ● Great also for PSTN
  • 37. Astricon 2020 Fred Posner Thank You! ● kamailio.org ● Mail lists, IRC, Matrix ● YouTube (kamailioworld) ● @kamailio