Click here to Skip to main content
16,015,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I wanted to know the ip address of router of the client/user accessing a web application. I have tried NativeWifi but that scans the ip of router connected to server but not of client's machine.

Any idea to achieve this. I tried nativeWifi code below:

WlanClient client = new WlanClient();

foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
{

Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList(0);

foreach (Wlan.WlanAvailableNetwork network in networks)
{

Wlan.Dot11Ssid ssid = network.dot11Ssid;

string networkName = Encoding.ASCII.GetString(ssid.SSID, 0, (int)ssid.SSIDLength);

string signalQuality = network.wlanSignalQuality.ToString();

lst.Add(networkName + " (Strength-" + signalQuality + "%)");


foreach (Wlan.WlanProfileInfo profileInfo in wlanIface.GetProfiles())
{
if (profileInfo.profileName == "Solitaire Slinfy")
{
string name = profileInfo.profileName; // this is typically the network's SSID

string xml = wlanIface.GetProfileXml(profileInfo.profileName);
string mac = String.Empty;

foreach (Wlan.WlanBssEntry network2 in wlanIface.GetNetworkBssList())
{
byte[] macAddr = network2.dot11Bssid;
if (GetStringForSSID(network2.dot11Ssid) == "Solitaire Slinfy")
{
for (int i = 0; i < macAddr.Length - 1; i++)
{
mac += macAddr[i].ToString("x2").PadLeft(2, '0').ToUpper();
}


string profileName = "my internet";
string key = "123456";




string s = wlanIface.InterfaceState.ToString();
string f = wlanIface.NetworkInterface.GetIPProperties().DnsAddresses.FirstOrDefault().ToString();
// string ff=wlanIface.CurrentConnection.wlanAssociationAttributes.
string ip = NetworkGateway();
string host = GetHostName(ip);
string maac = GetMacAddress(ip);
}
}
}
}








}
lstNetworks.DataSource = lst;
lstNetworks.DataBind();
}
Posted
Comments
Sinisa Hajnal 9-Sep-15 6:39am    
How would you like that some random site you access reads your router? I don't think that is possible, but I admit I don't know for sure. It just sounds wrong.
Philippe Mori 9-Sep-15 8:45am    
You don't want to do that neither you shoul be able to do it. If that much information was available, I think that security would be compromised...
Member 11983917 14-Sep-15 18:24pm    
While I agree I don't think it is a good idea for people to know my router, I am not going to police you. I don't know if this is possible, but I do have a thinking point you can ponder. Remember back to command prompt days, and needing information on other machines, we did an NSLOOKUP and it provided us with basic network information of a particular machine. Like I said, this is not a problem I am solving, but if it gives you a new way of thinking that will lead you to a solution, then that is terrific. good luck.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900