import socket for ip in ['14.10.10.71', '14.10.10.72']: print(f"\nChecking ports on {ip}:") for port in [22, 80, 111, 161, 443, 445, 2049, 5000, 5001]: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(1.0) res = s.connect_ex((ip, port)) if res == 0: print(f" Port {port} OPEN") s.close()