Bee Eee Blog

c# Getting your machine’s IP addresses.

by brian on Mar.17, 2009, under .NET, c#, c# coding GUI, coding, networking

Here is the simple way to get all of the IP addresses for you machine. This code filters out everything but IPv4 address, but to truly get everything just remove the if statement.

string hostName = Dns.GetHostName();
var addrs = Dns.GetHostAddresses(hostName);
bool hasIP = false;
for (int i = 0; i < addrs.Length; i++)
{
    IPAddress addr = addrs[i];
    if (addr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
    {
        si.DataIP = addr.ToString();
        hasIP = true;
        break;
    }
}
:, , ,
66 comments for this entry:
  1. Alexander7

    buy@generic.LEVITRA” rel=”nofollow”>…

    Need cheap generic LEVITRA?…

  2. SALVADOR

    Purchase@Abilify.Without.Prescription” rel=”nofollow”>..

    Buygeneric meds…

  3. JEFFREY

    Order@Cheap.Acai” rel=”nofollow”>…

    Buynow it…

  4. TERRENCE

    Cheap@Generic.Acai” rel=”nofollow”>..

    Buyit now…

  5. DONNIE

    Buy@Discount.Coral.Calcium” rel=”nofollow”>..

    Buywithout prescription…

  6. ENRIQUE

    Purchase@Cheap.Coral.Calcium” rel=”nofollow”>.

    Buynow it…

  7. ROY

    Purchase@Cheap.Coral.Calcium” rel=”nofollow”>…

    Buywithout prescription…

  8. EDUARDO

    Purchase@Abilify.Without.Prescription” rel=”nofollow”>..

    Buygeneric pills…

  9. FRED

    Cheap@Abilify.5mg.10mg.15mg.20mg.30mg” rel=”nofollow”>..

    Buyno prescription…

  10. WILLIE

    Buy@Discount.Acai” rel=”nofollow”>…

    Buygeneric drugs…

  11. CHARLIE

    Order@Cheap.Acai” rel=”nofollow”>..

    Buynow it…

  12. WALLACE

    Get@Acai.Online” rel=”nofollow”>…

    Buygeneric drugs…

  13. VICTOR

    Buy@Acai.Without.Prescription” rel=”nofollow”>.

    Buygeneric drugs…

  14. TONY

    Buy@Discount.Energy.Boost” rel=”nofollow”>.…

    Buynow it…

  15. BILLY

    Cheap@Accupril.Online” rel=”nofollow”>.…

    Buygeneric drugs…

  16. SAM

    Buy@Cheap.Accutane” rel=”nofollow”>.…

    Buygeneric drugs…

  17. CARL

    Cheap@Accutane.Online” rel=”nofollow”>.…

    Buygeneric meds…

  18. ADAM

    Order@Aciphex.Online” rel=”nofollow”>.…

    Buyno prescription…

  19. SERGIO

    Buy@Generic.Actonel.35mg” rel=”nofollow”>.

    Buyno prescription luw…

  20. VICTOR

    Generic@Actonel.35mg.Without.Prescription” rel=”nofollow”>..

    Buygeneric pills zdg…

  21. CLIFTON

    Buy@Generic.Actos.15mg.30mg” rel=”nofollow”>..

    Buygeneric meds qmo…

  22. RODNEY

    Order@Cheap.Coral.Calcium” rel=”nofollow”>..

    Buygeneric drugs lzt…

  23. LLOYD

    Order@Cheap.Abilify” rel=”nofollow”>…

    Buywithout prescription xiu…

  24. MARCUS

    Buy@Abilify.5mg.10mg.15mg.20mg.30mg” rel=”nofollow”>..

    Buynow it vhx…

  25. ALFRED

    Buy@Cheap.Acai” rel=”nofollow”>..

    Buyno prescription wkp…

  26. BRUCE

    Order@Acai.Online” rel=”nofollow”>..

    Buyno prescription jui…

  27. LEROY

    Cheap@Acai.Online” rel=”nofollow”>…

    Buyit now sge…

  28. VINCENT

    Purchase@Cheap.Energy.Boost” rel=”nofollow”>.

    Buyit now ojb…

  29. TRAVIS

    Buy@Cheap.Accutane” rel=”nofollow”>..

    Buyno prescription tao…

  30. JASON

    Get@Accutane.Online” rel=”nofollow”>…

    Buywithout prescription ccw…

  31. BRUCE

    Cheap@Generic.Accutane.10mg.20mg” rel=”nofollow”>…

    Buynow it zdg…

  32. RONNIE

    Accutane@10mg.20mg.Without.Prescription” rel=”nofollow”>..

    Buygeneric drugs ajd…

  33. MARVIN

    Aciphex@20mg.Without.Prescription” rel=”nofollow”>.

    Buynow it lmg…

  34. MITCHELL

    Buy@Discount.Acomplia” rel=”nofollow”>..

    Buydrugs without prescription faj…

  35. BRYAN

    Cheap@Advair.Online” rel=”nofollow”>.

    Buygeneric drugs nih…

  36. REGINALD

    < a href="http://trig.com/advair4746/biography/?ml=Generic-Advair-25mcg/50mcg-25mcg/125mcg-25mcg/250mcg-50mcg/500mcg-50mcg/100mcg-50mcg/250mcg-Without-Prescription Generic@Advair.25mcg50mcg.25mcg125mcg.25mcg250mcg.50mcg500mcg.50mcg100mcg.50mcg2

    Buydrugs without prescription jlg…

  37. JULIUS

    allopurinol@cheap.buy” rel=”nofollow”>..

    Buyit now…

  38. greg

    Download@pop.Rock” rel=”nofollow”>…

    Search rock US Charts…

  39. STEPHEN

    warfarin zoloft

    Buy_drugs without prescription…

  40. ROGER

    soft food diet ideas

    Buy_drugs without prescription…

  41. FREDDIE

    combination food diet

    Buy_drugs without prescription…

  42. WADE

    faye sick lung cancer

    Buy_drugs without prescription…

  43. jordan

    Download@pop.Rock” rel=”nofollow”>.

    Buy rock US Charts…

  44. SAM

    .

    Buydrugs without prescription…

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...