Router
Router works at OSI Layer 3 (Network) and connects different networks together.
01What Does a Router Do?
Main Tasks:
- Routing - Ensures packets take the best path
- Network Separation - Connects different LANs
- NAT - Converts private IPs to public IP
- DHCP - Distributes IP addresses (in home routers)
- Firewall - Basic security (in home routers)
02Routing
Routing Table:
code
Destination Network Exit Next Hop
192.168.1.0/24 eth0 Directly Connected
10.0.0.0/8 eth1 192.168.1.254
0.0.0.0/0 eth2 ISP Gateway
Routing Process:
- Packet arrives → Destination IP checked
- Routing table consulted
- Best path selected (longest prefix match)
- Packet sent that direction
03Home Router vs Enterprise Router
| Feature | Home Router | Enterprise Router |
|---|---|---|
| Ports | 4-8 | 24+ |
| Speed | 1 Gbps | 10-100 Gbps |
| Features | NAT, DHCP, Wi-Fi | Routing only |
| Price | $50-200 | $1,000+ |
| Management | Web interface | CLI/SSH |
04Static vs Dynamic Routing
Static Routing:
- Manual configuration
- Good for small networks
- Stable, reliable
code
ip route 10.0.0.0/8 192.168.1.254
Dynamic Routing:
- Automatic learning
- For large networks
- Adapts to changes
Protocols:
- RIP - Old, small networks
- OSPF - Medium/large networks
- BGP - Internet backbone
05Switch vs Router
| Feature | Switch | Router |
|---|---|---|
| Layer | Layer 2 | Layer 3 |
| Address | MAC | IP |
| Broadcast | Forwards | Stops |
| Usage | Within LAN | Between LANs |
06Summary
- Router = Connects different networks
- Works at Layer 3 (IP) level
- Routes using routing table
- Stops broadcasts (separates broadcast domains)