LoginSignup
0
1

More than 1 year has passed since last update.

ローカルネットワークに繋がっているデバイスを検索列挙

Last updated at Posted at 2021-01-27

こんにちは
ローカルネットワーク(192.168.1)に繋がっているデバイス(の IP アドレス)を検索列挙しました1pingコマンド利用です。

$ ./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
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1