Every network is built from a small set of device types. The trick to telling them apart is to ask one question: what does this device look at when it decides where to send a frame or packet? A hub looks at nothing, a switch looks at MAC addresses, a router looks at IP addresses, and a load balancer may look at the HTTP request itself.
Network interface card (NIC)
The NIC connects a host to a link. It can be a port on the motherboard, a PCIe card, a Wi-Fi chip or a virtual interface in a VM or container. Every Ethernet and Wi-Fi NIC has a 48-bit MAC address burned in by the manufacturer (and often randomized by the OS for privacy on Wi-Fi).
$ ip -brief link
lo UNKNOWN 00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
enp3s0 UP 3c:2c:4a:1b:9c:10 <BROADCAST,MULTICAST,UP,LOWER_UP>
wlp2s0 DOWN a4:b1:c1:22:7e:05 <NO-CARRIER,BROADCAST,MULTICAST,UP>
$ sudo ethtool enp3s0 | grep -E 'Speed|Duplex|Link detected'
Speed: 1000Mb/s
Duplex: Full
Link detected: yes
LOWER_UP and Link detected: yes mean a cable is plugged in and the other end answered. NO-CARRIER means nothing is connected.
Repeaters and hubs (layer 1)
A repeater takes a weak signal and sends it out again at full strength, so a link can run farther. A hub is a repeater with many ports: whatever comes in on one port goes out on all the others. Every device on a hub shares the same bandwidth and hears every frame, so only one can talk at a time. Hubs are obsolete; you will only meet them in old buildings and exam questions.
Bridges and switches (layer 2)
A bridge joins two network segments and forwards a frame only if the destination is on the other side. A switch is a fast bridge with many ports, and it is the heart of every LAN today.
A switch learns where devices are by reading the source MAC address of each frame and remembering the port it arrived on. That memory is the MAC address table (or CAM table):
| MAC address | Port | VLAN |
|---|---|---|
| 3c:2c:4a:1b:9c:10 | Gi0/1 | 10 |
| 00:1a:2b:3c:4d:5e | Gi0/7 | 10 |
| f0:9f:c2:aa:01:02 | Gi0/24 | 20 |
When a frame arrives, the switch looks up the destination MAC. If it knows the port, it sends the frame only there. If it does not (an “unknown unicast”) or the frame is a broadcast, it floods it out of every port in that VLAN. Each switch port is its own collision domain, and ports run full duplex, so collisions simply do not happen on a modern switched network.
A Linux bridge works the same way, which is how VMs and containers get on a network:
$ bridge fdb show br docker0 | head -3
02:42:ac:11:00:02 dev veth3a1f2c master docker0
02:42:ac:11:00:03 dev veth9b7d01 master docker0
A layer 3 switch also routes between VLANs in hardware. In a data center the line between “switch” and “router” is mostly marketing.
Routers (layer 3)
A router connects different IP networks and forwards packets between them based on the destination IP address and its routing table. Routers also stop broadcasts: a broadcast on one LAN never crosses a router to another. Your home “router” is really several devices in one box: a router, a switch, a Wi-Fi access point, a DHCP server, a DNS forwarder and a NAT firewall.
$ ip route
default via 192.168.1.1 dev enp3s0 proto dhcp metric 100
192.168.1.0/24 dev enp3s0 proto kernel scope link src 192.168.1.42
Your own computer is a tiny router too: it has a table that says “local network goes out directly, everything else goes to 192.168.1.1“.
Access points
A wireless access point (AP) bridges Wi-Fi clients onto the wired LAN. In offices, many APs are managed by a wireless controller (a box or a cloud service) that hands out the same network name and settings to all of them and moves clients between them.
Modems and ONTs
A modem converts digital data to the signal a provider’s line uses and back again: DSL over phone copper, DOCSIS over cable TV coax. Fiber service uses an ONT (optical network terminal) instead. These devices sit at the edge, between your router and the provider.
Gateways
“Gateway” means two different things:
- A default gateway is the router a host sends traffic to when the destination is not on its own network (
192.168.1.1above). - A protocol gateway translates between different protocols, for example a VoIP gateway between SIP and the phone network, or an IoT gateway between Zigbee and IP.
Firewalls
A firewall allows or blocks traffic by rules: source and destination address, port, protocol and, for stateful firewalls, whether the packet belongs to a connection that was already allowed. Next-generation firewalls also recognize applications and inspect content. Every Linux machine has one built in (nftables) and lesson 21 shows how to use it.
Load balancers and proxies
A load balancer spreads incoming connections across several servers and stops sending to servers that fail health checks. A layer 4 balancer looks at IPs and ports; a layer 7 balancer reads HTTP and can route /api and /images to different server groups. A proxy makes requests on behalf of clients (forward proxy) or sits in front of servers (reverse proxy). nginx, HAProxy and Envoy are common examples.
Device summary
| Device | Layer | Decides using | Breaks up |
|---|---|---|---|
| Hub, repeater | 1 Physical | Nothing, copies bits | Nothing |
| Bridge, switch | 2 Data link | MAC address | Collision domains |
| Router, L3 switch | 3 Network | IP address | Broadcast domains |
| Stateful firewall | 3 to 4 | IP, port, connection state | Trust zones |
| L7 load balancer, proxy | 7 Application | HTTP host, path, headers | Server pools |
Exercise
A switch receives a frame for a MAC address it has never seen. What does it do?
Show answer
Answer: B. Unknown destinations are flooded. When the device replies, the switch learns its port from the source address and sends future frames only there.
Exercise
Which device stops a broadcast from reaching another IP network?
Show answer
Answer: D. Routers do not forward broadcasts, so each routed interface ends a broadcast domain. Switches and APs forward broadcasts across the whole VLAN.
Exercise
ip -brief link shows NO-CARRIER on enp3s0. What is the most likely cause?
Show answer
Answer: C. NO-CARRIER is a layer 1 problem: the NIC sees no signal. Check the cable, the switch port and whether the other side is powered on.
Key takeaways
- Hubs repeat bits, switches forward by MAC, routers forward by IP.
- Switches learn MAC addresses from source fields and flood unknown destinations.
- Each switch port is a collision domain; each router interface ends a broadcast domain.
- A home router combines router, switch, AP, DHCP, DNS and NAT in one box.
- Firewalls filter by rules; load balancers spread connections across healthy servers.
FAQ
What is the difference between a switch and a router?
A switch connects devices inside one network and forwards frames by MAC address. A router connects different networks and forwards packets by IP address. You need a router to go from your LAN to the internet.
Is a modem the same as a router?
No. The modem (or ONT) turns the provider’s signal into Ethernet. The router decides where packets go and usually does NAT. Many providers ship one box that does both, which is why the words get mixed up.
Do I still need to know about hubs?
Only to understand why switches exist and to pass exams. You will not buy one, and a “hub” sold today is almost always a small unmanaged switch.
How do I find my default gateway?
On Linux run ip route show default; on Windows run ipconfig and read “Default Gateway”; on macOS run netstat -rn | grep default.