Chr*_*ams 262 networking linux ip ubuntu
使用 Ubuntu 10.10 命令行,如何列出连接到家庭网络的所有 IP?
理想情况下,它需要是一个 CLI 命令,因为我将从 C++ 运行它。
Lin*_*000 274
查看arp-scan命令 - 您可能必须安装它,例如:
sudo apt-get install arp-scan
Run Code Online (Sandbox Code Playgroud)
http://manpages.ubuntu.com/manpages/hardy/man1/arp-scan.1.html
并提供进一步的细节:
sudo arp-scan --interface=eth0 --localnet
Run Code Online (Sandbox Code Playgroud)
其中 eth0 是您的设备。您可以通过以下方式找到您的设备:
ifconfig
Run Code Online (Sandbox Code Playgroud)
Kei*_*ith 132
使用 nmap。例如:nmap -sn 10.10.10.0/24arp 缓存只会告诉您最近尝试联系的人。
Dav*_*vid 22
在 Windows 中,这arp -a相当于 Linux 中的arp -e.
从man页面arp:
arp with no mode specifier will print the current content of the table.
-e : Use default Linux style output format (with fixed columns).
Run Code Online (Sandbox Code Playgroud)
小智 22
如果您的网络是192.168.0.0/24,请使用以下代码制作一个可执行文件;将 更改192.168.0为您的实际网络。
#!/bin/bash
for ip in 192.168.0.{1..254}; do
ping -c 1 -W 1 $ip | grep "64 bytes" &
done
Run Code Online (Sandbox Code Playgroud)
vkt*_*tec 15
尝试安装nmap(sudo apt-get install nmap),然后键入nmap 192.168.1.0/24替换192.168.1您的IP地址的前三部分(查出使用ip addr)。
您还可以通过运行ping 192.168.1.255(再次替换192.168.1)来获得稍微不太准确(根据我的经验)的网络地图,这应该ping向网络上的每台机器发出 a ,但根据我的经验,它并不总是能正常工作。
有关已连接设备的更紧凑列表:
nmap -sL 192.168.0.* | grep \(1
Run Code Online (Sandbox Code Playgroud)
解释。
nmap -sL 192.168.0.*将列出子网中的所有 IP 并标记那些名称为:
Nmap scan report for 192.168.0.0
Nmap scan report for Dlink-Router.Dlink (192.168.0.1)
Nmap scan report for 192.168.0.2
...
Nmap scan report for android-473e80f183648322.Dlink (192.168.0.53)
...
Nmap scan report for 192.168.0.255
Run Code Online (Sandbox Code Playgroud)
由于所有有趣的记录都以括号(和数字开头1,因此我们使用| grep \(1(需要反斜杠来转义括号)进行过滤
怪癖
请注意,如果两个设备具有相同的名称,将仅显示最后nmap连接到路由器的那个设备
| 归档时间: |
|
| 查看次数: |
642965 次 |
| 最近记录: |