WEBSITE

Resolve a Hostname to an IP Address

9/26/2010 7:32:52 PM
The System.Net namespace contains much of the functionality, including such basics as the IPAddress and Dns classes.
string host = "www.microsoft.com";
//note that a host can have multiple IP addresses
IPAddress[] addresses = Dns.GetHostAddresses(host);
foreach (IPAddress addr in addresses)
{
Console.Write("\t{0}", addr);
}

Here is the output from a sample run of a few common hostnames:

www.microsoft.com
207.46.19.254 207.46.19.190
www.live.com
204.2.160.40 204.2.160.49
www.google.com
208.67.219.230 208.67.219.231
www.yahoo.com
209.131.36.158
Other  
 
Most View
Bloc - The Perfect Placeholder For Your Apple TV
How To Set Up The Ultimate Steam Box (Part 2)
Windows Small Business Server 2011 : Managing User Roles
Letter Of The Month – November 2012 (Part 1)
How To Spellcheck In Any Application
Tablet Group Test – December 2012 (Part 3) : Kurio 7, Samsung Galaxy Tab 2 10.1, Toshiba AT300
AMD And Nvidia Based Products In The New Benchmark (Part 3)
Adobe Premiere CS6 : Time Is Money
Manage Add-Ons For Internet Explorer (Part 1)
For Start-Ups, The Cloud Is The Way To Go!
Top 10
Sharepoint 2013 : Farm Management - Disable a Timer Job,Start a Timer Job, Set the Schedule for a Timer Job
Sharepoint 2013 : Farm Management - Display Available Timer Jobs on the Farm, Get a Specific Timer Job, Enable a Timer Job
Sharepoint 2013 : Farm Management - Review Workflow Configuration Settings,Modify Workflow Configuration Settings
Sharepoint 2013 : Farm Management - Review SharePoint Designer Settings, Configure SharePoint Designer Settings
Sharepoint 2013 : Farm Management - Remove a Managed Path, Merge Log Files, End the Current Log File
SQL Server 2012 : Policy Based Management - Evaluating Policies
SQL Server 2012 : Defining Policies (part 3) - Creating Policies
SQL Server 2012 : Defining Policies (part 2) - Conditions
SQL Server 2012 : Defining Policies (part 1) - Management Facets
Microsoft Exchange Server 2010 : Configuring Anti-Spam and Message Filtering Options (part 4) - Preventing Internal Servers from Being Filtered