Skip to content
Pwnversity
FUND-REDESbasic · 9 min · upd. 2026-11

Networking Fundamentals

Almost every attack travels over the network. A port scan is raw TCP, a man-in-the-middle is ARP, a pivot is routing, and exfiltration is picking a protocol the firewall lets out. This page is the big picture: which devices exist, how the layers are organised, and what happens to a packet from the moment it leaves your machine until it reaches its destination.

Piece What it does
Host Any machine using the network: laptop, server, phone, printer.
Client · server The one asking for something (your browser) · the one offering it (the website, the SMB share). A role, not a type of machine.
Switch Distributes traffic within a network. It learns which MAC sits on each port and delivers only to the right one.
Router Joins different networks and decides where to send each packet based on the destination IP. For your machine, it’s the default gateway.
Access point A switch over radio: connects wifi devices to the wired network.
Medium What the signal travels over: copper, fibre or radio.

The home “router” is actually three devices in one box: a switch (the ports on the back), an access point (the antennas) and a router (the link to the ISP). In a company they are separate because they grow at different rates.

By size we talk about LANs (a network you fully control: home, office, a floor) and WANs (geographically separate networks joined together). The Internet isn’t a network: it’s the interconnection of millions of networks speaking the same protocol.

Each layer solves one problem and only talks to the layer above and below. That’s why you can switch from cable to wifi without your browser noticing. It’s taught with OSI (7 layers), which provides the vocabulary (“layer 2 attack”, “layer 7 load balancer”), but what actually runs is TCP/IP (4 layers).

OSI TCP/IP What it solves Examples
7 Application · 6 Presentation · 5 Session Application What the program understands, format, encryption HTTP, DNS, SSH, SMB, TLS
4 Transport Transport Which program receives it (ports), reliability, ordering TCP, UDP
3 Network Internet Logical addresses and routing between networks IP, ICMP
2 Data link · 1 Physical Network access Delivery within the same segment, signal Ethernet, wifi, ARP

When sending, each layer adds its header around what it gets from above. When receiving, each layer strips its own and passes the rest up.

flowchart TB
    A["Application data (HTTP request)"] --> B["+ TCP header (ports) = segment"]
    B --> C["+ IP header (source and destination IP) = packet"]
    C --> D["+ Ethernet header (source and destination MAC) = frame"]
    D --> E["Bits over the cable or the air"]

From the inside out: segment (layer 4) → packet (layer 3) → frame (layer 2). That’s why Wireshark shows each packet as expandable layers.

MAC IP
Layer 2 (data link) 3 (network)
Format 48 bits in hex: 08:00:27:3a:9c:01 32 bits in decimal: 192.168.1.50
Who sets it The card manufacturer (the first 3 bytes identify the vendor) The network you connect to
When you change networks Stays the same Changes
Reach Only up to the next hop Source to destination
What it’s for Delivery within the local network Routing between networks

Say your PC (192.168.1.50) requests a web page from a server on another network. The packet goes through your router:

Field PC to router Router to next hop
Source MAC PC’s MAC Router’s MAC (its outgoing interface)
Destination MAC Router’s MAC Next device’s MAC
Source IP 192.168.1.50 192.168.1.50 (or the public one, with NAT)
Destination IP Server’s IP Server’s IP
Ports Ephemeral source → 443 Unchanged (unless PAT)

Rule: MACs are rewritten at every hop; IPs and ports only change if there’s NAT. Outbound NAT (SNAT, what your home router does) changes the source IP and port; a port forward (DNAT) changes the destination IP and port, from the router’s public IP to the internal server’s. See IP addressing and NAT and how a packet travels.

Radio is a shared medium: anyone in range receives the frames, whether or not they’re connected to the network. The only thing protecting the content is encryption. WPA2 and WPA3 are current; WEP and WPA (TKIP) are broken and, if they show up in an assessment, they’re a finding. See wifi.

Ventana de terminal
# Your interfaces: state, MAC and IP
ip -br link # eth0 UP 08:00:27:3a:9c:01
ip -br -4 a # eth0 UP 192.168.1.50/24
# Show layer 2 headers (MAC) as well as layer 3
sudo tcpdump -i eth0 -e -nn -c 5
# 08:00:27:3a:9c:01 > 52:54:00:12:35:02, ethertype IPv4 (0x0800) ...
# 192.168.1.50.51000 > 93.184.215.14.443: Flags [S] ...
# ^ PC's MAC → router's MAC, even though the destination IP is a remote server
# Every hop to a destination
traceroute -n 8.8.8.8
Concept What to remember
Switch · router Within the network (MAC) · between networks (IP).
OSI · TCP/IP Vocabulary · what actually runs.
Segment · packet · frame Layer 4 · layer 3 · layer 2.
At each hop The MACs change.
IPs and ports Only change with NAT: SNAT the source, DNAT (port forward) the destination.
MAC Set by the vendor, local, spoofable.
Wifi Shared medium: only encryption protects it. WEP and WPA are broken.
  1. What’s the difference between a switch and a router?

    Answer

    The switch delivers frames within the same network using MAC addresses. The router connects different networks and picks the path based on the destination IP.

  2. Order from the inside out: frame, segment, packet. What does each add?

    Answer

    Segment (ports, layer 4) → packet (IP addresses, layer 3) → frame (MAC addresses, layer 2).

  3. Your packet to an Internet server leaves your PC. What destination MAC does it carry?

    Answer

    Your default gateway’s (the router), not the server’s. The MAC only matters for the current hop; the destination IP is the server’s.

  4. When crossing a router without NAT, which fields change?

    Answer

    Only the source and destination MACs. IPs and ports stay the same; they would change with NAT (SNAT the source, a port forward or DNAT the destination).

  5. Why isn’t MAC filtering a security control?

    Answer

    Because the MAC travels in clear in every frame and can be changed in software: you only need to observe an authorised MAC and copy it.

  6. Why don’t you need to be connected to a wifi network to capture its traffic?

    Answer

    Because radio is a shared medium: every frame reaches any antenna in range. What stops you reading them is encryption (WPA2/WPA3), not the fact that you aren’t associated.