 |
|
 |
Hi.
I was wondering if there is a way to use the same routine to get all the available IP address in a given LAN using the same codes?
Will someone please show me how? Thanks
|
|
|
|
 |
|
 |
I tried running the code below but it doesn't give me the IP address I need for my Barcode Network Printer.
DirectorySearcher srch = new DirectorySearcher();
DirectoryEntry entry = srch.SearchRoot;
string domain = (string)entry.Properties["name"][0]; //DC name
DirectoryEntry DomainEntry = new DirectoryEntry("WinNT://" + domain);
DomainEntry.Children.SchemaFilter.Add("computer");
// To Get all the System names And Display with the Ip Address
foreach (DirectoryEntry machine in DomainEntry.Children)
{
string[] Ipaddr = new string[3];
Ipaddr[0] = machine.Name;
// string guid = machine.Guid.ToString();
System.Net.IPHostEntry Tempaddr = null;
Console.WriteLine(">" + Ipaddr[0]); // + " " + guid);
try
{
//Tempaddr = (System.Net.IPHostEntry)Dns.GetHostByAddress(machine.Name);
Tempaddr = (System.Net.IPHostEntry)Dns.GetHostEntry(machine.Name); //GetHostByName(
}
catch (Exception ex)
{
// IPx.Add(machine.Name);
continue;
}
System.Net.IPAddress[] TempAd = Tempaddr.AddressList;
foreach (IPAddress TempA in TempAd)
{
Ipaddr[1] = TempA.ToString();
//if (Ipaddr[1].ToString() == "10.25.1.222") { Console.WriteLine("found sato printer."); break; }
byte[] ab = new byte[6];
int len = ab.Length;
// This Function Used to Get The Physical Address
int r = SendARP((int)TempA.Address, 0, ab, ref len);
string mac = BitConverter.ToString(ab, 0, 6);
Ipaddr[2] = mac;
}
Console.WriteLine("\t\t" + Ipaddr[2].ToString().Trim() + "\t " + Ipaddr[1].ToString().Trim() + "\t\t " + Ipaddr[0].ToString().Trim() + " ");
}
I believe this code is all about searching for the assigned computer ip connected to the network. But my real question is,Is there a code in C# that actually searches for all the assigned network including hosts addresses? Its more than a week since I have been trying to solve this problem..
Can anyone willing to challenge my question?
Thank you and Happy New Year to all!!
you can also email me at janverge@gmail.com
|
|
|
|
 |
|
 |
first of all thank you very much,
you said "The information returned includes multiple IP addresses and aliases if the host specified has more than one entry in the DNS database"
One day I have queried the DNS and returned more than one IP, my machine was then named "TOSHIBA", I changed it to some thing like "my000000" then I logged in to the network and query the DNS again and the result was only one IP which is my machine IP address. How do you explain this and how can I identify my machine IP in case it returns more than one IP.
|
|
|
|
 |
|
 |
When a computer ask an ip address to a dhcp server, there is an expiration date. When that date is passed, the dhcp server give you another one (sometime it is the same but not always). So, the dhcp server does not always remove obsolete entries in the dns server so it is why you get multiple ip when you request for example "TOSHIBA". When you have renamed your computer to "my000000", it was the only entry with this name so you have has only one result.
I hope I was clear and sorry for my english.
|
|
|
|
 |
|
 |
Hello..
i was woundering how can i make my computer a client and a server at the same time, and how can i make sure it works?
|
|
|
|
 |
|
 |
Write your server to work on localhost (i.e. on 127.0.0.1)
|
|
|
|
 |
|
 |
otherwise will not compile
|
|
|
|
 |
|
 |
Is it possible to know if an IP address is associated with a LAN or a direct cable connection( for e.g. a USB host to host connection)
|
|
|
|
 |
|
 |
This code would not work after copy/paste into framework 2.0
They changed class name from DNS to Dns
renton
|
|
|
|
 |
|
 |
Hi, this code Return me External IP when my Computer is in LAN ??
|
|
|
|
 |
|
 |
Exactly what I needed. Thanks!
|
|
|
|
 |
|
 |
hi all
i have a proble about get all IP address in local LAN.
Best Regause
Rattapol
|
|
|
|
 |
|
 |
Try http://angryziber.com/ipscan
|
|
|
|
 |
|
 |
how can i see all IP address in local Lan nothing is signature
|
|
|
|
 |
|
 |
Hi,
I use Dns.GetHostByAddress to get a computer name from a given IP address.
I need to make a list of computers with IP address xxx.yyy.zzz.* (the last byte is variable) in my domain. I'm doing in in following (I admit silly) way:
I'm trying all 256 possibilities xxx.yyy.zzz.0-xxx.yyy.zzz.255 and passing them as argument to GetHostByAddress
If there is any computer with IP address xxx.yyy.zzz.aaa I'll get its name by Dns.GetHostByAddress(xxx.yyy.zzz.aaa). But if there is none, then GetHostByAddress lasts too long time (more than 3 seconds).
How could I avoid this? If there is any way.. I tried WinSock function gethostbyaddr and it's the same case (they're maybe identical)
Thx for any help..
stej
|
|
|
|
 |
|
 |
Hello!
Is it possible to get a calback when the ipaddress of the computer is changed? and if it is how do i do that?
Thanks Naveen for this simple and very short solution.
\Frisken
|
|
|
|
 |
|
 |
Thank you for your sample! its great, i had to know what the local iP adrress was for a c# webserver application. Thank you!
|
|
|
|
 |
|
 |
// This was cut & paisted from the MSDN Library...
// I think this is what some of you are looking for:
s.Connect (lep);
// Using the RemoteEndPoint property.
Console.WriteLine ("I am connected to " + IPAddress.Parse (((IPEndPoint)s.RemoteEndPoint).Address.ToString ()) + "on port number " + ((IPEndPoint)s.RemoteEndPoint).Port.ToString ());
// Using the LocalEndPoint property.
Console.WriteLine ("My local IpAddress is :" + IPAddress.Parse (((IPEndPoint)s.LocalEndPoint).Address.ToString ()) + "I am connected on port number " + ((IPEndPoint)s.LocalEndPoint).Port.ToString ());
|
|
|
|
 |
|
 |
How To Know Machine's Name When "Net Send Anynoumous"
Please Giev Me
Please Give Me
Thank You Very Much
Thanks Very Much
|
|
|
|
 |
|
 |
i am newbi. but i don't know how to fix again with the string strhostname =new strhostname(""). it's like it can't be zero arguments .
please give me some advice
|
|
|
|
 |
|
 |
strign strhostname = string.Empty;
thats it!!!!
|
|
|
|
 |
|
 |
Help me!
How to get name of a remote machine(on client)
If who know help me..code is much better..
Thankyou.
|
|
|
|
 |
|
 |
Hi Tinh Van Nguyen,
I think you are Vietnamese. I know your problem. You can contact with me to console it.
|
|
|
|
 |
|
 |
Personally, I think instead of using an array of IPAddress's and a for() loop, a foreach loop would be classier. Try this:
foreach(IPAddress temp in ipEntry.AddressList)
{
Console.WriteLine("IP Address: " + temp.ToString());
}
|
|
|
|
 |
 | Hmm  |  | Liquid Sky | 19:01 8 Mar '02 |
|
 |
Naveen must be a newbie... I feel sorry for the others that come to these websites to find examples that help teach, instead of bungle.
Better keep working at it Naveen
|
|
|
|
 |