书接上文,上次在阿里云安装好opensips之后,发现无法在公网ip监听。为了能够快速测试后续改用内网服务器搭建sips服务器。现在功能差不多了,于是就需要将opensips服务器重新部署到公网上。不得不再次面对这个蛋疼的问题。通过搜索之后发现可以通过rtpproxy实现内网穿透?(这个说不知道准不准去,没有深入研究实现原理)
方法也比较简单,安装rtpproxy:
sudo apt-get install rtpproxy |
安装之后修改opensips.cfg配置文件,添加如下内容:
#rtpproxy loadmodule "rtpproxy.so" modparam("rtpproxy", "rtpproxy_sock", "unix:/var/run/rtpproxy/rtpproxy.sock") #需要将unix路径修改为rtpproxy对应的sock路径。 |
同时修改原有配置:
listen=udp:172.18.99.28:5060 as 47.118.5.26:5060 # CUSTOMIZE ME alias=udp:47.118.5.26:5060 ####### Modules Section ######## |
修改之后重启服务即可,不过在安装rtpproxy之后,在启动opensips之前需要先启动rtpproxy。
sudo /etc/init.d/rtpproxy start |
systemctl restart opensips.service |
配置文件内容:
vim /etc/default/rtpproxy # Defaults for rtpproxy # The control socket. #CONTROL_SOCK="unix:/var/run/rtpproxy/rtpproxy.sock" # To listen on an UDP socket, uncomment this line: #CONTROL_SOCK=udp:127.0.0.1:22222 # Additional options that are passed to the daemon. EXTRA_OPTS="" #LISTEN_ADDR=47.118.5.26 #EXTRA_OPTS="-l ${LISTEN_ADDR}" |
参考文章:
https://blog.csdn.net/hzh_csdn/article/details/56011403
https://blog.csdn.net/fg4215828/article/details/60869396
https://www.dazhuanlan.com/2019/12/07/5deb0011050e3/
原创文章,转载请注明: 转载自 obaby@mars
本文标题: 《阿里云 opensips nat内网穿透》