こんにちは
ローカルネットワーク(192.168.1
)に繋がっているデバイス(の IP アドレス)を検索列挙しました1。ping
コマンド利用です。
$ ./ip_search.sh 192.168.1
9 bytes from 192.168.1.1: icmp_seq=0 ttl=64
9 bytes from 192.168.1.2: icmp_seq=0 ttl=64
9 bytes from 192.168.1.4: icmp_seq=0 ttl=128
ip_search.sh
# !/bin/sh
domain=$1
seq -f "$domain.%g" 254 | xargs -P256 -n1 ping -s1 -c1 -W1 2>/dev/null | grep ttl | sort
exit
ping 以外のコマンドを利用
ping 以外のコマンドを利用し同様な情報が得られるとのことです。
ip コマンド
$ ip neigh | grep 192.168.1
arp コマンド
$ arp -a | cut -d ' ' -f 2 | tr -d '()' | grep 192.168.1
arp-scan コマンド
$ sudo arp-scan -I en0 -l | grep 192.168.1
nmap コマンド
$ sudo nmap -sP 192.168.1.* | grep 192.168.1
ifconfig コマンド
ifconfig
コマンドの利用例です。gnu-grep コマンドの perl 拡張を使っています。
$ ifconfig -a | grep broadcast | grep -ohP "\d+\.\d+\.\d+" | head -n1
192.168.1