-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
... | ||
|
||
#!KAMAILIO | ||
# | ||
# sample config file for dispatcher module | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Kamailio as Load balancer | ||
|
||
Uses dipatch module with dbtext to stateless proxy sip traffic to sip servers | ||
Use dbtext to stpres destinations | ||
|
||
Read More on employing kamailio as SIP call Load balancer here : | ||
https://telecom.altanai.com/2014/11/12/telephony-solutions-with-kamailio/ | ||
|
||
> Among other features it offers load balancing with many distribution algorithms and failover support , | ||
>flexible least cost routing , routing failover and replication for High Availability (HA). | ||
## security against DOS ( denial of service ) attacks | ||
|
||
sample pike module in action | ||
``` | ||
INFO: <script>: REGISTER from sip:[email protected] (IP:10.20.20.20:44133) | ||
REGISTER from sip:[email protected] (IP:10.10.10.10:5060) | ||
REGISTER from sip:[email protected] (IP:10.10.10.10:5060) | ||
REGISTER from sip:[email protected] (IP:10.10.10.10:5060) | ||
REGISTER from sip:[email protected] (IP:10.10.10.10:5060) | ||
REGISTER from sip:[email protected] (IP:10.10.10.10:5060) | ||
REGISTER from sip:[email protected] (IP:10.10.10.10:5060) | ||
REGISTER from sip:[email protected] (IP:10.10.10.10:5060) | ||
WARNING: pike [pike_funcs.c:151]: pike_check_req(): PIKE - BLOCKing ip 10.10.10.10, node=0x7f7e073f7dd0 | ||
ALERT: pike blocking REGISTER from sip:[email protected] (IP:10.10.10.10:5060) | ||
REGISTER from sip:[email protected] (IP:10.20.20.20:44133) | ||
REGISTER from sip:[email protected] (IP:10.20.20.20:44133) | ||
``` | ||
unlcoking | ||
``` | ||
pike [pike_funcs.c:278]: refresh_node(): PIKE - UNBLOCKing node 0x7f7e073f7dd0 | ||
REGISTER from sip:[email protected] (IP:10.20.20.20:44133) | ||
``` | ||
|
||
## checking traffic using ngrep | ||
``` | ||
> ngrep -W byline -d any port 5060 -q | ||
``` | ||
|
||
## Dispatcher | ||
|
||
|
||
Dispatcher module - https://www.kamailio.org/docs/modules/5.1.x/modules/dispatcher.html#dispatcher.f.ds_select_domain |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
#!KAMAILIO | ||
|
||
|
||
####### Defined Values ######### | ||
|
||
#!substdef "!MY_IP_ADDR!127.0.0.1!g" | ||
#!substdef "!MY_EXTERNAL_IP!172.16.19.237!g" | ||
#!substdef "!MY_UDP_PORT!5060!g" | ||
#!substdef "!MY_TCP_PORT!8080!g" | ||
#!substdef "!MY_UDP_ADDR!udp:MY_IP_ADDR:MY_UDP_PORT!g" | ||
#!substdef "!MY_TCP_ADDR!tcp:MY_IP_ADDR:MY_TCP_PORT!g" | ||
|
||
|
||
# Dispatcher File | ||
#!define DISPATCHER_FILE "/Users/altanaibisht/kamilioexamples/Lua_load_balancer/dispatcher.list" | ||
|
||
# Routing File | ||
#!define ROUTE_LUA "/Users/altanaibisht/kamilioexamples/Lua_load_balancer/loadbalancer.lua" | ||
|
||
#!define WITH_DBTEXT | ||
|
||
####### Global Parameters ######### | ||
|
||
## LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR | ||
#!ifdef WITH_DEBUG | ||
debug = 4 | ||
log_stderror = yes | ||
#!else | ||
debug = 2 | ||
log_stderror = no | ||
#!endif | ||
memdbg = 5 | ||
memlog = 5 | ||
|
||
# log setting | ||
log_facility = LOG_LOCAL0 | ||
|
||
#!ifdef WITH_DBTEXT | ||
# - database URL - used to connect to database server by dispatcher | ||
#!define DBURL "text:///Users/altanaibisht/kamilioexamples/dbtext" | ||
#!endif | ||
|
||
|
||
children = 4 | ||
async_workers=8 | ||
|
||
#listen = MY_UDP_ADDR advertise MY_EXTERNAL_IP:MY_UDP_PORT | ||
#listening for the xmlrpc | ||
listen = MY_UDP_ADDR | ||
listen = MY_TCP_ADDR | ||
|
||
server_header="Server: SampleServer" | ||
sip_warning=0 | ||
|
||
####### Modules Section ######## | ||
#!ifdef WITH_SRCPATH | ||
mpath = "modules/" | ||
#!else | ||
mpath = "/usr/local/lib64/kamailio/modules/" | ||
#!endif | ||
# ------------------ module loading ---------------------------------- | ||
loadmodule "tm.so" | ||
loadmodule "rr.so" | ||
loadmodule "pv.so" | ||
loadmodule "tmx.so" | ||
loadmodule "sl.so" | ||
loadmodule "maxfwd.so" | ||
loadmodule "nathelper.so" | ||
loadmodule "textops.so" | ||
loadmodule "siputils.so" | ||
loadmodule "xlog.so" | ||
loadmodule "sanity.so" | ||
loadmodule "path.so" | ||
loadmodule "xhttp.so" | ||
loadmodule "jsonrpcs.so" | ||
loadmodule "app_lua.so" | ||
loadmodule "dispatcher.so" | ||
loadmodule "json.so" | ||
loadmodule "cfg_rpc.so" | ||
loadmodule "xmlrpc.so" | ||
# loadmodule "ctl.so" | ||
loadmodule "dialog.so" | ||
loadmodule "db_text.so" | ||
loadmodule "textopsx.so" | ||
loadmodule "sdpops.so" | ||
# ----------------- setting module-specific parameters --------------- | ||
|
||
# ----- rr params ----- | ||
# set next param to 1 to add value to ;lr param (helps with some UAs) | ||
modparam("rr", "enable_full_lr", 0) | ||
# do not append from tag to the RR (no need for this script) | ||
modparam("rr", "append_fromtag", 1) | ||
|
||
# ----- dispatcher params ----- | ||
modparam("dispatcher", "list_file", DISPATCHER_FILE) | ||
modparam("dispatcher", "ds_probing_mode", 1) | ||
modparam("dispatcher", "flags", 2) | ||
modparam("dispatcher", "ds_ping_interval", 10) | ||
|
||
# ----- nathelper params ---- | ||
modparam("nathelper", "received_avp", "$avp(s:rcv)") | ||
|
||
# ----- ctl ------ | ||
# modparam("ctl", "binrpc", "tcp:MY_IP_ADDR:2046") | ||
|
||
# ----- app_lua params ---- | ||
modparam("app_lua", "reload", 1) | ||
modparam("app_lua", "load", ROUTE_LUA) | ||
|
||
# ---- dialog params ---- | ||
modparam("dialog", "enable_stats", 1) | ||
modparam("dialog", "dlg_flag", 4) | ||
modparam("dialog", "dlg_match_mode", 1) | ||
modparam("dialog", "event_callback", "ksr_dialog_event") | ||
|
||
# ----- tm params ----- | ||
# auto-discard branches from previous serial forking leg | ||
modparam("tm", "failure_reply_mode", 3) | ||
modparam("tm", "fr_timer", 10000) | ||
modparam("tm", "fr_inv_timer", 120000) | ||
modparam("tm", "restart_fr_on_each_reply", 1) | ||
modparam("tm", "pass_provisional_replies", 1) | ||
modparam("tm", "contacts_avp", "tm_contacts"); | ||
modparam("tm", "contact_flows_avp", "tm_contact_flows"); | ||
|
||
# ----- db_text module params ---- | ||
modparam("db_text", "db_mode", 1) | ||
|
||
# ----- xhttp module params ----- | ||
modparam("xhttp", "url_match", "^/XMLRPC") | ||
modparam("xhttp", "event_callback", "ksr_xhttp_event") | ||
|
||
|
||
cfgengine "lua" |