Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[C#] DNS to IP [Beginner]
#1
This one is very simple. Everybody should now how to do this.

Imports:
Code:
using System.Net;

Code:
Code:
static string DNStoIP(string DNS)
        {
            try
            {
                IPHostEntry DNSHosts = Dns.GetHostEntry(DNS);
                IPAddress[] DNSIPs = DNSHosts.AddressList;
                return Convert.ToString(DNSIPs[0]);
            }
            catch (Exception ex)
            {
                throw ex;
            }

Usage:
Code:
Console.WriteLine(DNStoIP("google.com"));
Reply
#2
This is new to me; I've never used Dns.GetHostEntry before since you can do the same action using ping/reply.

Well thanks for this thread and you certainly taught me something new ;)
Reply
#3
Thanks for this (:
[Image: 15nrtb7.jpg]
Reply
#4
You're welcome everybody!
Reply
#5
Thanks, it works perfectly.
Reply
#6
wait cant you just goto cmd and do tracert (dns) then it give you the iP?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Beginner] Simple Function for retrieving Local Computer IP AceInfinity 11 2,630 10-06-2010, 12:05 PM
Last Post: CATMAN
  [Tut] How to make an auto text spammer in vb 2008. [Beginner] DeMeR 4 3,919 10-04-2010, 07:57 AM
Last Post: Jordan L.
  [C#] Random Integers [Beginner] Mike 0 596 08-31-2010, 12:57 PM
Last Post: Mike
  [Tut] Find color on screen | Good for beginner bots [VB.Net] mmki 13 10,207 08-18-2010, 05:44 AM
Last Post: mmki
  beginner, help in vb.net[solved] k1ll3r 6 1,716 10-12-2009, 03:29 AM
Last Post: k1ll3r

Forum Jump:


Users browsing this thread: 1 Guest(s)