Blog
Python Script

Python Script

내부에 있는 연결된 IP 확인하는 스크립트

내부IP확인 스크립트
import subprocess
import platform
import threading
 
def ping(host):
    param = "-c"
    command = ["ping", param, "1", host]
    
    if subprocess.call(command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) == 0:
        print(f"{host} is active")
    else:
        print(f"{host} is inactive")
 
if __name__ == '__main__':
    threads = []
    for i in range(1, 255):
        ip = f"192.168.0.{i}"
        thread = threading.Thread(target=ping, args=(ip,))
        thread.start()
        threads.append(thread)
 
    for thread in threads:
        thread.join()