root@ubuntu:~# root@ubuntu:~# mysql -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 90 Server version: 5.7.28-0ubuntu0.16.04.2 (Ubuntu) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | opensips | | performance_schema | | sys | +--------------------+ 5 rows in set (0.00 sec) mysql> use opensips Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select * from load_balancer; +----+----------+-------------------+-----------+------------+-------------+ | id | group_id | dst_uri | resources | probe_mode | description | +----+----------+-------------------+-----------+------------+-------------+ | 1 | 1 | sip:192.168.50.133 | pstn=32 | 1 | FS1 | | 2 | 1 | sip:192.168.50.134 | pstn=32 | 1 | FS2 | +----+----------+-------------------+-----------+------------+-------------+ 2 rows in set (0.00 sec) mysql> select * from dispatcer; ERROR 1146 (42S02): Table 'opensips.dispatcer' doesn't exist mysql> select * from dispatcher; +----+-------+-------------------+--------+-------+--------+----------+-------+-------------------+ | id | setid | destination | socket | state | weight | priority | attrs | description | +----+-------+-------------------+--------+-------+--------+----------+-------+-------------------+ | 1 | 1 | sip:192.168.50.133 | | 0 | 50 | 0 | FS1 | Outbound Gateway1 | | 2 | 1 | sip:192.168.50.134 | | 0 | 50 | 0 | FS2 | Outbound Gateway2 | +----+-------+-------------------+--------+-------+--------+----------+-------+-------------------+ 2 rows in set (0.00 sec) mysql> quit Bye root@ubuntu:~# root@ubuntu:~# root@ubuntu:~# root@ubuntu:~# cd /usr/local/etc/opensips/ root@ubuntu:/usr/local/etc/opensips# more opensips.cfg # # OpenSIPS loadbalancer script # by OpenSIPS Solutions # # This script was generated via "make menuconfig", from # the "Load Balancer" scenario. # You can enable / disable more features / functionalities by # re-generating the scenario with different options. # # Please refer to the Core CookBook at: # http://www.opensips.org/Resources/DocsCookbooks # for a explanation of possible statements, functions and parameters. # ####### Global Parameters ######### log_level=3 log_stderror=no log_facility=LOG_LOCAL0 children=4 /* uncomment the following lines to enable debugging */ #debug_mode=yes /* uncomment the next line to enable the auto temporary blacklisting of not available destinations (default disabled) */ #disable_dns_blacklist=no /* uncomment the next line to enable IPv6 lookup after IPv4 dns lookup failures (default disabled) */ #dns_try_ipv6=yes /* comment the next line to enable the auto discovery of local aliases based on reverse DNS on IPs */ auto_aliases=no listen=udp:192.168.50.171:5060 # CUSTOMIZE ME ####### Modules Section ######## #set module path mpath="/usr/local//lib64/opensips/modules/" #### SIGNALING module loadmodule "signaling.so" loadmodule "event_xmlrpc.so" loadmodule "textops.so" #### StateLess module loadmodule "sl.so" #### Transaction Module loadmodule "tm.so" modparam("tm", "fr_timeout", 5) modparam("tm", "fr_inv_timeout", 30) modparam("tm", "restart_fr_on_each_reply", 0) modparam("tm", "onreply_avp_mode", 1) #### Record Route Module loadmodule "rr.so" /* do not append from tag to the RR (no need for this script) */ modparam("rr", "append_fromtag", 0) #### MAX ForWarD module loadmodule "maxfwd.so" #### SIP MSG OPerationS module loadmodule "sipmsgops.so" #### FIFO Management Interface loadmodule "mi_fifo.so" modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo") modparam("mi_fifo", "fifo_mode", 0666) #### MYSQL module loadmodule "db_mysql.so" #### AVPOPS module loadmodule "avpops.so" #### ACCounting module loadmodule "acc.so" /* what special events should be accounted ? */ modparam("acc", "early_media", 0) modparam("acc", "report_cancels", 0) /* by default we 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) #### DIALOG module loadmodule "dialog.so" modparam("dialog", "dlg_match_mode", 1) modparam("dialog", "default_timeout", 21600) # 6 hours timeout modparam("dialog", "db_mode", 2) modparam("dialog", "db_url", "mysql://root:opensips@localhost") # CUSTOMIZE ME #### LOAD BALANCER module loadmodule "load_balancer.so" modparam("load_balancer", "db_url", "mysql://root:opensips@localhost") # CUSTOMIZE ME modparam("load_balancer", "probing_method", "OPTIONS") modparam("load_balancer", "probing_interval", 30) loadmodule "dispatcher.so" modparam("dispatcher", "db_url", "mysql://root:opensips@localhost") #modparam("dispatcher", "ds_ping_method", "OPTIONS") #modparam("dispatcher", "ds_ping_interval", 5) #modparam("dispatcher", "ds_probing_threshhold", 2) #modparam("dispatcher", "ds_probing_mode", 1) loadmodule "proto_udp.so" ####### Routing Logic ######## # main request routing logic route{ if (is_method("INVITE")) { if (!load_balance("1","pstn","1")) { send_reply("503","Service Unavailable"); exit; } } else if (is_method("REGISTER")) { if (!ds_select_dst("1", "0")) { send_reply("503","Service Unavailable"); exit; } } else { send_reply("405","Method Not Allowed"); exit; } if ( is_method("CANCEL") ) { if ( t_check_trans() ) t_relay(); exit; } # route the request if (!t_relay()) { sl_reply_error(); } } root@ubuntu:/usr/local/etc/opensips# root@ubuntu:/usr/local/etc/opensips# ps -ef | grep -i opensips root 8010 1 0 Dec11 ? 00:00:00 opensips -v root 8011 8010 0 Dec11 ? 00:00:00 opensips -v root 8012 8010 0 Dec11 ? 00:20:54 opensips -v root 8013 8010 0 Dec11 ? 00:05:02 opensips -v root 8014 8010 0 Dec11 ? 00:00:51 opensips -v root 8015 8010 0 Dec11 ? 00:00:46 opensips -v root 8016 8010 0 Dec11 ? 00:00:44 opensips -v root 8017 8010 0 Dec11 ? 00:00:58 opensips -v root 8018 8010 0 Dec11 ? 00:02:42 opensips -v root 13717 13689 0 23:39 pts/0 00:00:00 grep --color=auto -i opensips root@ubuntu:/usr/local/etc/opensips# netstat -alnp | grep opensips udp 0 0 192.168.50.171:5060 0.0.0.0:* 8010/opensips unix 2 [ ] STREAM CONNECTED 163030 8018/opensips unix 2 [ ] STREAM CONNECTED 163029 8010/opensips unix 2 [ ] DGRAM 132057 8010/opensips unix 2 [ ] STREAM CONNECTED 132067 8016/opensips unix 2 [ ] STREAM CONNECTED 132063 8014/opensips unix 2 [ ] STREAM CONNECTED 132065 8015/opensips unix 2 [ ] DGRAM 132054 8010/opensips unix 2 [ ] STREAM CONNECTED 132061 8011/opensips unix 2 [ ] STREAM CONNECTED 132070 8017/opensips root@ubuntu:/usr/local/etc/opensips# /etc/init.d/opensips Usage: /etc/init.d/opensips {start|stop|restart|force-reload|status} root@ubuntu:/usr/local/etc/opensips# /etc/init.d/opensips status ● opensips.service - LSB: Start the OpenSIPS SIP server Loaded: loaded (/etc/init.d/opensips; bad; vendor preset: enabled) Active: active (exited) since Sun 2019-12-15 22:49:42 PST; 24h ago Docs: man:systemd-sysv-generator(8) Process: 12868 ExecStop=/etc/init.d/opensips stop (code=exited, status=0/SUCCESS) Process: 12983 ExecStart=/etc/init.d/opensips start (code=exited, status=0/SUCCESS) Dec 15 22:49:42 ubuntu /usr/local/sbin/opensips[13006]: INFO:textops:mod_init: initializing... Dec 15 22:49:42 ubuntu /usr/local/sbin/opensips[13006]: INFO:rr:mod_init: rr - initializing Dec 15 22:49:42 ubuntu /usr/local/sbin/opensips[13006]: INFO:maxfwd:mod_init: initializing... Dec 15 22:49:42 ubuntu /usr/local/sbin/opensips[13006]: INFO:sipmsgops:mod_init: initializing... Dec 15 22:49:42 ubuntu /usr/local/sbin/opensips[13006]: INFO:core:evi_publish_event: Registered event Dec 15 22:49:42 ubuntu /usr/local/sbin/opensips[13006]: INFO:avpops:avpops_init: initializing... Dec 15 22:49:42 ubuntu /usr/local/sbin/opensips[13006]: INFO:dialog:mod_init: Dialog module - initializing Dec 15 22:49:42 ubuntu /usr/local/sbin/opensips[13006]: INFO:core:evi_publish_event: Registered event Dec 15 22:49:42 ubuntu opensips[12983]: already running ...done. Dec 15 22:49:42 ubuntu systemd[1]: Started LSB: Start the OpenSIPS SIP server. root@ubuntu:/usr/local/etc/opensips# root@ubuntu:/usr/local/etc/opensips# root@ubuntu:/usr/local/etc/opensips# root@ubuntu:/usr/local/etc/opensips# tcpdump -i any port 5060 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes 23:45:38.152130 IP 192.168.50.154.4932 > 192.168.50.171.sip: SIP: INVITE sip:43215@192.168.50.171 SIP/2.0 23:45:38.154313 IP 192.168.50.171.sip > 192.168.50.154.4932: SIP: SIP/2.0 100 Giving it a try 23:45:38.154562 IP 192.168.50.171.sip > 192.168.50.154.4932: SIP: SIP/2.0 404 Not Found 23:45:38.158486 IP 192.168.50.154.4932 > 192.168.50.171.sip: SIP: ACK sip:43215@192.168.50.171 SIP/2.0 ^C 4 packets captured 4 packets received by filter 0 packets dropped by kernel root@ubuntu:/usr/local/etc/opensips# opensips-cli -v OpenSIPS CLI 0.1.0 root@ubuntu:/usr/local/etc/opensips# opensips -v Listening on udp: 192.168.50.171 [192.168.50.171]:5060 Aliases: root@ubuntu:/usr/local/etc/opensips#