What is a default gateway

When a host wants to reach a destination that is outside of its own network, it has to use a default gateway. We use a router or multilayer switch (that’s a switch that can do routing) as a default gateway.

In this lesson I’ll explain how a host knows when to use the default gateway or not and how it works behind the scenes. Let’s start with a simple example:

two hosts same subnet

Above we have two hosts connected to a switch. We only have network 192.168.1.0 with subnet mask 255.255.255.0.

When one host wants to send something to another host then it will check if the destination is inside or outside its own network. When the destination is in the same network then it will use ARP to find the MAC address of the destination and it can send the IP packet. How does the host check if the destination is in the same network? This is done by checking the subnet mask. For example, let’s say that 192.168.1.1 wants to send an IP packet to 192.168.1.2:

Source 192.168.1.1 11000000 10101000 00000001 00000001
Destination 192.168.1.2 11000000 10101000 00000001 00000010
Subnet mask 255.255.255.0 11111111 11111111 11111111 00000000

The subnet mask tells us which part of the IP address is the network and host part, the host that uses 192.168.1.1 sees that 192.168.1.2 is using the exact same network address and will know that it can use ARP to find the MAC address, create an Ethernet frame, encapsulate the IP packet and send it towards the switch.

Now let’s take a look at an example where we do require a default gateway. Take a look at this picture:

We're Sorry, Full Content Access is for Members Only...

If you like to keep on reading, Become a Member Now! Here is why:

  • Learn any CCNA, CCNP and CCIE R&S Topic. Explained As Simple As Possible.
  • Try for Just $1. The Best Dollar You've Ever Spent on Your Cisco Career!
  • Full Access to our 660 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

505 Sign Ups in the last 30 days

satisfaction-guaranteed
100% Satisfaction Guaranteed!
You may cancel your monthly membership at any time.
No Questions Asked!

Tags: ,


Forum Replies

  1. This is best explained with the following two captures:

    https://networklessons.com/wp-content/uploads/2015/12/wireshark-capture-arp-request.png

    Above you can see the ARP request. The sender (fa:16:3e:38:94:94) creates the ARP request and is looking for 192.168.12.2. It encapsulates this in an Ethernet frame with its own MAC address as the source and destination broadcast.

    Everyone on the subnet will hear this message, the device that has the destination MAC address will reply:

    //cdn-forum.networklessons.com/uploads/default/original/2X/9/9f60d1190267be572f382a07

    ... Continue reading in our forum

  2. sir , for the scenario
    Computer A ——-Switch1—–ROUTER1——————ROUTER 2 —- Switch2 —– Computer B.

    you said that

    "Computer A will do an ARP request for the IP address of Router 1

    Computer B will do an ARP request for Router 2 (its default gateway).

    Router 1 and Router 2 will do ARP requests on the link that connects them to discover each others MAC addresses."

    please rectify/guide me if i am worng
    computer A will send ARP request to R1 to know R1 MAC address, so whenever it sends send data to ComputerB it will then send it to MAC address of R1.

    sir my second query i

    ... Continue reading in our forum

  3. Hi.

    Router A wants to know MAC address of router B. So, it broadcasts ARP. Only router B replies.
    In this case, target MAC should be FF:FF:FF:FF:FF:FF which is broadcastin ARP request. Why the target MAC is all 0’s in ARP request?

  4. Thanks Lazaros, your explanation has been very useful. Now is more clear for me.

  5. Hi Braulio,

    Every device that has an IP address builds an ARP table. They somehow need to map a L3 IP address to a L2 MAC address.

    A computer (host) will have an ARP table. A switch that you configure with an IP address for remote management also has an ARP table.

    Rene

101 more replies! Ask a question or join the discussion by visiting our Community Forum