Home > Net >  Refer to turn domain IP complains?
Refer to turn domain IP complains?

Time:10-04

///& lt; Summary> 
///incoming domain returns the corresponding IP
///& lt;/summary>
///& lt; Param name="domain" & gt; Domain name & lt;/param>
///& lt; Returns>
Public static string getIP (string domain)
{
Domain=domain. The Replace (" http://", ""). The Replace (" https://", "");
IPHostEntry hostEntry=Dns. GetHostEntry (domain);
IPEndPoint IPEndPoint=new IPEndPoint (hostEntry expressions such as AddressList [0], 0).
Return ipEndPoint. Address. The ToString ();
//IPAddress [] ips;
//ips=Dns. GetHostAddresses (domain);
//return ips [0]. ToString ();

}



Such as the DNS query will collapse at greenvpnn.com?

CodePudding user response:

Don't try this code, but according to the experience, if the network can't get to the Internet, abnormal there will be exceptions, such as DNS service

As if had twice this year, large-scale DNS service, the service if it is dependent on 8.8.8.8 and 114.114.114.114 error of the two DNS servers (ah, the original two is the fastest, most stable, the main for the double hung, later still need to do a variety of plans?)

CodePudding user response:

DNS will have a problem, but it is not common phenomenon
Try this: IPAddress [] IPs=Dns. GetHostAddresses (" domain name ");

CodePudding user response:

refer to the second floor HyoJung response:
DNS will have a problem, but it is not common phenomenon
Try this: IPAddress [] IPs=Dns. GetHostAddresses (" domain name ");


The test also not cause problems

CodePudding user response:

See the DNS whether normal, look this domain name is not very harmonious

CodePudding user response:

Apparently is a domain name can't parse (harmonious website)
And already your code as parsing can obtain IP processing the success

CodePudding user response:

GetHostEntry () of the input is the host name or IP address, not the domain name

CodePudding user response:

If you don't want to do this you need to make sure that your server can certainly connected to the Internet, and then through the CMD ping or nslookup get returned by IP
  •  Tags:  
  • C#
  • Related