Networking โ€ข Quick Reference

Networking Commands, Ports & Subnetting

Your fast, plain-English field guide for diagnosing connections, looking up ports, calculating IPv4 subnets, and navigating the OSI model.

โฑ๏ธ 10 min ref๐ŸŸข Beginner๐Ÿ“… Updated: Nov 2026

Command Anatomy

Most network CLI tools follow the same three-part pattern: Tool + Flag + Target.

ping -c 4 8.8.8.8
ToolpingSends test packets
Flag-c 4Stop after 4 packets
Target8.8.8.8Destination IP or host

How a Request Travels

๐Ÿ’ป Client 192.168.1.10 Asks: example.com LAN ๐ŸŒ Router / NAT 192.168.1.1 Default Gateway UDP 53 ๐Ÿ“– DNS Server 8.8.8.8 / 1.1.1.1 Name โ†’ IP Lookup TCP 443 ๐Ÿ–ฅ๏ธ Web Server 93.184.216.34 Serves HTTPS Page 1. Request 2. Route Out 3. Resolve IP 4. Connect

Packet Flow: Client โ†’ Router (Gateway) โ†’ DNS (Name to IP) โ†’ Destination Server.

1 Essential CLI Commands

Use these six commands to check your IP, test reachability, trace routes, verify DNS, inspect open ports, and test HTTP responses. Press Ctrl+C anytime to stop a running ping on Linux/macOS.

ping -c 4 8.8.8.8 Win: ping 8.8.8.8
Test Reachability & Latency
Sends ICMP echo packets to check if a host is alive and how fast it replies (in ms).
traceroute google.com Win: tracert google.com
Trace Every Router Hop
Shows each router your packet passes through and where a connection slows down or drops.
ip -br addr Win: ipconfig /all
View Local IP & Interfaces
Lists your network adapters, local IPv4/IPv6 addresses, and link status (UP/DOWN).
dig +short example.com Alt: nslookup example.com
Query DNS Records
Translates a domain name into its IP address to verify DNS resolution works.
ss -tulnp Win: netstat -ano
List Listening Ports & Apps
Shows open TCP/UDP ports (-tuln) and which process ID (-p) owns them.
curl -I https://example.com Linux / macOS / Win 10+
Fetch HTTP Response Headers
Tests web server reachability and prints status codes like 200 OK or 404 without downloading the page body.

2 Well-Known Ports Quick Table

Ports act like apartment numbers on a server's IP address, routing traffic to the right service. TCP guarantees delivery; UDP prioritizes speed.

Port Protocol Service Plain-English Purpose
20 / 21 TCP FTP File Transfer Protocol (21 = control, 20 = data). Unencrypted โ€” prefer SFTP (22).
22 TCP SSH / SFTP Secure Shell for encrypted remote terminal login and file transfers.
25 TCP SMTP Simple Mail Transfer Protocol โ€” sends outgoing email between mail servers.
53 TCP / UDP DNS Domain Name System โ€” translates names like shekharit.com to IPs (UDP for queries, TCP for zone transfers).
67 / 68 UDP DHCP Automatically assigns IP addresses, subnet masks, and gateways to devices (67 = server, 68 = client).
80 TCP HTTP Unencrypted web traffic. Usually redirected to port 443.
443 TCP HTTPS Encrypted web traffic using TLS/SSL (also HTTP/3 uses UDP 443).
445 TCP SMB Windows file & printer sharing. Never expose directly to the public internet.
3389 TCP / UDP RDP Remote Desktop Protocol for graphical Windows remote control.

3 IPv4 Subnetting & CIDR Cheat Table

CIDR notation (/24) counts how many bits of the 32-bit IPv4 address belong to the network. Remember: Usable Hosts = Total IPs โˆ’ 2 (first is Network ID, last is Broadcast), except /32 which is a single host route.

CIDR Subnet Mask Total IPs Usable Hosts Typical Use
/8 255.0.0.0 16,777,216 16,777,214 Massive enterprise / Class A block
/16 255.255.0.0 65,536 65,534 Cloud VPCs (AWS / Azure / GCP)
/24 255.255.255.0 256 254 Standard home, office, or VLAN subnet
/25 255.255.255.128 128 126 Half of a /24 (department LAN)
/26 255.255.255.192 64 62 Small office or app tier subnet
/27 255.255.255.224 32 30 Database or microservice subnet
/28 255.255.255.240 16 14 Small server cluster / DMZ
/30 255.255.255.252 4 2 Point-to-point router-to-router link
/32 255.255.255.255 1 1 (Host) Single IP (firewall allowlist / loopback)

Private IPv4 Ranges (RFC 1918)

These ranges are reserved for internal networks and are not routable on the public internet:

Class A Private
10.0.0.0/8
10.0.0.0 โ€“ 10.255.255.255
~16.7M IPs (Enterprise & Cloud)
Class B Private
172.16.0.0/12
172.16.0.0 โ€“ 172.31.255.255
~1M IPs (Docker & Mid-size)
Class C Private
192.168.0.0/16
192.168.0.0 โ€“ 192.168.255.255
65,536 IPs (Home & Small LAN)

4 OSI Model 7-Layer Quick Reference

The OSI model splits networking into 7 layers so you can isolate problems (for example: "Is the cable unplugged at Layer 1, or is DNS failing at Layer 7?").

๐Ÿง  Memory Trick (Top-Down, Layer 7 โ†’ Layer 1)

All People Seem To Need Data Processing

Application โ†’ Presentation โ†’ Session โ†’ Transport โ†’ Network โ†’ Data Link โ†’ Physical

Layer Name Data Unit (PDU) Key Protocols & Devices What It Does
L7 Application Data HTTP, HTTPS, DNS, SSH, SMTP Interfaces directly with user apps (browsers, mail clients).
L6 Presentation Data TLS/SSL, JSON, UTF-8, JPEG Encrypts, compresses, and formats data for the app.
L5 Session Data RPC, NetBIOS, Auth Sessions Opens, manages, and closes communication sessions.
L4 Transport Segment TCP, UDP, Ports Reliable delivery (TCP) or fast delivery (UDP) + port numbers.
L3 Network Packet IP, ICMP, Routers Logical addressing (IP) and routing across different networks.
L2 Data Link Frame Ethernet, Wi-Fi, MAC, Switches Moves frames on the local LAN using hardware MAC addresses.
L1 Physical Bits Cables, Fiber, Hubs, NICs Transmits raw 1s and 0s over copper, fiber, or radio waves.

5 Danger Zone & Common Mistakes

โš ๏ธ Avoid These Costly Networking Mistakes
1. Opening 0.0.0.0/0 on Admin Ports: Allowing 0.0.0.0/0 on port 22 (SSH), 3389 (RDP), or 3306 (MySQL) exposes your server to every bot on the internet. Restrict admin ports to your own IP (YOUR_IP/32) or a VPN.
2. Running ufw enable Before ufw allow 22: Enabling a firewall on a cloud VPS without allowing SSH first will immediately lock you out of your own server. Always allow SSH before enabling the firewall.
3. Confusing /24 with /32: Writing 203.0.113.10/24 in a firewall rule allows all 256 IPs in that neighborhood, not just your machine. Use /32 for a single IP address.
4. Assuming a Failed ping Means a Server Is Down: Many cloud firewalls block ICMP (ping) by default. Always verify with curl -I or dig before concluding a service is offline.