Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Foundations / Networking hands-on

Networking hands-on cheat sheet

The OSI model

TaskCommand
Build a frame layer by layerpython3 build.py
Label the headers of a framepython3 layers.py frame.hex
Layer 2: cards and MAC addressesip -br link
Layer 3: IP addressesip -4 -br addr
Layer 4: listening portsss -tln

Addresses and routes

TaskCommand
List IPv4 addresses, one line eachip -4 -br addr
Test the network stackping -c 2 127.0.0.1
Show the routing tableip route
Ask which route an address usesip route get 1.1.1.1
Test an address against a networkpython3 -c "import ipaddress as i; print(i.ip_address('192.168.1.50') in i.ip_network('192.168.1.0/24'))"

Switching, routing and VLANs

TaskCommand
Show the ARP (neighbour) cacheip neigh, ip neigh show dev v0
Simulate a MAC tablepython3 switch.py frames.txt
Pick a route by the longest prefixpython3 route.py routes.txt 10.30.5.9
Read an 802.1Q tagpython3 vlan.py tagged.hex
Private network without rootunshare -Urn sh vlanlab.sh arp.sh, unshare -Urn sh vlanlab.sh tag.sh
Put a VLAN on an interfaceip link add link v0 name v0.10 type vlan id 10

Ports and connections

TaskCommand
Serve a folder on loopback onlypython3 -m http.server 8000 --bind 127.0.0.1
Find a listening socketss -tlnp | grep 8000
List TCP and UDP listenersss -tulnp
Show live connections to a portss -tn state established dport = :8000
Show closed connections that waitss -tn state time-wait sport = :8000
Open a TCP connection in Pythonsocket.create_connection(("127.0.0.1", 8000), timeout=3)
Catch a closed portexcept ConnectionRefusedError

DHCP, NTP and IPv6

TaskCommand
Read a DHCP exchange and its leasepython3 dhcp.py exchange.txt
Offset and delay from four time stampspython3 ntp.py ntp.txt
Is the clock synchronised?timedatectl | grep -E 'synchronized|NTP service'
List IPv6 addressesip -6 -br addr
Classify IPv6 addressespython3 ipv6.py addrs.txt
Short and long form of an addressipaddress.ip_address(x).compressed, .exploded

DNS

TaskCommand
Resolve like a normal programgetent hosts localhost
Read the resolver ordergrep '^hosts' /etc/nsswitch.conf
Read the name serversgrep nameserver /etc/resolv.conf
Show only the answer linesdig +noall +answer example.com A
Try other record typesfor t in AAAA MX TXT NS; do dig +noall +answer example.com $t; done
Spot a missing namedig example.invalid A | grep status
Ask one server and portdig @127.0.0.1 -p 8053 www.lab.test A

HTTP by hand

TaskCommand
Show request and response linescurl -sv -o /dev/null URL 2>&1 | grep -E '^[<>]'
Ask for headers onlycurl -sI URL
Print the status codecurl -s -o /dev/null -w '%{http_code}\n' URL
Force a methodcurl -si -X POST URL
Save and send cookiescurl -si -c jar.txt URL, curl -s -b jar.txt URL
Add a request headercurl -H 'Cookie: sid=abc123' URL

TLS and certificates

TaskCommand
Make a lab key and certificateopenssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem -days 30 -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
Read a certificateopenssl x509 -in cert.pem -noout -subject -issuer -dates -ext subjectAltName
Trust one certificatecurl -sS --cacert cert.pem https://localhost:8010/
Test a name with no DNS--resolve wrong.example:8010:127.0.0.1
Inspect a handshakeecho | openssl s_client -connect localhost:8010 -servername localhost -CAfile cert.pem
Test a name against a certificateopenssl x509 -in cert.pem -noout -checkhost NAME
Check expiry in 30 daysopenssl x509 -in cert.pem -noout -checkend 2592000

Capture and firewalls

TaskCommand
Watch packets livesudo tcpdump -i lo -nn -A port 8000
Save and read a capturesudo tcpdump -i lo -nn -w web.pcap port 8000, tcpdump -nn -r web.pcap
Capture without root, in a private networkunshare -Urn sh caplab.sh, then tcpdump -nn -A -r web.pcap
Run the logging proxypython3 proxy.py 8020 8000
Bind to all addresses (folder with nothing secret)cd pub && python3 -m http.server 8031 --bind 0.0.0.0
Read firewall rules of a hostsudo nft list ruleset, sudo ufw status verbose, sudo iptables -L -n -v
Make a host a routersysctl -w net.ipv4.ip_forward=1 (as root, in the private lab)
Default deny, replies allowednft add chain inet filter forward '{ type filter hook forward priority 0; policy drop; }', nft add rule inet filter forward ct state established,related accept
Drop one TCP port when forwardingnft add rule inet filter forward tcp dport 8081 drop
Rewrite the source addressnft add rule ip nat post oifname s0 masquerade
Try a router and a firewall without rootunshare -Urn sh routerlab.sh forward.sh (also firewall.sh, nat.sh)
Count a token in a capture file without tcpdumppython3 -c "print(open('beacon.pcap','rb').read().count(b'T-4417-XK'))"

Monitor and troubleshoot

TaskCommand
Climb the ladder on recorded outputpython3 ladder.py cases.txt
Tell the rung from the curl exit code6 name, 7 refused, 28 timeout, 35 and 60 TLS
Time one requestcurl -s -o /dev/null -w 'code=%{http_code} total=%{time_total}s connect=%{time_connect}s size=%{size_download}\n' URL
Latency, loss, throughput, availabilitypython3 stats.py probes.csv
Trace a request by stagepython3 trace.py https://localhost:8010/ --cacert cert.pem

Safety habits