Tag Archive ping

Byphunsanit

หาเครื่องที่เปิดอยู่ในบ้าน / ที่ทำงาน

แทนที่จะไล่หาว่าเครื่องไหนมันเปิดอยู่บ้างที่ละเครื่องสามารถใช้ command ping เครือข่ายทั้งยวงได้โดยใช้คำสั่ง

FOR /L %i IN (1,1,254) DO ping -n 1 192.168.1.%i | FIND /i "Reply">>c:\ipaddresses.txt

ผลที่ได้จะถูกเขียนลงในไฟล์ c:\ipaddresses.txt

...
Reply from 192.168.1.1: Destination host unreachable.
Reply from 192.168.1.1: Destination host unreachable.
Reply from 192.168.1.1: Destination host unreachable.
...
Reply from 192.168.1.61: bytes=32 time=2ms TTL=64
Reply from 192.168.1.62: bytes=32 time=5ms TTL=64
Reply from 192.168.1.63: bytes=32 time<1ms TTL=128
Reply from 192.168.1.64: bytes=32 time<1ms TTL=128
...
Reply from 192.168.1.1: Destination host unreachable.
...

อธิบายคือไล่ ping เครื่องตั้งแต่ ip 192.168.1.1 ถึง 192.168.1.254 ถ้าเครื่องไหนตอบกลับมา (เปิดอยู่) แล้วเขียนไว้ในไฟล์ c:\ipaddresses.txt ถ้าเปิดดูก็จะเห็นตัวหนังสือประมาณ bytes=32 time=2ms TTL=64 ส่วนที่หาไม่เจอ ไม่ตอบกลับมา ก็จะได้ข้อความซ้ำๆ มาจาก router อย่าง Reply from 192.168.1.1: Destination host unreachable.

ดีกว่าไล่ดูทีละเครื่องเยอะเลย
Cr: Ping all addresses in network, windows