ãã¾ã«LANã«æ¥ç¶ãã¦ããæ©å¨ã®IPã¢ãã¬ã¹ãç¥ãããæããããPCãã²ã¼ã æ©ããããªãæ¬ä½ã®æ©è½ã§IPã¢ãã¬ã¹ã確èªããã°æ¸ãããããç¸æããã¼ã ã²ã¼ãã¦ã§ã¤ï¼ããã¼ããã³ãã«ã¼ã¿ãç¡ç·LANã¢ã¯ã»ã¹ãã¤ã³ããUSBã¡ãã£ã¢ãµã¼ãã§ããã¼ãã¦ã§ã¢æ¬ä½ã«ã¯IPã¢ãã¬ã¹è¡¨ç¤ºæ©è½ããªããWeb管çç»é¢ãããã°ã¤ã³ãããã®ã ãã©ã¢ãã¬ã¹ãåãããªãã®ã§ç®¡çç»é¢ã«ãããã©ãçããªãââãããªæã«ãã¨ããããLANã«æ¥ç¶ãã¦ããæ©å¨ã®IPã¢ãã¬ã¹ãåæãã¦ãããããçµãè¾¼ãã§ãã£ããããã
ï¼UPnPãDLNAãBonjourçµç±ã§Web管çç»é¢ã«ãã©ãçããã¨ã¯éããªããå¤ãæ©å¨ãªã®ã§UPnPçãªæ©è½ãæã£ã¦ããªãã£ãããã¯ã©ã¤ã¢ã³ãPCãWindowsã§ããã¨ããã®ããããã¯ã¼ã¯æ¢ç´¢ããç¡å¹ã«ãã¦ããããããã¨ãããã®ã ï¼
ä»ã«ã¯ãä¾ãã°LANã«ãããã¯ã¼ã¯å¯¾å¿ã®ããªã³ã¿ãæ¥ç¶ãã¦åºå®IPãå²ãæ¯ãããã®ã ãã©æ¢åã®ãµã¼ããããªã³ã¿ãã®ä»ã使ç¨ãã¦ããIPã¢ãã¬ã¹ãåãããªãã¨ããRaspberry Pi OSãå ¥ããRaspberry Piã®åæè¨å®ããããã®ã ãã©è«¸äºæ ã«ãããã£ã¹ãã¬ã¤ããã¼ãã¼ããæ¥ç¶ã§ããªãã®ã§åã£ç«¯ããsshæ¥ç¶ãããã¨ããããããå ´åã«ãåããããªãã¨ãããããªãã
å®ç´ãªè§£æ³ã¨ãã¦ã¯ãLANã®å ¨IPã¢ãã¬ã¹ã«å¯¾ãã¦pingãå®è¡ãã¦åå¿ã調ã¹ãã°ããããã¡ã¤ã¢ã¼ã¦ã©ã¼ã«çã§pingã«å¿çããªãè¨å®ã«ãã¦ããæ©å¨ã¯åæã§ããªããã大æµã®å ´åãå¿çããªãã®ã¯PCã ï¼PCã ããæ®éã«ãã°ãªã³ãã¦IPã¢ãã¬ã¹ã確èªããã°ããï¼ã
ã¨ãã訳ã§ping(8)ã§çµ¨æ¯¯çæããã·ã§ã«ã¹ã¯ãªãããæ¸ãã¦ã¿ãï¼IPã¢ãã¬ã¹ã¯åèªã®ç°å¢ã«åããã¦èª¿æ´ãããã¨ï¼ã
#!/bin/sh # -*- coding: utf-8-unix -*- # vim:fileencoding=utf-8:ff=unix # # Worked on Ubuntu 20.04 readonly addrbase=192.0.2. for i in $(seq 1 254); do addr=$addrbase$i ping -c 1 -w 1 $addr >/dev/null [ $? -eq 0 ] && echo $addr done
ç°å¢ã«ãã£ã¦ping(8)ã®ã¿ã¤ã ã¢ã¦ããè¨å®ãããªãã·ã§ã³ãç°ãªãã®ã§æ³¨æã
ãã®ã¹ã¯ãªããã¯ãå®ç´ã«ãã¿ã¤ã ã¢ã¦ã1ç§ã®è¨å®ã§1åã ãICMP Echoãéä¿¡ãããã¨ããå¦çãIPã¢ãã¬ã¹ãã¨ã«é çªã«å®è¡ãã¦ããããã®ããé常ã«é ããLANã«æ¥ç¶ãã¦ããæ©å¨ãå°ãªãã£ãããæ¥ç¶ãã¦ãã¦ãpingã«åå¿ããªãæ©å¨ãå¤ãã»ã©ââã¤ã¾ãICMP Echo Replyãè¿ã£ã¦ããå¯è½æ§ãä½ãã»ã©é ããªããæ大ã§1ç§ãããå¦çã254åå®è¡ããã®ã§ãã¯ã¼ã¹ãã§4å13ç§ããããããè¨ç®ã«ãªã*1ã
4å以ä¸ããããã®ã¯ä¸ä¾¿ãªã®ã§ãé«éåãã¦ã¿ãã
#!/bin/sh # -*- coding: utf-8-unix -*- # vim:fileencoding=utf-8:ff=unix # # Worked on Ubuntu 20.04 readonly addrbase=192.0.2. # do_ping <IP address> do_ping () { ping -c 1 -w 1 $1 >/dev/null [ $? -eq 0 ] && echo $1 } { for i in $(seq 1 254); do do_ping $addrbase$i & done wait } | sort -V
ããã¯ã°ã©ã¦ã³ãããã»ã¹ã使ã£ã¦ping(8)ã並è¡å®è¡ãããããã«ãã¦ã¿ãããããªã1ç§ã¡ãã£ã¨ã§å®äºããã
並è¡å®è¡ã®ä»£åã¨ãã¦ãIPã¢ãã¬ã¹ã®åºåé ãä¸å®ã¨ãªãããããã½ã¼ãããã®ã«ãIPv4ã¢ãã¬ã¹ãªãGNU coreutilsã®sort(1)ã®ãªãã·ã§ã³-V
ã使ãããä»ã®ç°å¢ã«ã¯-V
ãç¡ãã®ã§ãå¥ã®ãªãã·ã§ã³ã®çµã¿åããã§å¯¾å¿ãããã¨ã«ãªãï¼ä¾ãã°sort -t . -k 4,4 -n
ã ãããï¼ã
ãªãIPv6ã®ãã¨ã¯èãã¦ããªããèªå® ãä¼ç¤¾ã®LANãIPv6ã«ãªã£ã¦ããèããã¤ããã
çµããã«
æçµçã«ã¯ããããªæãã«ãªã£ãã
https://github.com/eel3/eel3-scripts/blob/master/bin/linux/pingest4
*1:4å14ç§ã§ã¯ãªã4å13ç§ãªã®ã¯ãLANã«æ¥ç¶ãã¦ããæ©å¨ã®ãã¡1å°ã¯èªåèªèº«ãªã®ã§ãã»ã¼ç¢ºå®ã«æ°ããªç§ç¨åº¦ã§ã¬ã¹ãã³ã¹ã帰ã£ã¦ããããã ã