找到连接到我的路由器的客户端IP地址列表 [英] Find the list of client ip address who are connected to my router

查看:166
本文介绍了找到连接到我的路由器的客户端IP地址列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要用c语言连接到我的路由器的用户ip地址列表#



我尝试过:



I want the list of users ip address who are connected to my router in the language c#

What I have tried:

public static string GetIpAddress()  // Get IP Address
    {
        string ip = "";     
        IPHostEntry ipEntry = Dns.GetHostEntry(GetHostCode());
        IPAddress[] addr = ipEntry.AddressList;
        ip = addr[2].ToString();
        return ip;
    }
    public static string GetCompCode()  // Get Computer Name
    {   
        string strHostName = "";
        strHostName = Dns.GetHostName();
        return strHostName;
    }

推荐答案

试试这个:检索LAN的IP和MAC地址 [ ^ ]

请注意,这只会选择有线连接,对于无线,你需要在这里开始阅读: WiFiDirectDevice.GetConnectionEndpointPairs | getConnectionEndpointPairs方法 - Windows应用程序开发 [ ^ ]
Try this: Retrieving IP and MAC addresses for a LAN[^]
Note that this only picks up wired connections, for wireless you need to start reading here: WiFiDirectDevice.GetConnectionEndpointPairs | getConnectionEndpointPairs method - Windows app development[^]


我假设您的客户端IP地址是使用DHCP分配的,并且DNS条目可选地添加到本地DNS服务器。 />


然后,您将无法通过标准化方法从客户端获取该信息。您必须登录到运行DHCP服务器的系统才能获取它。取决于可能是远程登录的服务器(例如,通过SSH的远程会话)或Web界面。



如果您没有专用的DHCP服务器(例如只是一个SOHO路由器,它是网关,DHCP服务器和DNS服务器)你通常没有shell登录但只有一个web界面。然后,您可以使用带有登录凭据的HTTP / HTTPS连接到Web界面,以编程方式导航到显示DHCP租约的希望提供的页面,并解析页面内容以获取IP地址。由于系统在列出时可能已经脱机,因此请检查所有系统是否仍然存在。最后,您可以使用DNS查询来获取相应的名称。



但请注意,这一切都取决于路由器型号。
I assume that your client IP adresses are assigned using DHCP and DNS entries are optionally added to a local DNS server.

Then you won't get that information from a client by a standardised method. You must be logged in to the system where the DHCP server is running to get it. Depending on the server that may be a remote login (e.g. a remote session via SSH) or a web interface.

If you did not have a dedicated DHCP server (e.g. just a SOHO router that is gateway, DHCP server and DNS server) you usually have no shell login but a web interface only. Then you might connect to the web interface using HTTP/HTTPS with the login credentials, navigate programmatically to the hopefully provided page showing the DHCP leases, and parse the page content to get the IP adresses. Because systems may be already offline when listed, check all for being still present. Finally you can use DNS queries to get the corresponding names.

But note that this all depends on the router model.


这篇关于找到连接到我的路由器的客户端IP地址列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆