Working with IP addresses in C#

// get the host IP addresses
var hostIPs = System.Net.Dns.GetHostAddresses("LocalHost");

// get the local computer name
var localHostName = System.Net.Dns.GetHostName();

// get the local IP addresses
var localIPs = System.Net.Dns.GetHostAddresses(localHostName);

And here’s the full example with a method to check whether an IP address is local:

http://www.csharp-examples.net/local-ip/

 

Learn to build Production-Ready Serverless applications

Want to learn how to build Serverless applications and follow best practices? Subscribe to my newsletter and join over 3,000 AWS & Serverless enthusiasts who have signed up already.
As a BONUS, you will receive early access and discount for my new AppSync course.

Leave a Comment

Your email address will not be published.