A router forwards packets between networks, choosing where each packet goes next based on its destination IP address. A home router connects your local network to your ISP, and usually also hands out IP addresses (DHCP), shares one public IP (NAT), provides Wi-Fi and runs a basic firewall.
How it works
Routing
A router keeps a routing table: for each destination network, which interface and next hop to use. A home router's table is simple: local addresses stay on the LAN, everything else goes to the ISP (the default route). Internet routers hold hundreds of thousands of routes learned via BGP.
The other jobs of a home router
- DHCP server: gives devices their IP addresses.
- NAT: lets all devices share one public IPv4 address.
- Firewall: drops unsolicited incoming connections.
- Wi-Fi access point and a small switch for wired ports.
- DNS forwarder: relays lookups to the ISP or a resolver.
Router vs modem
The modem (or fibre ONT) converts the signal on your line into Ethernet; the router manages your network. Many ISP boxes combine both.
Your Mac as a router
Every device routes in a small way: your Mac has its own routing table and sends anything not local to the default gateway, which is your router.
Examples
$ netstat -rn -f inet | head -4
Routing tables
Internet:
Destination Gateway Flags Netif Expire
default 192.168.1.1 UGScg en0
Everything without a more specific route goes to 192.168.1.1, the home router.
On a Mac
route -n get default shows your router's address; open http://<that address> to reach its admin page. System Settings › Network › Wi-Fi › Details › TCP/IP also lists the router.
See it in the app
LightAtom's traceroute starts with your router as the first hop, then every router beyond it.
Frequently asked questions
What does a router do?
It forwards traffic between networks. At home it connects your devices to the internet and usually also assigns addresses, shares your public IP, provides Wi-Fi and blocks incoming connections.
Do I need a router if I have a modem?
Yes, to connect more than one device and get Wi-Fi, unless your ISP's box already combines a modem and router.
How do I find my router's IP address on a Mac?
Run route -n get default in Terminal, or look under Router in System Settings › Network › Details › TCP/IP.
How often should I replace my router?
When it no longer gets firmware updates, or can't keep up with your plan or Wi-Fi needs: typically every four to six years.