Snom voice-over-IP phones have a built-in OpenVPN client, and they can also have audio transmitted to them via multicast. However, in my case a phone logged into OpenVPN did not play back audio received from the local ethernet network
I had multicast reception configured correctly on the phone:
(Remember that you need to push the Apply button at the bottom of the page and then the Save button at the top of the page for the setting to actually take effect.)
To diagnose the problem, you can use multicast pings. Running
ping -I eth0 -t 2 18.104.22.168
on the local network showed no reactions from the phone. However, running
ping -I tun2 -t 2 22.214.171.124
on the VPN server showed responses from the phone. So clearly the phone wanted to do multicast exclusively via VPN. The cause of this was the following line in my OpenVPN config on the server:
push "redirect-gateway def1"
The obvious solution was to replace this line with routes that excluded the multicast IP addresses:
push "route 0.0.0.0 126.96.36.199" push "route 188.8.131.52 192.0.0.0" push "route 192.0.0.0 184.108.40.206"
While this worked, the phone wouldn’t complete booting up the next time I power-cycled it. So I switched back to the old OpenVPN config and instead turned on multicast routing on the VPN server:
apt-get install smcroute echo 'mgroup from eth0 group 220.127.116.11' >> /etc/smcroute.conf echo 'mroute from eth0 group 18.104.22.168 to tun0 tun1 tun2' >> /etc/smcroute.conf service smcroute restart
Multicast audio now works and it even goes across the VPN.
Below you can find some commands that use FFMPEG to send the multicast audio:
ffmpeg -re -i song.mp3 -filter_complex 'aresample=16000,asetnsamples=n=160' -acodec g722 -ac 1 -vn -f rtp udp://22.214.171.124:5555 ffmpeg -re -i song.mp3 -filter_complex 'aresample=8000,asetnsamples=n=160' -acodec pcm_mulaw -ac 1 -vn -f rtp udp://126.96.36.199:5555 ffmpeg -re -i song.mp3 -filter_complex 'aresample=8000,asetnsamples=n=160' -acodec pcm_alaw -ac 1 -vn -f rtp udp://188.8.131.52:5555
Interestingly, you don’t even need to set the rtp_codec_type setting — the phone automatically determines the codec from the stream. I wasn’t able to get the Opus codec working though, the phone just makes crackling noises when I tried.