Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - Machine has 250 ips, I can only retrieve 50 from code

Tags:

c#

networking

I have a linux (ubuntu server 14.04) machine with 250 ips. When I run my c# code in mono, it only retrieves 50 ips.

All ips are configured correctly, I have the same code in java, and all 250 ips are found, and can be bound to.

I have tried:

Dns.GetHostByName(Dns.GetHostName()).AddressList;

and

Dns.GetHostAddresses(string.Empty);

both return 50 ips?

So, my question, is there a limit in c# on how many ips can be discovered? or any other reason anyone knows of why this would be happening?

like image 805
felbus Avatar asked Sep 29 '22 07:09

felbus


1 Answers

I would recommend switching to a different method to obtain the same data.

System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()

http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.getallnetworkinterfaces%28v=vs.110%29.aspx

What you are asking the code to do is to take the current machine, and ask a second server what all IP addresses are registered. Instead it would be easier, and more reliable, to ask the server you are on what the IP addresses are. Some may not be registered to a DNS server, either local, or remote.

like image 142
Josh Avatar answered Oct 08 '22 21:10

Josh