我是一个托管代码的人,所以当我与非托管代码互操作时,它不像宣传的那样工作,我会抽搐。有人可以向我解释为什么当命令行工作时这会返回没有 MX 记录nslookup
?
[DllImport("dnsapi", EntryPoint = "DnsQuery_W", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
private static extern int DnsQuery([MarshalAs(UnmanagedType.VBByRefStr)]ref string pszName, QueryTypes wType, QueryOptions options, int aipServers, ref IntPtr ppQueryResults, int pReserved);
string domain = "HomeTechnologySolutions.com";
int num1 = DnsQuery(ref domain, QueryTypes.DNS_TYPE_MX, QueryOptions.DNS_QUERY_BYPASS_CACHE, 0, ref ptr1, 0);
if (num1 != 0)
{
throw new Win32Exception(num1)
}
返回的错误代码表示“未找到给定 DNS 查询的记录”
令人担忧的是,这是我发现的第一个未通过此测试的域,但我被告知它“经常”发生。(没有人能经常为我定义,但我正在努力)
无论如何,当我通过命令提示符执行 nslookup 时,我会返回:
> set type=mx
> hometechnologysolutions.com
Server: dhcp.removedtoprotectedtheguilty.com
Address: 10.0.0.9
hometechnologysolutions.com
primary name server = ns1.streetsimple.com
responsible mail addr = hostmaster.streetsimple.com
serial = 11
refresh = 900 (15 mins)
retry = 600 (10 mins)
expire = 86400 (1 day)
default TTL = 3600 (1 hour)