Networking for Security: Introduction
An alert fires at 10:02: "possible credential exposure, host 10.10.0.5". The SIEM shows a line of text. To decide whether it is real, somebody has to open the packet capture and look: which host talked to which, over what protocol, and whether a password really crossed the network in the clear. Logs summarise; packets are the evidence. Firewalls, intrusion detection systems, proxies and EDR products all make their decisions from fields in frames, packets and segments, and every one of them can be wrong. A defender who can read those fields can check the tools instead of trusting them.
This course teaches networking from that point of view. The protocols are the ones you met in Computer Networking; here each one is read byte by byte from a capture, attacked in a toy setting, detected, and fixed.
What "reading packets" looks like
Here is the first session of the course. It runs tcpdump in a sandbox and reads a sample capture of a lab web client (10.10.0.5) talking to a lab server (10.10.0.10). The sandbox has no network: tcpdump only reads a file, it does not capture anything live.
tcpdump -nn -r $SAMPLES/pcap/http.pcap -c 4reading from file /opt/sec-samples/pcap/http.pcap, link-type EN10MB (Ethernet), snapshot length 65535
10:00:00.000000 IP 10.10.0.5.50412 > 10.10.0.10.80: Flags [S], seq 1000000, win 64240, options [mss 1460], length 0
10:00:00.000250 IP 10.10.0.10.80 > 10.10.0.5.50412: Flags [S.], seq 3000000, ack 1000001, win 65160, options [mss 1460], length 0
10:00:00.000500 IP 10.10.0.5.50412 > 10.10.0.10.80: Flags [.], ack 1, win 502, length 0
10:00:00.000750 IP 10.10.0.5.50412 > 10.10.0.10.80: Flags [P.], seq 1:80, ack 1, win 502, length 79: HTTP: GET / HTTP/1.1
Four lines, and already a story: a TCP handshake ([S], [S.], [.]) from port 50412 to port 80, then the client pushes 79 bytes of data, which tcpdump recognises as an HTTP GET. Later in the course you will read the same capture again and find a login form sent without encryption, the password readable by anyone on the path.
A second view summarises a whole capture as conversations, the way an analyst starts on an unfamiliar file:
tshark -r $SAMPLES/pcap/http.pcap -q -z conv,tcp | sed -n '1,8p'================================================================================
TCP Conversations
Filter:<No Filter>
| <- | | -> | | Total | Relative | Duration |
| Frames Bytes | | Frames Bytes | | Frames Bytes | Start | |
10.10.0.5:50412 <-> 10.10.0.10:80 4 353 bytes 6 407 bytes 10 760 bytes 0.000000000 0.0022
10.10.0.5:50414 <-> 10.10.0.10:80 4 334 bytes 6 501 bytes 10 835 bytes 1.000000000 0.0023
================================================================================
Two TCP conversations from the same client to port 80, one second apart, ten frames each (760 and 835 bytes in total). Two short connections to a web server is normal; two thousand in a minute, or one to port 23, would not be. Knowing what normal looks like is most of traffic analysis.
The layers, and where the attacks sit
| Section | What you learn | What you run |
|---|---|---|
| Link layer | Ethernet frames and MAC addresses, ARP, ARP spoofing, VLANs and trunks, VLAN hopping | frame and ARP parsers in Python, tcpdump -e and tshark on the ARP capture, 802.1Q tags written with Scapy |
| Network layer | the IPv4 header field by field, CIDR and subnetting, IPv6, routing and spoofed sources, ICMP and traceroute, NAT and NAT traversal | an IPv4 parser with checksum, the subnet lab, Python's ipaddress, a NAT table simulation |
| Transport layer | the TCP header and flags, the handshake and state machine, SYN floods and SYN cookies, UDP amplification, ports and services | the tcp-handshake lab, BPF flag filters, ss and Nmap against listeners in your sandbox |
| Core services | DNS resolution and records, DNS messages in packets, cache poisoning and DNSSEC, DHCP and rogue DHCP | dig against a lab DNS server, a DNS parser, a poisoning-odds calculation, a rogue-DHCP detector |
| Application protocols | HTTP vs HTTPS, the TLS ClientHello and SNI, SSH vs Telnet, FTP vs SFTP, mail and STARTTLS, SMB, NFS, RDP, LDAP, Kerberos, IPsec, SIP and RTP | a cleartext login read from a capture, a ClientHello parser, TLS sessions with OpenSSL |
| The analyst's tools | Wireshark display filters, tcpdump and BPF, Nmap, Ncat, OpenSSL, ss, ip, nftables |
each tool, for real, inside the sandbox |
| Practice | exercises; mini project | a packet-capture analyser in Python that flags cleartext credentials, ARP spoofing and NXDOMAIN bursts |
How the examples run
```python runexamples run in your browser. They cannot open files in the sandbox, so when a Python example parses a packet, the packet's bytes are written into the code as hex, copied from the sample captures.```bash runblocks are recorded tool sessions. The site shows the saved output; each was produced by a real run of tcpdump, tshark, Nmap, Ncat, OpenSSL, dig,ssandipin a sandbox image, as an ordinary user, with no root and no network interface except loopback. The sample captures live in$SAMPLES/pcap/; a session that needs a server (a web server, a TLS server, a DNS server) starts it on127.0.0.1inside the same block and stops it at the end.- Tools that need a GUI or a live network (Wireshark itself, a live capture, a traceroute across real routers) appear as labelled lab session transcripts using lab addresses only.
The rules this course keeps
This course belongs to the Cybersecurity track and keeps its safety line, set out in Security Foundations:
- Mechanism → detection → fix. Every attack lesson ends with how the attack is seen and how it is stopped.
- Only toy targets. Attacks are shown on synthetic captures, simulations in Python, or services your sandbox started on
127.0.0.1. Nothing here sends a packet to a real host. - Lab addresses only:
10.10.0.0/24for the lab network, the documentation ranges192.0.2.0/24,198.51.100.0/24and203.0.113.0/24(RFC 5737), and names underlab.test. - Capturing and scanning are regulated. Capturing on a network you don't own or administer, reading other people's traffic or scanning their systems without authorisation can break wiretap and computer-misuse laws. Capture and scan only your own lab or with written permission (Authorization, Scope and Rules of Engagement).
Before you start
You should be comfortable with the layer model and the basics of IP, TCP and DNS; Computer Networking covers them, and the on-ramp lesson Network Security Basics gives the security overview in one page. Hex and byte order come up constantly: if 0x0800 or "big-endian" is unfamiliar, read Bits, Bytes & Byte Order first.
Test yourself
Why can't the sandbox sessions in this course capture live traffic or scan the Internet?
- tcpdump is not installed
- The sandbox has no network except loopback and no root capabilities
- Captures are only allowed in Python
- Nmap only scans IPv6
In the first tcpdump session, what do the flags [S], [S.], [.] on the first three lines show?
- An HTTP redirect
- A TCP three-way handshake
- An ARP exchange
- A DNS lookup
Which address may appear as a target in this course's transcripts?
- A university's public web server
- 10.10.0.10
- A cloud provider's DNS resolver
- Any address the learner owns