已复制
全屏展示
复制代码

nmap扫描局域网所有ip地址


· 2 min read

ipcalc用于快速计算网段,nmap用户扫描局域网的ip地址。

安装工具

# 安装工具 macos
brew install ipcalc
brew install nmap

# 安装工具 ubuntu
sudo apt install nmap
sudo apt install ipcalc

查看网段

# 查看指定网卡的:IP地址、子网掩码
$ ifconfig eth0
eth0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        options=400<CHANNEL_IO>
        ether 90:9c:4a:bd:52:a2 
        inet6 fe80::180d:171e:9eee:2027%en0 prefixlen 64 secured scopeid 0x6 
        inet 172.20.10.2 netmask 0xfffffff0 broadcast 172.20.10.15
        inet6 2409:8900:78e6:20e6:18fc:63f8:4d8:617e prefixlen 64 autoconf secured 
        inet6 2409:8900:78e6:20e6:903d:24e6:189e:8427 prefixlen 64 autoconf temporary 
        nd6 options=201<PERFORMNUD,DAD>
        media: autoselect
        status: active


# 得到 16 进制的子网掩码,直接 ping 就得到 IP 形式的子网掩码
$ ping 0xfffffff0
PING 0xfffffff0 (255.255.255.240): 56 data bytes
Request timeout for icmp_seq 0
^C
--- 0xfffffff0 ping statistics ---
2 packets transmitted, 0 packets received, 100.0% packet loss


# 使用 IP地址 +子网掩码 得到了网段
$ ipcalc 172.20.10.2/255.255.255.240
Address:   172.20.10.2          10101100.00010100.00001010.0000 0010
Netmask:   255.255.255.240 = 28 11111111.11111111.11111111.1111 0000
Wildcard:  0.0.0.15             00000000.00000000.00000000.0000 1111
=>
Network:   172.20.10.0/28       10101100.00010100.00001010.0000 0000
HostMin:   172.20.10.1          10101100.00010100.00001010.0000 0001
HostMax:   172.20.10.14         10101100.00010100.00001010.0000 1110
Broadcast: 172.20.10.15         10101100.00010100.00001010.0000 1111
Hosts/Net: 14                    Class B, Private Internet

扫描局域网

# 注意要使用 sudo ,同时能解析主机名
$ sudo nmap -sn 172.20.10.0/28
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-25 00:00 CST
Nmap scan report for 172.20.10.1
Host is up (0.026s latency).
MAC Address: 56:09:10:17:CB:64 (Unknown)
Nmap scan report for 172.20.10.13
Host is up (0.012s latency).
MAC Address: DC:A6:32:57:23:07 (datanode01)
Nmap scan report for 172.20.10.2
Host is up.
Nmap done: 16 IP addresses (3 hosts up) scanned in 1.50 seconds


文章推荐