To get the IP address from the SDP part of incoming INVITE:
$(rb{sdp.line,c}{s.select,2, })
http://lists.opensips.org/pipermail/users/2024-June/048189.html
To get the IP address from the SDP part of incoming INVITE:
$(rb{sdp.line,c}{s.select,2, })
http://lists.opensips.org/pipermail/users/2024-June/048189.html
conf t -> session-router -> sip-manipulation
Select some HMR and then do:
export %filename%
After that a %filename%.gz will appear under /code/imports/ directory. And you can download it via FTP/SFTP.
It is also possible to import sip-manipulation rules. Put your .gz file with the same structure to /code/imports/ , then go to conf t -> session-router -> sip-manipulation and do:
import %filename%.gz
Wanna be a real VoIP nerd? :-) Let’s use Linphone from a command line!
1. ‘linphonec’ – enter the CLI.
2. ‘help’ – list available commands. Now it’s time to create a profile and connect to PBX
3. ‘help proxy’ – show help.
3.1. ‘proxy add’ – and press Enter. Answer to the appeared questions (just look at listing below):
linphonec> proxy add Adding new proxy setup. Hit ^D to abort. Enter proxy sip address: 10.1.51.13 Your identity for this proxy: sip:1301@10.1.51.13 Do you want to register on this proxy (yes/no): yes Specify register expiration time in seconds (default is 600): Expiration: 0 seconds Specify route if needed: No route specified. -------------------------------------------- sip address: route: identity: sip:1301@10.1.51.13 register: yes expires: 0 registered: no -------------------------------------------- Accept the above proxy configuration (yes/no) ?: yes Proxy added. linphonec> Password for 1301 on "pbx.secretcompany.com": MeGaSeCuRePaSs linphonec> Unregistration on sip:10.1.51.13 done. linphonec>
Yes, the message ‘Unregistration on sip:10.1.51.13 done.’ seems strange, but tcpdump shows that everything is OK.
3.2. Now we may list our proxies:
linphonec> proxy list ****** Proxy 0 - this is the default one - ******* sip address: route: identity: sip:1301@10.1.51.13 register: yes expires: 0 registered: no linphonec>
4. Let’s call via default proxy:
linphonec> call 79991234567 Establishing call id to <sip:79991234567@10.1.51.13>, assigned id 1 Contacting <sip:79991234567@10.1.51.13> linphonec> Call 1 to <sip:79991234567@10.1.51.13> in progress. linphonec> Remote ringing. linphonec> Early media. linphonec> Call 1 with <sip:79991234567@10.1.51.13> early media. Call 1 with <sip:79991234567@10.1.51.13> connected. Call answered by <sip:79991234567@10.1.51.13>. linphonec> Media streams established with <sip:79991234567@10.1.51.13> for call 1 (audio).
We may look active calls with ‘calls’ command.
This is how it looks like while ringing:
linphonec> calls Call states Id | Destination | State | Flags | ------------------------------------------------------------------------ 2 | sip:79991234567@10.1.51.13 | OutgoingEarlyMedia |
And this is how it looks like during an established call:
linphonec> calls Call states Id | Destination | State | Flags | ------------------------------------------------------------------------ 2 | sip:79991234567@10.1.51.13 | StreamsRunning |
If you want to terminate a call, just type ‘terminate’ and press Enter.
If you have some troubles with sound and your PC is behind NAT, play with following parameters: ‘firewall’ and ‘nat’. Maybe you need ‘firewall none’ (it helped me at previous linphonec setup with one-way sound).
5. You may quit linphonec with ‘quit’ command. And these are history log, call log and configuration file in your home directory:
lexus@lexus:~$ ls -lh .linph* -rw------- 1 lexus lexus 162 нояб. 24 15:10 .linphonec_history -rw------- 1 lexus lexus 2,5K нояб. 24 15:10 .linphonerc
6. Read the documentation for more information.
Now I am a Digium Certified Asterisk Administrator (dCAA).
Few days ago we successfully implemented the switching from analog to IP telephony in one company, the name of which we keep in secret due to the privacy policy.
The ‘uplink’ still remains analog, consisting of 15 PSTN lines (the client’s requirement). All 40 office phones now are SIP ones.
Eltex TAU-32M.IP VoIP gateway was used in conjunction with AsteriskNOW (client’s requirement, they wanted to have some web-interface at least to look for the system, what is happening inside) on the HP ProLiant DL160 Gen8 server.
SIP phones are Fanvil C56, Gigaset C610A IP and top Digium’s model – D70.
A good starting place is a set of rules similar to this one:
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p udp --dport 5060 -j ACCEPT
iptables -A INPUT -p udp --dport 10000:20000 -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -P INPUT DROP
My practice of manual loading of needed modules only.
Change ‘autoload=yes
‘ to ‘autoload=no
‘ in /etc/asterisk/modules.conf
.
Restart Asterisk – Asterisk CLI> core restart now
(remember that it will cancel all active calls).
Login into Asterisk console (root# asterisk -rvvvvvvv
). Then load modules manually:
Asterisk CLI> module load app_dial.so
Asterisk CLI> module load app_playback.so
Asterisk CLI> module load chan_sip.so
Asterisk CLI> module load codec_alaw.so
Asterisk CLI> module load codec_gsm.so
Asterisk CLI> module load res_rtp_asterisk.so
Asterisk CLI> module load res_musiconhold.so
Asterisk CLI> module load func_dialplan.so
Asterisk CLI> module load pbx_config.so
Asterisk CLI> module load format_sln.so
Asterisk CLI> module load format_wav.so
Asterisk CLI> module load format_gsm.so
Asterisk CLI> module load app_record.so
A nice help for modules being used is ‘Asterisk CLI> module show
‘ . This is mine:
Asterisk CLI> module show Module Description Use Count res_musiconhold.so Music On Hold Resource 0 app_dial.so Dialing Application 0 app_playback.so Sound File Playback Application 0 chan_sip.so Session Initiation Protocol (SIP) 0 codec_alaw.so A-law Coder/Decoder 0 codec_gsm.so GSM Coder/Decoder 0 res_rtp_asterisk.so Asterisk RTP Stack 0 func_dialplan.so Dialplan Context/Extension/Priority Chec 0 pbx_config.so Text Extension Configuration 0 format_sln.so Raw Signed Linear Audio support (SLN) 0 app_record.so Trivial Record Application 0 format_wav.so Microsoft WAV/WAV16 format (8kHz/16kHz S 0 format_gsm.so Raw GSM data 0 13 modules loaded Asterisk CLI>
If you need AEL, you have to load 2 modules (in shown sequence):
Asterisk CLI> module load res_ael_share.so
Asterisk CLI> module load pbx_ael.so
The best practice is to configure /etc/asterisk/modules.conf
according to its syntax, to prevent manual loading of modules each time your Asterisk PBX starts.
Your installation may need other modules as well.
Добавляем в диалплан
exten => *98,1,Answer()
exten => *98,n,Wait(2)
exten => *98,n,Record(/tmp/myrecord%d:wav)
exten => *98,n,Wait(1)
exten => *98,n,Playback(${RECORDED_FILE})
exten => *98,n,Wait(1)
exten => *98,n,Hangup()
Начинаем надиктовывать после сигнала (услышите его, набрав *98), когда сказали всё, что хотели, нажимаем # , после чего через секунду нам проиграют надиктованный голос.
Вариантов много, подробности тут http://www.voip-info.org/wiki/view/Convert+WAV+audio+files+for+use+in+Asterisk
Я сначала конвертировал .mp3 в .wav, но Asterisk ругался, поэтому пришлось .wav конвертировать в .sln, он очень хорош для Asterisk’a.
mpg123 -w foo-out.wav foo-in.mp3
sox foo-in.wav -t raw -r 8000 -s -2 -c 1 foo-out.sln
По ссылке выше написано, что можно сразу из .mp3 в .sln, но у меня не получилось.
В Интернете много пишут про MusicOnHold, т.е. музыка при удержании звонка. Но когда мы хотим слышать музыку, пока на том конце не успели поднять трубку, MusicOnHold – не совсем то, что нам нужно. Следует использовать параметр ‘m‘ для приложения Dial.
exten => _XXXX,1,Dial(SIP/${EXTEN},15,m)
exten => {EXTEN},n,Hangup()
Обратите внимание, что сначала указывается, как долго дозваниваться, прежде чем звонок будет завершен (15 секунд), а только потом параметр музыки (m). Если поменять местами, музыка играть не будет.
Файл musiconhold.conf тоже должен быть отредактирован.
В минимальной конфигурации этого будет вполне достаточно:
[general]
[default]
mode=files
directory=moh
random=yes