
Internet Protocol. an IP address (IPv4 or IPv6) identifies a host on a network so packets can be routed to it.Discover hosts (IP discovery) Methods include ARP queries on a local network, ICMP ping sweeps, and crafted TCP/UDP probes. On routed networks not under your control, many hosts will drop ICMP so discovery techniques vary.
Choose scan type (port probing strategy)
Interpret results
ip addr show
OR
ifconfig
What to look for
192.168.1.15/24 in the screenshot).
What is nmap
nmap is a widely used network scanner for host discovery, port scanning, and basic service/version detection. It’s ideal for learning because it includes multiple scan modes and safe defaults.Install
sudo apt update
sudo apt install -y nmap
A) Discover live hosts on your LAN
# replace 192.168.1.15/24 with the subnet you found in step 1
nmap -sn 192.168.1.15/24
-sn = host discovery only
B) Full port range on localhost
nmap -sT -p 1-65535 127.0.0.1
-sT performs full TCP handshakes and is easy to understand for beginners.
sudo apt update
sudo apt install -y openssh-server
sudo systemctl enable --now ssh
C) Service/version detection
nmap -sT -sV --top-ports 50 192.168.1.15
-sV probes services to guess software/version.
local_probe.py# local_probe.py
import socket, ipaddress, sys
def is_allowed_target(ip):
try:
addr = ipaddress.ip_address(ip)
return addr.is_private or ip == "127.0.0.1"
except ValueError:
return False
target = input("Target IP (127.0.0.1 or private range): ").strip()
if not is_allowed_target(target):
print("Refusing non-private target. Use only localhost or private IPs.")
sys.exit(1)
ports_in = input("Enter ports (comma separated, e.g. 22,80,443): ").strip()
try:
ports = [int(p) for p in ports_in.split(",") if p.strip()]
except ValueError:
print("Invalid port list")
sys.exit(1)
timeout = 0.8
for p in ports:
if not (0 < p < 65536):
print(f"port {p}: invalid")
continue
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(timeout)
try:
s.connect((target, p))
print(f"port {p}: open")
except socket.timeout:
print(f"port {p}: filtered/timeout")
except ConnectionRefusedError:
print(f"port {p}: closed")
except Exception as e:
print(f"port {p}: error {e}")
finally:
s.close()
print("[+] Done")
open = service accepted the connectionclosed = host reachable but no service on that portfiltered = firewall or device dropped the probe-T2) on shared networks