51

I‘ve been trying to figure out why a router is needed. I know a router can be used for DHCP and some other things, but I’m just thinking of networking with static IPs. So the following:

Is it possible to do the following with static IPs:

Modem -> Switch -> PCs

Or do you need to go:

Modem -> Router -> Switch -> PCs

So what exactly does a router do and why is it needed?

6
  • Are you interested more about why routers in general are needed, or why the router at your home is needed? Aug 2, 2015 at 13:04
  • I think generally routers serve as an access point, DHCP, firewall and switch as an easy solution for people who don't know much about networking.
    – Maxbit
    Aug 2, 2015 at 13:12
  • 6
    @Maxbit No, that’s just what SOHO routers do.
    – Daniel B
    Aug 2, 2015 at 13:16
  • 1
    Ok, then I'd like to know why routers are needed generally and IF I need a router in my scenario.
    – Maxbit
    Aug 2, 2015 at 13:19
  • 1
    Depends if your ISP makes multiple public IP addresses available for your use, if they do its would be possible to use a switch rather than router. The router however allows you to use one public IP address with multiple private IP addresses.
    – Tyson
    Aug 2, 2015 at 13:35

6 Answers 6

76

I think generally routers serve as an access point, DHCP, firewall and switch as an easy solution for people who don't know much about networking

No, routers are a separate kind of device from APs and switches. "Router" is not just a generic name – it describes a specific function, routing IP packets between networks.

In other words, you're describing a router + switch + AP combination, which might be better called a "SOHO (Small Office/Home Office) router" or a "home gateway".

(However, many dedicated routers do have an integrated firewall and sometimes even a DHCP server.)

I'd like to know why routers are needed generally

IP routing is needed because pure Ethernet-level switching wouldn't scale well.

Ethernet device addresses are assigned by the manufacturer – there's no useful structure in them; they're random as far as the network is concerned. So an Ethernet switch only has two choices: keep a list of every single device connected to every port (as modern switches do), or simply broadcast every packet to every port (as in the original Ethernet).

Both methods work well only up to a certain network size, but if there are more devices than a switch can remember, the network will quickly melt down. (Related topics: CAM exhaustion)

Thus, similar to zipcodes or phone numbering, IP gives the network a structure – each network, sub-network, super-network is assigned a chunk of addresses, and you can describe routes such as "addresses starting with [10.7.x.x] can be reached via [port 3]". Now the rest of the world doesn't need to know about millions of Comcast customers, it only needs a few routes towards Comcast itself.

IP routers hold the knowledge of these routes, and forward all packets accordingly.

(This separation between Ethernet and IP is actually useful because it gives flexibility – the same Ethernet can carry several different protocols, such as IPv4, IPv6, perhaps IPX... Some other protocols did not have such separation, such as DECnet or NetBIOS, and they couldn't survive the network growth.)

Is it possible to go: Modem -> Switch -> PCs with static IPs

Sure, technically it's possible. Static IPs aren't even required.

Indeed, at an ISP next to my workplace, some 20 business customers around the city actually don't have their own routers – their 'external' switches are connected directly to a single router in the ISP's building (which even serves DHCP to all of them), just as you describe.

But there are reasons why it's not usually done this way. (Admittedly, a few of them come from the shortage of IPv4 addresses – such as NAT. But many would still be important even in a pure-IPv6 world.)

  • As it is right now, the ISP routes a single "global" IP address towards your network. So, certainly, you can connect your PC directly to the modem, and configure it with your "global" address. (Chances are, it would even autoconfigure that via DHCP.)

    Indeed, this used to be a very common configuration here until late 2000's. Most home customers only had one computer, and that computer would often talk directly through the modem to the ISP's routers – first using an actual dial-up modem, later an ADSL one.

    But every device needs its own address. Since you only get one IPv4 address from your ISP, you can directly connect one computer, but not two – unless you pay extra for the second address.

    That's why your home router has a "network address translation" function (aka NAT) which gives you a block of "private" 192.168.x addresses and hides them behind a single "global" one.

    (CGNAT is also worth mentioning, but research is left to the reader.)

  • Alongside NAT, your "router" also has other functions like a firewall, a DHCP server, a DNS cache. Yes, those all could be done by the ISP's routers, but it would cost the ISP a fair bit and it would inconvenience all customers, without giving any advantages to any of them.

    The firewall would have to be configured via your ISP's provided interface, and most ISPs would only provide the bare minimum of options. (When configuring my own router I have full control – I can apply firewall rules to uncommon protocols; I can create multiple subnets; I can experiment with IPv6 tunnels or RIP or OSPF...)

    Both the firewall and NAT need resources for tracking connections – some amount of memory, some CPU power. Currently these resources are spread out, since your router only has to track your own connections. But if everything was done by the ISP, their routers would need as much memory & CPU as all customers' routers together, which is expensive.

    The DHCP server works much better when it's on your side. Even if the Internet cable is cut, your own devices can still get IP addresses and communicate locally. (Yes, yes, static addresses are possible, but believe me, they're a pain in the ass to keep track of.)

    The DNS cache works because it's at your home. Your ISP has its own DNS cache anyway, but your router still has its own small cache, simply because it's closer to you, serves fewer devices, and therefore can answer much faster. (Slow DNS is very noticeable.)

So the reasons for having your own home router are, 1) it's faster, 2) it's cheaper, 3) it's simpler for both you and the ISP.

(The ISP I described earlier? I don't know why they do that. Perhaps it's different when you have only a dozen customers, than when you have many thousands.)

1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Mokubai
    Aug 4, 2015 at 11:38
5

A home modem usually only gives you one IP address. The router does NAPT (Network Address Port Translation), allowing you to have multiple private IP addresses on your network.

If your ISP gives you multiple IP addresses, you could possibly go without a router on your side.

12
  • Mhm, seems like I have a bad understanding of networks. Why do I need multiple IPs from my ISP? My understanding of the process was that if computer with static ip 192.168.0.10 requests something from like 10.0.0.0 which is not within the network (subnetmask 255.255.255.0) it will be routed to the default gateway which should be the modem that is connected to the WAN. Why do I need multiple IPs from my ISP for that?
    – Maxbit
    Aug 2, 2015 at 13:36
  • 1
    If the modem does that, it’s a router (with an integrated modem).
    – Daniel B
    Aug 2, 2015 at 13:42
  • 2
    @maxbit Unless your modem does NAPT itself (which would make it come closer to a router), your ISP will see a packet coming from 192.168.0.10. However, this is a private IP, which your neighbour could also use (and he probably uses one in that subnet), so the reply wouldn't know how to get back to you. In fact, the computer you're sending it to might have that exact same IP. Usually, ISPs will even drop packets from those IPs and only accept packets from the (public) IP they've given you. A modem simply converts one form of signal to another, they do not understand IP and work at lower layer. Aug 2, 2015 at 13:44
  • 1
    @user2313067: My ISP does hand out global IPv4 addresses to multiple connected devices on the same cable modem. I run a NAT firewall mostly to isolate insecure NFS / windows-filesharing from the Internet. I could just use a regular firewall, though, if I wanted, but I already had NAT set up before my ISP changed from requiring you to register your ethernet MAC address with them. Aug 2, 2015 at 18:35
  • 2
    @user2313067 My ISP hands out multiple. But even with an ISP only handing out one IP, you can do without a router, if you only have one computer connected. So to the technical question of can you, the answer is yes.
    – barlop
    Aug 2, 2015 at 20:53
1

At your home you likely have only one path to take to reach the Internet, out through a device provided by your Internet Service Provider (ISP). The ISP needs a router at the other end of its connection to you, though, which can decide where data from your system goes next. Does it need to go to one of the ISP's web servers, one of its other customer's systems, or does it need to go to a Google or Microsoft server, or does your destination IP address point to a system in Norway, etc. The ISP will have routers that have multiple connections coming into them. It could have a router with a circuit that connects to a network in Europe, one that connects to a network in South America, etc. And at the other end of those circuits are other routers likely with multiple connections of their own. So how does your ISP's router know which router it should forward your data to? It has a routing table that tells it which other router is the next "hop" to which it should send your data. It won't know all of the intervening routers from your system to the destination address, since it doesn't know the full path from your system to the destination system, just which one is the best choice to move your data further along the path to its destination. The next router will look in its own routing table to decide where it should send your data. It could, conceivably, send your data out any of several connections it has; it will decide on which one to use based on a "routing metric". The connection with the lowest routing metric will be chosen. But if that connection goes down or becomes congested, it can pick the next best connection based on its routing metrics. Your ISP's routers don't need to be in communication at all times with every other router in the Internet, they just need to know what is the next best network "hop" at the time your data is received; it can rely on that next router to make similar decisions and all the other routers in the path to do likewise.

By use of routing tables to pick the next hop, if your data might normally go through a router in France to reach a destination in Norway, even if there was no longer a path through France, some other router along the way that connected to the router in France would be aware of the outage and reroute your data through another path, e.g., perhaps through Germany. The Internet is an outgrowth of ARPANET; one of the requirements for ARPANet was that it be resilient and able to tolerate the failure of particular pieces of equipment in the network by routing around the failed equipment. In the days of ARPANET, the precursors of today's routers was called an Interface Message Processor (IMP).

In regards to your home network, it would be possible to have a direct connection from a device at your home that isn't a router. If you were using the Internet back in the days of dial-up modems you wouldn't have been using a router at home. Your computer would have, instead, dialed into a device belonging to the ISP. Some business and organizations still use ISDN, which operates in a similar fashion to the old dial-up modems, though they might have an ISDN router, if they have multiple systems that need to share the ISDN connection.

And even in the days when dial-up networking was the method used by almost all home users and small businesses to access the Internet, if a home user or small business had a limited number of phone lines, but needed Internet access for multiple computers, a solution that was available was to configure one PC that had a dial-up modem to function as a router for all the other computers on the local area network at the home or business. I remember installing a router that had a 56 Kbs modem in it to provide dial-up access to the Internet for several computers at a small business.

Today, people expect to be able to have both wired and wireless connections at their home that can all connect to the ISP simultaneously and, since Internet Protocol version 4 (IPv4) addresses are limited, most home users get but one public IP address, so need a device that can perform network address translation between that one public IP address and the multiple private IP addresses they will be using for their own systems. And they want to be able to control who has access from the outside into their internal systems. For that you will need your router or a firewall; most home routers have at least some limited firewall capabilities built into them.

Technically, the ISP might be able to handle the function for you, but that approach wouldn't scale well for thousands or perhaps even millions of customers. E.g., if you have your own router, you can use the private IP address 192.168.0.5 for one of your systems and so can a thousand of the ISP's other customers. The ISP doesn't have to ensure that when private IP address space is used that different customers don't pick the same addresses. The ISP's equipment external to your home only needs to concern itself with the one IP address you were provided by the ISP. And if you want to allow inbound connectivity on port 5000 to one of your systems, you can manage that yourself; you don't have to call the ISP's tech support department, which would put an additional burden on the ISP's support staff.

0

I suppose you don't need it

You can take a modem and plug a switch in and use the public IP the ISP provides.

Or you can take a router-modem and turn off the router by putting it in bridge mode(a bridge is basically switch but with some weird arbitrary distinctions people sometimes make*), and use the public IP from your ISP

Outside your home they have to use Routers, because switches don't deal with a hierarchical addressing system like IPs. A decide like a switch that can only deal with a flat addressing scheme, is too slow for a large number of devices.

Like consider if everybody in the world had a unique number, but the numbers weren't grouped together, you'd have to look up the person's whole number in the list, in order to find out which hole/socket/port/direction/angle to send the data out to. Whereas if you could see straight away they're in Tokyo / their IP address starts with blah blah blah, and everybody in Tokyo/with IP address starting with blah blah blah, has data sent out this hole/socket/port/direction/angle then it's quicker to get it to them.

But back to your personal case, your home.

You don't need DHCP server on your device because the IP can come from the ISP(via DHCP). So a switch is fine for that.

You don't need NAPT if you have only one device. A plain old switch is fine.

It's not necessarily as secure(unless you secure it yourself), and you can only connect one device if the ISP doesn't give you multiple IPs. But you can do it / it can be done.

A point re terminology. The device you call a router, is a box. It does functions. Routing, DHCP,NAPT some have a modem too. You can turn off DHCP and NAT on a box and do plain routing. And the box also has a switch built into it. You can hence put it in bridge mode, turning off the router.

-* functionally a bridge is a switch.. a few distinction people make sometimes is a switch should have multiple ports.. a bridge is for when the networks are on different mediums. maybe some say the chips in a switch are a faster design. But functionally they do switching/bridging(same thing), use a MAC address table(or perhaps some other "layer 2" protocol), and MAC addresses are a flat address scheme, probably anything at "layer 2" is.

0

The Internet is not just one protocol, but a series of protocols that stack up on top of one another. These protocols are organized into layers, and each one handles a specific task related to networking.

For this question, two of the layers are of interest: the link layer and the network layer (sometimes called the internet layer, but note the lowercase i; this isn't the same thing as the wider Internet).

The link layer handles getting a signal between two machines that are directly connected together. Wi-Fi is a protocol that lives in the link layer, as is Ethernet. There are others, but you're probably using one of these two (or maybe both of them) at home.

The network layer handles getting a signal between two machines that aren't directly connected together, using a chain of machines which are. It goes in a separate layer so that it doesn't have to know or care about how the different machines are connected; you can have machines in the chain that are connected through Ethernet or Wi-Fi or Fibre Channel or PPP or even more exotic protocols, and they would still all work together the same way.

Routers are the bridge between the link layer and the network layer. Your router is directly connected to the machines at your home (probably using Ethernet, Wi-Fi, or a mix of the two), and also to a machine at your ISP (there are many different ways that could happen). But none of those machines are directly connected to each other -they are only connected indirectly, through the router- so the router forms the all-important link between your home machines and the wider Internet. Even if your router doesn't decide what your home machines' IP addresses are, you would still need a way to form a link between them all, and this is what the router does.

2
  • Well, no; a switch already links all machines together. If you access another host within the same subnet, you don't go through any router (which is internally just connected to one of the switch ports). Aug 3, 2015 at 11:36
  • @grawity: That only holds if all of the machines and switches are on the same subnet. This is often true for most of the machines in a given setup, but there's almost always at least one exception: the uplink to the ISP. Those exceptions to the rule are what make routers necessary. Aug 3, 2015 at 12:49
0

For the simplest answer possible:

Any given device on a network can communicate with other devices in the same subnet through a switch. But in order to communicate with a device on a different subnet, a router is required. Switches will not transfer packets across subnets.

3
  • As mentioned in other answers, though, your home network is often not on the same subnet as your ISP gateway, in which case your computers will only talk to each other, and not to the Internet, without a router. Cable modems usually include a (very basic) router for this reason. Aug 3, 2015 at 17:50
  • It's possible for the ISP's router to be on the same subnet as you. It'd just become too complex to maintain beyond a few dozen customers. Aug 3, 2015 at 19:51
  • @grawity Possible, yes. But uncommon, for the reason you stated. Aug 3, 2015 at 20:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .