# start tcpdump each hour from 8:00 to 20:00 daily
00 8-20 * * * root /var/scripts/tcpdumper.sh
tcpdumper.sh script:
#!/bin/bash
TCPDUMP="/usr/bin/timeout 1h /usr/sbin/tcpdump -v -As0 -pnni enp2s0 udp and net 10.72.1.0/24 or net 10.72.2.0/24 or host 1.2.3.4"
DATE=$(date +%F_%T)
cd /home/user/
$TCPDUMP -w $DATE.pcap
# remove older than 5 days old dumps
find /home/user/ -type f -name "*pcap" -mtime +5 -execdir rm -f {} \;
exit $?
]]>opkg list-upgradable | cut -f 1 -d ' ' | xargs -r opkg upgrade
]]>setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump
setcap cap_net_raw=ep /usr/sbin/sngrep
After these steps you will be able to run tcpdump and sngrep as a non-root user.
]]>I had to edit ‘Menu -> Internet -> Linphone’ – after downloading and updated snap package of Linphone the menu entry became broken and could not launch the application, so I needed to edit the path to the new update package.
If to edit it manually (without MenuLibre), it is located here:
~/.local/share/applications/linphone.desktop
]]>To disable:
sudo dpkg-divert --package im-config --rename /usr/bin/ibus-daemon
… and then reboot. To enable back:
sudo dpkg-divert --package im-config --rename --remove /usr/bin/ibus-daemon
]]>The difference is that now we will kill dialogs not based by the remote side IP address, but based on datestart. There was some short-term connectivity interruption which caused a sudden increase in dialogs count. It’s normal for such a situation and they will end by the configured lifetime (‘default_timeout‘ parameter), e.g. 1 hour.

But what if we don’t want to wait and if we want to kill them manually?
The idea is to pick dialogs which were created during time range, assuming that you know an average call duration, and it’s obvious that if such calls are still shown by ‘opensips-cli -x mi dlg_list’ , it means that it is not valid alive call and you can kill it.
As it’s seen on the graph, the increasing was between 12:14 and 12:23. Let’s say it’s 12:30 now, and an average call duration is 30 … 60 seconds. So, we can kill dialogs which were created between 12:14 and 12:23 and which are still visible with ‘opensips-cli -x mi dlg_list’.
opensips-cli -x mi dlg_list > 2025-06-23_dlg_list.txt
grep datestart -B5 2025-06-23_dlg_list.txt | grep -B5 "2025-06-23 12:14:" | grep ID | awk '{ print $2}' | sed 's/"//g' | sed 's/,//g' > dlgs_12-14.txt
grep datestart -B5 2025-06-23_dlg_list.txt | grep -B5 "2025-06-23 12:15:" | grep ID | awk '{ print $2}' | sed 's/"//g' | sed 's/,//g' > dlgs_12-15.txt
… and so on, up to 12:23. After that you’ll have several txt files with dialog IDs. Not it’s time to kill them:
for i in `echo $(cat dlgs_12-14.txt)` ; do opensips-cli -x mi dlg_end_dlg $i ; done
… and the same for each file.
So, as a summary commands set we may use this one (just setting date/time you need):
# remove old files, if they are]]>
rm -f dlgs_all.txt dlgs_to_kill.txt
# get all dialogs list
opensips-cli -x mi dlg_list > dlgs_all.txt
# just show the oldest dialog and the newest dialog
grep datestart dlgs_all.txt | sort | head -n1 ; echo ; grep datestart dlgs_all.txt | sort | tail -n1
# kill all dialogs started at e.g. 2025-08-21 15:0x
grep datestart -B5 dlgs_all.txt | grep -B5 "2025-08-21 15:0" | grep ID | awk '{ print $2}' | sed 's/"//g' | sed 's/,//g' > dlgs_to_kill.txt && for i in `echo $(cat dlgs_to_kill.txt)` ; do opensips-cli -x mi dlg_end_dlg $i ; done
The original table looks like this.
Select:
SELECT "prefix", "description", "ruleid"
FROM "dr_rules"
WHERE "description" LIKE '%from ACME%'
ORDER BY "ruleid"
DESC LIMIT 5;
Result:
prefix description
73843444445 Novokuznetsk from ACME
73843208507 Novokuznetsk from ACME
73843400000 Maxim Novokuznetsk from ACME
73843208505 Office Poehali Novokuznetsk from ACME
73843208508 Office Maxim Novokuznetsk from ACME
We want to change “from ACME” to “moved from ACME”.
First, let’s test our SQL statement with SELECT, no changes will be made:
SELECT REPLACE(description,'from ACME','moved from ACME')
FROM dr_rules
WHERE description LIKE('%from ACME%')
AND description NOT LIKE('%moved from ACME');
Now do an SQL UPDATE in a sed-like style:
UPDATE dr_rules
SET description=REPLACE(description,'from ACME','moved from ACME')
WHERE description LIKE('%from ACME%')
AND description NOT LIKE('%moved from ACME');
The result after an UPDATE:
prefix description
73843444445 Novokuznetsk moved from ACME
73843208507 Novokuznetsk moved from ACME
73843400000 Maxim Novokuznetsk moved from ACME
73843208505 Office Poehali Novokuznetsk moved from ACME
73843208508 Office Maxim Novokuznetsk moved from ACME
So, to test the statement, do:
SELECT REPLACE(columnname,'old string','new string')
FROM tablename
WHERE columnname LIKE('%old string%')
AND columnname NOT LIKE('%new string');
To replace, do:
UPDATE tablename
SET columnname=REPLACE(columnname,'old string','new string')
WHERE columnname LIKE('%old string%')
AND columnname NOT LIKE('%new string');
If you need case-insensitive, use ILIKE instead of LIKE.
]]>Create a macro:
macro greetBlock( ext )
{
if(${DB_EXISTS(greetblock/${CALLERID(num)})}) {
// get the last call's timestamp.
Set(LASTCALL=${DB(greetblock/${CALLERID(num)})});
} else {
Set(LASTCALL=0);
}
Set(NOW=${EPOCH});
Set(DIFF=${MATH(${NOW} - ${LASTCALL},int)});
if ("${LASTCALL}" != "" & ${DIFF} < 600) {
// a person called less than 10 minutes ago - skip greeting.
NoOp(skip greeting to ${CALLERID(num)} for ${ext});
Set(GREETING=0);
} else {
Set(DB(greetblock/${CALLERID(num)})=${NOW});
Set(GREETING=1);
}
return;
};
And use this macro in your dialplan:
73333123456 =>
{
NoOp(${STRFTIME(,,%F %R)} . ${CALLERID(num)} dials SALES office . callid start: ${SIP_HEADER(Call-ID)});
&greetBlock(${EXTEN});
if ("${GREETING}" = "1") {
goto greeton;
} else {
goto greetoff;
}
greeton:
Playback(${SOUNDS}/welcome);
greetoff:
Queue(...);
...
}
]]>Add to your dialplan table:
INSERT INTO dialplan VALUES \
(1002,0,0,'rt_user1',1,'','13511654321',NULL,0,'modifying letters to digits in provider''s ruri');
So, the SQL record is as follows:
sqlite> select * from dialplan where dpid=1002;
id = 2
dpid = 1002
pr = 0
match_op = 0 # Matching operator for rule (0-equal, 1-regexp).
match_exp = rt_user1
match_flags = 1
subst_exp =
repl_exp = 13511654321
timerec =
disabled = 0
attrs = modifying letters to digits in provider's ruri
A piece of code from your OpenSIPS config:
dp_translate(1002, $rU, $var(out), $var(attrs));
xlog("L_INFO", "[$ci] method: $rm . orig uri: $ou . rU: $rU . translated into var(out) . attrs fetched: $var(attrs) \n");
We will use sipvicious for tests:
sipvicious_svmap 192.168.1.203 -m INVITE -e rt_user1
Matching flags (0-case sensitive, 1-case insensitive) – I’ve tested both with 0 and 1 values in ‘match_flags’ column and with sending INVITE with r-uri username in both cases (rt_user1 and rt_usER1), and it worked as desired. Use this if needed.
Here is how the OpenSIPS log looks like:
INFO:[663875316192451266446661] method: INVITE . orig uri: sip:rt_user1@192.168.1.203 . rU: rt_user1 . translated into 13511654321 . attrs fetched: modifying letters to digits in provider's ruri
Use case 2:
convert the username in incoming INVITE from your VoIP provider to e164 format
(e.g. INVITE: +83533444444@192.168.1.203 -> INVITE: 73533444444@192.168.1.203):
Add to your dialplan table (for testing purposes I use a separate dialplan id (dpid)):
INSERT INTO dialplan VALUES \
(1003,0,1,'^(\+73533|83533|\+83533)444444',0,'^(\+73533|83533|\+83533)(.+)','73533\2',NULL,0,'modifying rU variations to e164');
The SQL record will look like this:
sqlite> select * from dialplan where dpid=1003;
id = 3
dpid = 1003
pr = 0
match_op = 1 # Matching operator for rule (0-equal, 1-regexp).
match_exp = ^(\+73533|83533|\+83533)444444
match_flags = 0
subst_exp = ^(\+73533|83533|\+83533)(.+)
repl_exp = 73533\2
timerec =
disabled = 0
attrs = modifying rU variations to e164
A piece of code from your OpenSIPS config (for testing purposes I use a separate dialplan id (dpid)):
dp_translate(1003, $rU, $var(out2), $var(attrs2));
xlog("L_INFO", "[$ci] method: $rm . orig uri: $ou . rU: $rU . translated into $var(out2) . attrs fetched: $var(attrs2) \n");
Sipvicious commands for tests:
sipvicious_svmap 192.168.1.203 -m INVITE -e +73533444444
sipvicious_svmap 192.168.1.203 -m INVITE -e 83533444444
sipvicious_svmap 192.168.1.203 -m INVITE -e +83533444444
OpenSIPS log:
INFO:[612608355179772675168706] method: INVITE . orig uri: sip:+83533444444@192.168.1.203 . rU: +83533444444 . translated into 73533444444 . attrs fetched: modifying rU variations to e164
]]>