Router vs Gateway

I have started “DevOps Pre-Requisite Course”.

My understanding about Router is: It helps to establish communication between systems that are on different networks.

But I did not understand what a Gateway is. Also it would be helpful if someone can also please explain the difference between Router and Gateway.

There isn’t a difference. A gateway is a router.

In a route table, there will be certain destinations that have the IP address of a gateway. These are routes to addresses that are not on the same network as the machine you are working on. Those requests get set to the gateway machine which consults its own route table to see if it knows the destination. If it does not, it sends the request on to the next gateway.

Your broadband router serves as the gateway on your home network. If you look at the route table on your laptop with either

  • route print on Windows or
  • netstat -rn on Mac

There, the default gateway entry is the IP of your broadband router.

The broadband router’s own default gateway entry in its route table will be some other router inside your ISP - and so on until finally a router is reached that knows the destination (e.g. webserver) you are trying to get to.

You can see most of the routers passed through to reach a final destination by running e.g.

  • tracert www.google.com on Windows
  • traceroute www.google.com on Mac

Some routers refuse to answer ICMP questions and respond with * Request timed out, so you get no details about that particular router in the chain.

Think of it like a subway ride. To get to destination Z, change at A, C, M., N and P where each change is another router

1 Like

Thank you very much @Alistair_KodeKloud for the detailed explanation. It helped.

In “Labs - Switching and Routing” under “Networking Basics” section, we’ve these 2 questions:

Q4: Which of the following is preferred device to connect two system which are on different networks?

For example, if System A is on 192.168.1.0/24 network and System B is on 192.168.2.0/24 network.

Q5: Can a gateway connect a system to the internet?

Q5 - is the reason for my post “Router vs Gateway”

Q4 is a router, because the router is a computer that has two network interfaces. In this example, one interface is connected to 192.168.1.0/24 and the other to 192.168.2.0/24 networks
Let us assume that this router machine has the addresses 192.168.1.1 for its connection to System A’s network, and 192.168.2.1 for its connection to System B’s network.
Then System A will have a route table entry that says

Destination       Gateway
192.168.2.0/24    192.168.1.1

And system B’s route table will say

Destination       Gateway
192.168.1.0/24    192.168.2.1

Q5 - the answer is Yes. It will do it using the subway train analogy above. This gateway will be a router acting as the “default” gateway - the one to go to when no other specific routes (like the system A and B above) satisfy the destination. A default gateway route table entry has

Destination
0.0.0.0/0

and the IP of the gateway router. This special destination means “anywhere not explicitly known”

1 Like