Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Integralist/89db69ec07e3ca34495259d4feacb2ae to your computer and use it in GitHub Desktop.
Save Integralist/89db69ec07e3ca34495259d4feacb2ae to your computer and use it in GitHub Desktop.
What's the difference between a router and a modem?

Modem

A modem is a box that you plug your telephone (or cable) line into. Doing this will provide you with a connection to your ISP (Internet Service Provider) who are the company responsible for providing you with a public IP address so you may connect to the internet.

The internet is based on the TCP/IP protocol, which means you need a public IP address so that any requests you make for online content has a place to send a response to (e.g. if you open a web browser and make a request for www.google.com then the response needs to know your IP so it can come back to you).

Router

A router is a box that allows multiple devices to connect to it. By itself it's probably not that useful (unless you configure it so that devices can share folders and files). So a router provides a LAN (local area network).

Typically you'll connect your router to a modem, meaning that every device that connects to the router can connect to the internet. The router uses DHCP to dynamically assign private IPs to your LAN connected devices.

If someone tries to connect to your router’s public IP address (remember this public IP is provided by your ISP), your router has no idea where it should send that traffic. All your router can do is take the traffic and discard it. This means your router acts as a firewall, discarding unrequested inbound traffic.

Although you can configure your router to use "port forwarding", so any requests for port 9000 (as an example) could be routed to a local private IP.

But you'd also need to ensure it was a static private IP, otherwise the local device (which is expected to handle the incoming request coming from outside the LAN) could end up being different each time due to DHCP dynamically assigning private IPs to local devices when they connect †

† but that in itself is a bit silly because if you had a local web server running (as an example), then you'd want it to always be connected to the router. You wouldn't disconnect the server from the router before bed as people in other timezones might still want to access it; but the principle is still the same: your server might accidentally fail and so when you restart it the connection to the router would give you a different IP, unless you configured it to give you a static IP.

ISP Provided Public IPs

There are a limit to the number of IPv4 IPs that can be created (hence the move to IPv6 IPs). ISPs will typically own a range of public IPs and then lease them to each of their customers for a set amount of time.

When the lease expires, your modem has to re-negotiate a new public IP (from the pool of public IPs your ISP makes available to its customers). This is typically why if you check a website like http://www.whatsmyip.org/ you'll find after a while (it could be days or months even), that the IP shown will change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment