{
    "name"  : "检测DNS服务器是否未配置或配置错误",
    "problems" : {
        "flowEmpty" : {
            "desc"      : "【问题】DNS服务器未配置或配置错误",
            "advice"    : "【建议】请配置DNS服务器或正确的DNS地址"
        },
        "skipNetworkOperator" : {
            "desc"      : "【问题】DNS地址与接口地址存在跨运营商",
            "advice"    : "【建议】请根据接口所属不同运营商配置相同运营商的DNS地址"
		},
		"Empty" : {
            "desc"      : "【问题】没有流",
            "advice"    : "【建议】内网有NAT设备或PC和网关之间有防火墙、审计设备等阻的用户数据到达出口。"
		}
    }
}

---------------------------code-------------------------------
ipCheck = precondition('ipCheck')
wanIntf = precondition('wanIntf')

reg = /[\r\n]+\s*[a-zA-Z\d]+\s{2,}[\d\.]+\s{2,}(?:\([\d\.]+\)\s{2,})?[\d\.]+\s{2,}(?:\([\d\.]+\)\s{2,})?[\d]+\s{2,}53\s{2,}0\s{2,}[\d]+\s{2,}([\d]+)/g
cmd = 'show ip f f | in ' + ipCheck
response = cli(cmd)
res1 = response.split(/\r?\n/)
if res1.length < 3 :
	add_problem('Empty')
    return 'warn'
end
result = response.match(reg)
if !result :
    add_problem('flowEmpty')
    return 'warn'
else :
    totalRecv = 0
    foreach flow in result :
        rep = /(\d+)$/
        recv = flow.match(rep)
        if recv != null :
            recv = recv[1]
            recv = parse_int(recv)
            totalRecv = totalRecv + recv
        end
    end
    if totalRecv == 0 :
        add_problem('flowEmpty')
        return 'warn'
    end
end

if wanIntf != '' :
    reg = format('%s\\s{2,}([\\d\\.]+)',wanIntf)
    response = cli('show ip int brief')
    result = response.match(reg)
    if result != null :
        intfIp = result[1]
        reg = /ip\sname\-server\s[\d\.]+/g
        cmd = 'show run int ' + wanIntf
        response = cli(cmd)
        result = response.match(reg)
        if !result :
            reg = /[\r\n]ip\sname\-server\s[\d\.]+/g
            response = cli('show run | include name-server')
            result = response.match(reg)
        end
        if result != null :
            isDiffOperator = true
            foreach item in result :
                reg = /ip\sname\-server\s([\d\.]+)/
                dnsIp = item.match(reg)
                dnsIp = dnsIp[1]
                operator_intf = getOperator(intfIp)
                operator_dns =  getOperator(dnsIp)
                if operator_intf == operator_dns && operator_intf != 'other' :
                    isDiffOperator = false
                    break
                end
            end
            if isDiffOperator == true :
                add_problem('skipNetworkOperator')
                return 'warn'
            end
        end
    end
end

return 'success'