Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!KAMAILIO
- #
- # Kamailio (OpenSER) SIP Server v5.1 - default configuration script
- # - web: https://www.kamailio.org
- # - git: https://github.com/kamailio/kamailio
- #
- # Direct your questions about this file to: <sr-users@lists.kamailio.org>
- #
- # Refer to the Core CookBook at https://www.kamailio.org/wiki/
- # for an explanation of possible statements, functions and parameters.
- #
- # Note: the comments can be:
- # - lines starting with #, but not the pre-processor directives,
- # which start with #!, like #!define, #!ifdef, #!endif, #!else, #!trydef,
- # #!subst, #!substdef, ...
- # - lines starting with //
- # - blocks enclosed in between /* */
- #
- # Several features can be enabled using '#!define WITH_FEATURE' directives:
- #
- # *** To run in debug mode:
- # - define WITH_DEBUG
- #
- # *** To enable mysql:
- # - define WITH_MYSQL
- #
- # *** To enable authentication execute:
- # - enable mysql
- # - define WITH_AUTH
- # - add users using 'kamctl'
- #
- # *** To enable IP authentication execute:
- # - enable mysql
- # - enable authentication
- # - define WITH_IPAUTH
- # - add IP addresses with group id '1' to 'address' table
- #
- # *** To enable persistent user location execute:
- # - enable mysql
- # - define WITH_USRLOCDB
- #
- # *** To enable presence server execute:
- # - enable mysql
- # - define WITH_PRESENCE
- #
- # *** To enable nat traversal execute:
- # - define WITH_NAT
- # - install RTPProxy: http://www.rtpproxy.org
- # - start RTPProxy:
- # rtpproxy -l _your_public_ip_ -s udp:localhost:7722
- # - option for NAT SIP OPTIONS keepalives: WITH_NATSIPPING
- #
- # *** To enable PSTN gateway routing execute:
- # - define WITH_PSTN
- # - set the value of pstn.gw_ip
- # - check route[PSTN] for regexp routing condition
- #
- # *** To enable database aliases lookup execute:
- # - enable mysql
- # - define WITH_ALIASDB
- #
- # *** To enable speed dial lookup execute:
- # - enable mysql
- # - define WITH_SPEEDDIAL
- #
- # *** To enable multi-domain support execute:
- # - enable mysql
- # - define WITH_MULTIDOMAIN
- #
- # *** To enable TLS support execute:
- # - adjust CFGDIR/tls.cfg as needed
- # - define WITH_TLS
- #
- # *** To enable XMLRPC support execute:
- # - define WITH_XMLRPC
- # - adjust route[XMLRPC] for access policy
- #
- # *** To enable anti-flood detection execute:
- # - adjust pike and htable=>ipban settings as needed (default is
- # block if more than 16 requests in 2 seconds and ban for 300 seconds)
- # - define WITH_ANTIFLOOD
- #
- # *** To block 3XX redirect replies execute:
- # - define WITH_BLOCK3XX
- #
- # *** To block 401 and 407 authentication replies execute:
- # - define WITH_BLOCK401407
- #
- # *** To enable VoiceMail routing execute:
- # - define WITH_VOICEMAIL
- # - set the value of voicemail.srv_ip
- # - adjust the value of voicemail.srv_port
- #
- # *** To enhance accounting execute:
- # - enable mysql
- # - define WITH_ACCDB
- # - add following columns to database
- #!ifdef ACCDB_COMMENT
- ALTER TABLE acc ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';
- ALTER TABLE acc ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';
- ALTER TABLE acc ADD COLUMN src_ip varchar(64) NOT NULL default '';
- ALTER TABLE acc ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';
- ALTER TABLE acc ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';
- ALTER TABLE acc ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
- ALTER TABLE missed_calls ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';
- ALTER TABLE missed_calls ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';
- ALTER TABLE missed_calls ADD COLUMN src_ip varchar(64) NOT NULL default '';
- ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';
- ALTER TABLE missed_calls ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';
- ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
- #!endif
- ####### Include Local Config If Exists #########
- import_file "kamailio-local.cfg"
- ####### Defined Values #########
- # *** Value defines - IDs used later in config
- #!ifdef WITH_MYSQL
- # - database URL - used to connect to database server by modules such
- # as: auth_db, acc, usrloc, a.s.o.
- #!ifndef DBURL
- #!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
- #!endif
- #!endif
- #!ifdef WITH_MULTIDOMAIN
- # - the value for 'use_domain' parameters
- #!define MULTIDOMAIN 1
- #!else
- #!define MULTIDOMAIN 0
- #!endif
- # - flags
- # FLT_ - per transaction (message) flags
- # FLB_ - per branch flags
- #!define FLT_ACC 1
- #!define FLT_ACCMISSED 2
- #!define FLT_ACCFAILED 3
- #!define FLT_NATS 5
- #!define FLB_NATB 6
- #!define FLB_NATSIPPING 7
- ####### 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_facility=LOG_LOCAL0
- log_prefix="{$mt $hdr(CSeq) $ci} "
- /* number of SIP routing processes */
- children=8
- /* uncomment the next line to disable TCP (default on) */
- # disable_tcp=yes
- /* uncomment the next line to disable the auto discovery of local aliases
- * based on reverse DNS on IPs (default on) */
- # auto_aliases=no
- /* add local domain aliases */
- # alias="sip.mydomain.com"
- /* uncomment and configure the following line if you want Kamailio to
- * bind on a specific interface/port/proto (default bind on all available) */
- # listen=udp:10.0.0.10:5060
- #!ifdef WITH_TLS
- enable_tls=yes
- #!endif
- /* life time of TCP connection when there is no traffic
- * - a bit higher than registration expires to cope with UA behind NAT */
- tcp_connection_lifetime=3605
- ####### Custom Parameters #########
- /* These parameters can be modified runtime via RPC interface
- * - see the documentation of 'cfg_rpc' module.
- *
- * Format: group.id = value 'desc' description
- * Access: $sel(cfg_get.group.id) or @cfg_get.group.id */
- #!ifdef WITH_PSTN
- /* PSTN GW Routing
- *
- * - pstn.gw_ip: valid IP or hostname as string value, example:
- * pstn.gw_ip = "10.0.0.101" desc "My PSTN GW Address"
- *
- * - by default is empty to avoid misrouting */
- pstn.gw_ip = "" desc "PSTN GW Address"
- pstn.gw_port = "" desc "PSTN GW Port"
- #!endif
- #!ifdef WITH_VOICEMAIL
- /* VoiceMail Routing on offline, busy or no answer
- *
- * - by default Voicemail server IP is empty to avoid misrouting */
- voicemail.srv_ip = "" desc "VoiceMail IP Address"
- voicemail.srv_port = "5060" desc "VoiceMail Port"
- #!endif
- ####### Modules Section ########
- /* set paths to location of modules */
- # mpath="/usr/lib/x86_64-linux-gnu/kamailio/modules/"
- #!ifdef WITH_MYSQL
- loadmodule "db_mysql.so"
- #!endif
- loadmodule "jsonrpcs.so"
- loadmodule "kex.so"
- loadmodule "corex.so"
- loadmodule "tm.so"
- loadmodule "tmx.so"
- loadmodule "sl.so"
- loadmodule "rr.so"
- loadmodule "pv.so"
- loadmodule "maxfwd.so"
- loadmodule "usrloc.so"
- loadmodule "registrar.so"
- loadmodule "textops.so"
- loadmodule "siputils.so"
- loadmodule "xlog.so"
- loadmodule "sanity.so"
- loadmodule "ctl.so"
- loadmodule "cfg_rpc.so"
- loadmodule "acc.so"
- loadmodule "counters.so"
- #!ifdef WITH_AUTH
- loadmodule "auth.so"
- loadmodule "auth_db.so"
- #!ifdef WITH_IPAUTH
- loadmodule "permissions.so"
- #!endif
- #!endif
- #!ifdef WITH_ALIASDB
- loadmodule "alias_db.so"
- #!endif
- #!ifdef WITH_SPEEDDIAL
- loadmodule "speeddial.so"
- #!endif
- #!ifdef WITH_MULTIDOMAIN
- loadmodule "domain.so"
- #!endif
- #!ifdef WITH_PRESENCE
- loadmodule "presence.so"
- loadmodule "presence_xml.so"
- #!endif
- #!ifdef WITH_NAT
- loadmodule "nathelper.so"
- loadmodule "rtpproxy.so"
- #!endif
- #!ifdef WITH_TLS
- loadmodule "tls.so"
- #!endif
- #!ifdef WITH_ANTIFLOOD
- loadmodule "htable.so"
- loadmodule "pike.so"
- #!endif
- #!ifdef WITH_XMLRPC
- loadmodule "xmlrpc.so"
- #!endif
- #!ifdef WITH_DEBUG
- loadmodule "debugger.so"
- #!endif
- # ----------------- setting module-specific parameters ---------------
- # ----- jsonrpcs params -----
- modparam("jsonrpcs", "pretty_format", 1)
- /* set the path to RPC fifo control file */
- # modparam("jsonrpcs", "fifo_name", "/var/run/kamailio/kamailio_rpc.fifo")
- /* set the path to RPC unix socket control file */
- # modparam("jsonrpcs", "dgram_socket", "/var/run/kamailio/kamailio_rpc.sock")
- # ----- ctl params -----
- /* set the path to RPC unix socket control file */
- # modparam("ctl", "binrpc", "unix:/var/run/kamailio/kamailio_ctl")
- # ----- tm params -----
- # auto-discard branches from previous serial forking leg
- modparam("tm", "failure_reply_mode", 3)
- # default retransmission timeout: 30sec
- modparam("tm", "fr_timer", 30000)
- # default invite retransmission timeout after 1xx: 120sec
- modparam("tm", "fr_inv_timer", 120000)
- # ----- 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", 0)
- # ----- registrar params -----
- modparam("registrar", "method_filtering", 1)
- /* uncomment the next line to disable parallel forking via location */
- # modparam("registrar", "append_branches", 0)
- /* uncomment the next line not to allow more than 10 contacts per AOR */
- # modparam("registrar", "max_contacts", 10)
- /* max value for expires of registrations */
- modparam("registrar", "max_expires", 3600)
- /* set it to 1 to enable GRUU */
- modparam("registrar", "gruu_enabled", 0)
- # ----- acc params -----
- /* what special events should be accounted ? */
- modparam("acc", "early_media", 0)
- modparam("acc", "report_ack", 0)
- modparam("acc", "report_cancels", 0)
- /* by default ww do not adjust the direct of the sequential requests.
- * if you enable this parameter, be sure the enable "append_fromtag"
- * in "rr" module */
- modparam("acc", "detect_direction", 0)
- /* account triggers (flags) */
- modparam("acc", "log_flag", FLT_ACC)
- modparam("acc", "log_missed_flag", FLT_ACCMISSED)
- modparam("acc", "log_extra",
- "src_user=$fU;src_domain=$fd;src_ip=$si;"
- "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
- modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
- /* enhanced DB accounting */
- #!ifdef WITH_ACCDB
- modparam("acc", "db_flag", FLT_ACC)
- modparam("acc", "db_missed_flag", FLT_ACCMISSED)
- modparam("acc", "db_url", DBURL)
- modparam("acc", "db_extra",
- "src_user=$fU;src_domain=$fd;src_ip=$si;"
- "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
- #!endif
- # ----- usrloc params -----
- /* enable DB persistency for location entries */
- #!ifdef WITH_USRLOCDB
- modparam("usrloc", "db_url", DBURL)
- modparam("usrloc", "db_mode", 2)
- modparam("usrloc", "use_domain", MULTIDOMAIN)
- #!endif
- # ----- auth_db params -----
- #!ifdef WITH_AUTH
- modparam("auth_db", "db_url", DBURL)
- modparam("auth_db", "calculate_ha1", yes)
- modparam("auth_db", "password_column", "password")
- modparam("auth_db", "load_credentials", "")
- modparam("auth_db", "use_domain", MULTIDOMAIN)
- # ----- permissions params -----
- #!ifdef WITH_IPAUTH
- modparam("permissions", "db_url", DBURL)
- modparam("permissions", "db_mode", 1)
- #!endif
- #!endif
- # ----- alias_db params -----
- #!ifdef WITH_ALIASDB
- modparam("alias_db", "db_url", DBURL)
- modparam("alias_db", "use_domain", MULTIDOMAIN)
- #!endif
- # ----- speeddial params -----
- #!ifdef WITH_SPEEDDIAL
- modparam("speeddial", "db_url", DBURL)
- modparam("speeddial", "use_domain", MULTIDOMAIN)
- #!endif
- # ----- domain params -----
- #!ifdef WITH_MULTIDOMAIN
- modparam("domain", "db_url", DBURL)
- /* register callback to match myself condition with domains list */
- modparam("domain", "register_myself", 1)
- #!endif
- #!ifdef WITH_PRESENCE
- # ----- presence params -----
- modparam("presence", "db_url", DBURL)
- # ----- presence_xml params -----
- modparam("presence_xml", "db_url", DBURL)
- modparam("presence_xml", "force_active", 1)
- #!endif
- #!ifdef WITH_NAT
- # ----- rtpproxy params -----
- modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")
- # ----- nathelper params -----
- modparam("nathelper", "natping_interval", 30)
- modparam("nathelper", "ping_nated_only", 1)
- modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
- modparam("nathelper", "sipping_from", "sip:pinger@kamailio.org")
- # params needed for NAT traversal in other modules
- modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
- modparam("usrloc", "nat_bflag", FLB_NATB)
- #!endif
- #!ifdef WITH_TLS
- # ----- tls params -----
- modparam("tls", "config", "/etc/kamailio/tls.cfg")
- #!endif
- #!ifdef WITH_ANTIFLOOD
- # ----- pike params -----
- modparam("pike", "sampling_time_unit", 2)
- modparam("pike", "reqs_density_per_unit", 16)
- modparam("pike", "remove_latency", 4)
- # ----- htable params -----
- /* ip ban htable with autoexpire after 5 minutes */
- modparam("htable", "htable", "ipban=>size=8;autoexpire=300;")
- #!endif
- #!ifdef WITH_XMLRPC
- # ----- xmlrpc params -----
- modparam("xmlrpc", "route", "XMLRPC");
- modparam("xmlrpc", "url_match", "^/RPC")
- #!endif
- #!ifdef WITH_DEBUG
- # ----- debugger params -----
- modparam("debugger", "cfgtrace", 1)
- modparam("debugger", "log_level_name", "exec")
- #!endif
- loadmodule "cdp.so"
- modparam("cdp", "config_file", "/etc/kamailio/diametercfg.xml")
- modparam("cdp", "debug_heavy", 1)
- loadmodule "cdp_avp.so"
- loadmodule "ims_diameter_server.so"
- ####### Routing Logic ########
- /* Main SIP request routing logic
- * - processing of any incoming SIP request starts with this route
- * - note: this is the same as route { ... } */
- request_route {
- xlog("Received request with method $rm");
- }
- event_route[diameter:request] {
- xlog("Got diameter message");
- xlog("Diamater Application Code: $diameter_application");
- xlog("Diameter Command Code: $diameter_command");
- xlog("Diameter Request $diameter_request");
- if(cdp_check_peer("ims-hss.localdomain")) {
- xlog("Peer ims-hss.localdomain is online - Checking capabilities");
- if(cdp_has_app($diameter_application)) {
- xlog("Has required app and can process");
- if(!cdp_has_app("10415", "318")) {
- xlog("Has vendor ID and application required");
- }else{
- xlog("Missing vendor ID and applications support in current peers");
- }
- }else{
- xlog("Does not have required app and cannot process");
- }
- }else{
- xlog("Peer ims-hss.localdomain is not online");
- exit;
- }
- diameter_request("ims-hss.localdomain", "$diameter_application", "$diameter_command", "$diameter_request");
- xlog("Forwarded Diameter Request");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement