shell 脚本dns_parse 解析url

该脚本主要用于处理VoIP服务器的DNS解析,获取服务器名称和IP地址,并将这些信息用于设置网络设备的SIP注册服务器和SIP允许地址。如果IP地址的某些部分为空,则使用默认值0.0.0.0。此外,还涉及lan和wireless的设置功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#!/bin/sh

voip_dns_parse()
{
	local voip_server_name=`echo ${QUERY_STRING} | cut -d ? -f 2`
	echo "voip_server_name == ${voip_server_name}"> /dev/console
	local voip_server_ip=''
	local voip_server_ip1=''
	local voip_server_ip2=''
	
	voip_server_ip=`dns_parse ${voip_server_name}`
	echo "voip_server_ip == ${voip_server_ip}"> /dev/console
	voip_server_ip1=`echo ${voip_server_ip} | cut -d ? -f 2`
	echo "voip_server_ip1 == ${voip_server_ip1}"> /dev/console
	voip_server_ip2=`echo ${voip_server_ip} | cut -d ? -f 4`
	echo "voip_server_ip2 == ${voip_server_ip2}"> /dev/console
	
	cfgcmd set "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.1.SIP.RegistrarServer" "$voip_server_ip"
	
	if [ "${voip_server_ip1}" == '' ]; then
		cfgcmd set "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.1.SIP.X_TRI-illegal_SipAllowAddr" "0.0.0.0"
	fi
	cfgcmd set "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.1.SIP.X_TRI-illegal_SipAllowAddr" "$voip_server_ip1"
	
	
	if [ "${voip_server_ip2}" == '' ]; then
		cfgcmd set "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.1.SIP.X_TRI-illegal_SipAllowAddrBak" "0.0.0.0"
	fi
	cfgcmd set "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.1.SIP.X_TRI-illegal_SipAllowAddrBak" "$voip_server_ip2"
	
	
	
	
	

	
}


echo "QUERY_STRING_origin == ${QUERY_STRING}"> /dev/console

QUERY_STRING=${QUERY_STRING//%23/#}

echo "QUERY_STRING == ${QUERY_STRING}"> /dev/console

gCmd=`echo ${QUERY_STRING} | cut -d ? -f 1`

echo "gCmd == ${gCmd}"> /dev/console


case "${gCmd}" in
"dns_parse")
	voip_dns_parse() 
    ;;
"lan")
    lan_set
    ;;
"wireless")
    wireless_set
    ;;
"voip")
    voip_set
    ;;    
*)

    ;;
esac


nvram commit
echo "Pragma: no-cache\n"
echo "Cache-control: no-cache\n"
echo "Content-type: text/html"
echo ""
echo "sucess"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值