Skip to main content

networking - Why is a router needed?


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?



Answer




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.)


Comments

Popular Posts

Use Google instead of Bing with Windows 10 search

I want to use Google Chrome and Google search instead of Bing when I search in Windows 10. Google Chrome is launched when I click on web, but it's Bing search. (My default search engine on Google and Edge is http://www.google.com ) I haven't found how to configure that. Someone can help me ? Answer There is no way to change the default in Cortana itself but you can redirect it in Chrome. You said that it opens the results in the Chrome browser but it used Bing search right? There's a Chrome extension now that will redirect Bing to Google, DuckDuckGo, or Yahoo , whichever you prefer. More information on that in the second link.

linux - Using an index to make grep faster?

I find myself grepping the same codebase over and over. While it works great, each command takes about 10 seconds, so I am thinking about ways to make it faster. So can grep use some sort of index? I understand an index probably won't help for complicated regexps, but I use mostly very simple patters. Does an indexer exist for this case? EDIT: I know about ctags and the like, but I would like to do full-text search. Answer what about cscope , does this match your shoes? Allows searching code for: all references to a symbol global definitions functions called by a function functions calling a function text string regular expression pattern a file files including a file

How do I transmit a single hexadecimal value serial data in PuTTY using an Alt code?

I am trying to sent a specific hexadecimal value across a serial COM port using PuTTY. Specifically, I want to send the hex codes 9C, B6, FC, and 8B. I have looked up the Alt codes for these and they are 156, 182, 252, and 139 respectively. However, whenever I input the Alt codes, a preceding hex value of C2 is sent before 9C, B6, and 8B so the values that are sent are C2 9C, C2 B6, and C2 8B. The value for FC is changed to C3 FC. Why are these values being placed before the hex value and why is FC being changed altogether? To me, it seems like there is a problem internally converting the Alt code to hex. Is there a way to directly input hex values without using Alt codes in PuTTY? Answer What you're seeing is just ordinary text character set conversion. As far as PuTTY is concerned, you are typing (and reading) text , not raw binary data, therefore it has to convert the text to bytes in whatever configured character set before sending it over the wire. In other words, when y

networking - Windows 10, can ping other PC but cannot access shared folders! What gives?

I have a computer running Windows 7 that shares a Git repo on drive D. Let's call this PC " win7 ". This repo is the origin of a project that we push to and pull from. The network is a wireless network. One PC on this network is running on Windows 10. Let's call this PC " win10 ". Win10 can ping every other PC on the network including win7 . Win7 can ping win10 . Win7 can access all shared files on win10 . Neither of the PCs have passwords. Problem : Win10 cannot access any shared files on win7 , not from Explorer, nor from Git Bash or any other Git management system (E-Git on Eclipse or Visual Studio). So, win10 cannot pull/push. Every other PC on the network can access win7 shared files and push/pull to/from the shared Git origin. What's wrong with Windows 10? I have tried these: Control Panel\All Control Panel Items\Network and Sharing Center\Advanced sharing settings\ File sharing is on, Discovery is on, Password protected sharing is off Adapte