Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you resolve a domain name to an IP address with .NET/C#?

How do you resolve a domain name to an IP address with .NET/C#?

like image 307
Antonio Haley Avatar asked Aug 07 '08 14:08

Antonio Haley


People also ask

How does a domain name resolve to an IP address?

DNS keeps the record of all domain names and the associated IP addresses. When you type in a URL in your browser, DNS resolves the domain name into an IP address. In other words, DNS is a service that maps domain names to corresponding IP addresses.

How do I give a domain name to an IP address?

To point your domain name to your dedicated server's public IP address, you need to create an address record for the domain — an A record. An A record is part of the DNS system and it simply maps a domain name to an IP address. An A record is stored as a DNS entry on the domain's name servers.

How do I resolve domain resolution?

Resolving host names with a hosts file Domain names or IP addresses on a local computer can be resolved by adding entries in the local hosts file on a computer. Entries in the local hosts file have the added advantage that the system can run the application server, even when disconnected from the network.


2 Answers

using System.Net;  foreach (IPAddress address in Dns.GetHostAddresses("www.google.com")) {    Console.WriteLine(address.ToString()); } 
like image 150
lubos hasko Avatar answered Sep 22 '22 23:09

lubos hasko


Try using the System.Net.Dns class

like image 38
Yaakov Ellis Avatar answered Sep 20 '22 23:09

Yaakov Ellis