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

keyboard - Is there any utility/method to change Windows key bindings to type rare chars to currently empty bindings?

I'm currently typing this post with my windows XP machine and (Spanish) keyboard, and I'd like to add some extra symbols to my text. I could open the "char map" windows utility, look for the desired symbols, and paste them. But I'd like something quickier. For example, when I'm using my OSX Mac at work, I can easily add a ©, ™, ® or similar symbols, just pressing some weird ALT-GR + G / H / J, key combinations. In my (Spanish) keyboard mapping, these combinations are empty, as they don't produce any char at all, which, on the other hand, is perfectly normal and desirable. So, I thought: Why couldn't I add some extra key mappings on top of my currently empty ALT-GR + G/J/H Keys in my Spanish keyboard, and thus, being able to quickly type these special symbols? So that's my question: Is there any utility/method to achieve that effect under windows? (My version is XP). I've even googled this for some time but no luck. I've been a long term Hot...

virtualization - How to select paravirtualization interface in VirtualBox?

Given a windows 8 host system (Intel Core i5) and a Linux Fedora host, I would like to determine the optimal setting for the paravirtual interface. Options are none Default Legacy minimal Hyper-V KVM This page suggest the selection is only based on the guest system: The biggest change in VirtualBox 5.0 is the introduction of paravirtualization support, bringing higher performance and time-keeping accuracy to supported guest operating systems (Hyper-V on Windows and KVM on Linux). Is that correct? Answer The VirtualBox Manual , in the section titled Paravirtualization providers explains very clearly when each should be used (emphasis added): Minimal: Announces the presence of a virtualized environment. Additionally, reports the TSC and APIC frequency to the guest operating system. This provider is mandatory for running any Mac OS X guests. KVM: Presents a Linux KVM hypervisor interface which is recognized by Linux kernels starting with version 2.6.25. VirtualBox's implementati...

Desktop reboots itself on sleep or hibernate

I have been using an ASUS M2NPV-VM motherboard for main home desktop workstation, operating Windows Vista x64. This computer has right from day one not been able to enter hibernate or standby; after Windows performs its final actions and brings the machine down, it would automatically revive itself for a reboot. Updating to the second latest BIOS (1201)has not helped (the latest BIOS revision would induce video refresh problems rendering it unusable). I have been reading related discussions on incidents similar to mine to no avail of a true workable solution. They appear to be more speculative guesses rather than actual knowledge on the inner workings of motherboard hardware. Does anybody have any electronic engineering experience on PC energy-saving standards to provide a more informed opinion how to go about getting this to work? More stories: this motherboard could not even reboot properly the first thing i used it. It was due to refresh rate of the onboard GPU, which had no influe...

security - How is Linux not prone to viruses, malware and those kinds of things?

How is Linux protected against viruses? This question was a Super User Question of the Week . Read the blog entry for more details or contribute to the blog yourself Answer Well, it factually is not... it's just less subject to hackers developing viruses that target Linux systems. Consumer grade computers usually run on Windows and thus, when targeting a wide audience, Windows is the way to go. Don't misunderstand Linux and viruses, there definitely ARE Linux viruses. Some distros have additional protection layers such as SELinux (See here ) in Ubuntu for example. Then there's the default firewall and the fact that alien files don't automatically have permission to be executed. Specific execution permission has to be granted before execution is possible. (See here ) Then there are several other factors that make Linux a hard place to be for viruses usually non-root users on linux systems have no to little executable files at their disposal that would allow for virus...