# What is a default gateway

**URL:** https://forum.networklessons.com/t/what-is-a-default-gateway/1267
**Category:** Lessons Discussion
**Created:** [December 29, 2016, 7:51pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267 "2016-12-29T19:51:24Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [December 29, 2016, 7:51pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/1 "2016-12-29T19:51:24Z")

</div>

This topic is to discuss the following lesson:

> **[What is a default gateway](https://networklessons.com/ip-routing/what-is-a-default-gateway)**
>
> This lesson explains why we need a default gateway and how a host decides when to use it or not.

---

<div class="post-metadata">

### Author: ![shinuvarghesea](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@shinuvarghesea](https://forum.networklessons.com/u/shinuvarghesea)
#### Post date: [July 14, 2015, 5:21pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/2 "2015-07-14T17:21:36Z")

</div>

What if i have 2 network interface card on my host system with two different default gateway IP address configured.

Host will use which default gateway to forward the traffice. ??

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [July 14, 2015, 6:15pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/3 "2015-07-14T18:15:26Z")

</div>

Hi Shinu,

It will depend on the host but Windows for example uses a metric to determine which default gateway to pick.

Try a “route print” on a Windows machine when it’s connected with two network interfaces and has default gateways. You can see which default gateway it will prefer.

Rene

---

<div class="post-metadata">

### Author: ![chris.m.chavez](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/c/58f4c7/32.png) [@chris.m.chavez](https://forum.networklessons.com/u/chris.m.chavez)
#### Post date: [July 20, 2015, 2:28am UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/4 "2015-07-20T02:28:14Z")

</div>

Rene,

Hello, normally I use the command  
`ip route 0.0.0.0 0.0.0.0`  
to define the default route, but there is another command,  
`ip default-gateway`  
also. What is the difference between the two commands?

Thanks,

Chris

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [July 20, 2015, 12:34pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/5 "2015-07-20T12:34:20Z")

</div>

Hi Chris,

IP route is used on a router to enter something in its routing table. The effect will be the same…

Devices like switches don’t build a routing table so that’s when you need to use the ip default-gateway command. Also, on a router you can use it if you disable the routing table with “no ip routing”.

Rene

---

<div class="post-metadata">

### Author: ![mlomeli](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@mlomeli](https://forum.networklessons.com/u/mlomeli)
#### Post date: [January 8, 2016, 7:36pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/6 "2016-01-08T19:36:08Z")

</div>

Hi Rene,

I have a question. Does the ARP table at Host A keep an entry for each non-local IP address to the Router’s MAC address, or it will keep only one entry relating the Router’s interface IP address to its MAC address?

Thanks

Miguel

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [January 11, 2016, 1:32pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/7 "2016-01-11T13:32:08Z")

</div>

Hi Miguel,

In the ARP table you only find MAC addresses of devices in the same subnet. When your PC wants to reach something that it not in the same subnet then it will send it to the default gateway. You will only find one entry in the ARP table for everything that is not in your own subnet: the router MAC and IP address, that’s it.

Rene

---

<div class="post-metadata">

### Author: ![svvdprasad](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@svvdprasad](https://forum.networklessons.com/u/svvdprasad)
#### Post date: [March 21, 2016, 7:35am UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/8 "2016-03-21T07:35:09Z")

</div>

Hi Rene,

I was reading your lessons since one month onwards thanks for great explanation…

I have one small query

HOST — SWITCH — HOST  
10.10.10.2 — SWITCH ---- 20.20.20.2 / 24

will ping work for above scenario … My answer would be No … Since we can’t add the default gateway is that correct answer…

Tried this scenario on GNS,while connecting the host to switch via Ethernet cable it’s throwing error so i thought we could not able to configure Default gateway  
it’s throwing an error.

Please help me in understanding this

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [March 21, 2016, 2:03pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/9 "2016-03-21T14:03:53Z")

</div>

Hi Durga,

It depends on the switch that you are using. If it’s an L2 switch then the only thing it does for your is “switching”. It will forward Ethernet frames based on the destination MAC address for different VLANs and that it’s.

If you want to use the switch as your default gateway, then it has to be an L3 switch (multilayer switch). This means that it can do routing.

This lesson might help:

[InterVLAN Routing](https://networklessons.com/switching/intervlan-routing/)

The first example with the “router on a stick” is used when you have a L2 switch. The “SVI (Switch Virtual Interface)” example is for a L3 switch.

Hope this helps!

Rene

---

<div class="post-metadata">

### Author: ![svvdprasad](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@svvdprasad](https://forum.networklessons.com/u/svvdprasad)
#### Post date: [March 21, 2016, 2:29pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/10 "2016-03-21T14:29:03Z")

</div>

Hi Rene,

if it is L2 switch what will happen if i ping to 10.10.10.2 to 20.20.20.2

HOST — SWITCH — HOST  
10.10.10.2/24 — SWITCH —- 20.20.20.2 / 24

will i be able configure default gateway … Please help me in understanding

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [March 21, 2016, 3:00pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/11 "2016-03-21T15:00:42Z")

</div>

Hi Durga,

Here’s what will happen:

1. Your PC will check its own IP address and subnet mask and the destination IP address. It comes to the conclusion that the destination IP address it outside of its own subnet so it has to use the default gateway.
2. If a default gateway has been configured then the computer will do an ARP for the IP address of the default gateway.
3. If there is no default gateway then the computer will be unable to send the IP packet.

In other words, your computer requires a default gateway otherwise it won’t even send the packet. You’ll need an IP address that you can use as a default gateway (router or SVI interface on L3 switch for example).

Rene

---

<div class="post-metadata">

### Author: ![ukpongudo28](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/u/5e9695/32.png) [@ukpongudo28](https://forum.networklessons.com/u/ukpongudo28)
#### Post date: [March 28, 2016, 12:50am UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/12 "2016-03-28T00:50:43Z")

</div>

Thanks for the explanation on default gateway. but my question is, what are the commands to configure the two interfaces of the Ethernet port?

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [March 28, 2016, 11:46am UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/13 "2016-03-28T11:46:42Z")

</div>

Hi Emmanuel,

Here’s how you can do this on a Cisco IOS router:

```auto
R1(config)#interface FastEthernet 0/0
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#no shutdown

```

```auto
R1(config)#interface FastEthernet 0/1
R1(config-if)#ip address 192.168.2.254 255.255.255.0
R1(config-if)#no shutdown

```

Rene

---

<div class="post-metadata">

### Author: ![matthew.wilson](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/matthew.wilson/32/249_2.png) [@matthew.wilson](https://forum.networklessons.com/u/matthew.wilson)
#### Post date: [April 8, 2016, 12:48pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/14 "2016-04-08T12:48:48Z")

</div>

I also like to set the speed to the required value and the duplex to full (we don’t use half duplex anymore) when configuring an interface. Leaving them at the defaults (auto) can cause problems in some circumstances. Also set switchports to mode access. Security best practise is to leave unused interfaces in the administratively set shutdown state.

---

<div class="post-metadata">

### Author: ![abids.mrd](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/a/47e85d/32.png) [@abids.mrd](https://forum.networklessons.com/u/abids.mrd)
#### Post date: [May 26, 2016, 6:30pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/15 "2016-05-26T18:30:20Z")

</div>

sir  
on query

“HOST — SWITCH — HOST  
10.10.10.2 — SWITCH —- 20.20.20.2 / 24”

you replied

" t depends on the switch that you are using. If it’s an L2 switch then the only thing it does for your is “switching”. It will forward Ethernet frames based on the destination MAC address for different VLANs and that it’s."

sir my query is that  
" on L2 switch if switch doesn’t connected with Router , communication between different vlans ( if all vlans reside/created on single L2 switch) is not possible , am i right? "  
thanking you in anticipation

---

<div class="post-metadata">

### Author: ![andrew](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/andrew/32/645_2.png) [@andrew](https://forum.networklessons.com/u/andrew)
#### Post date: [May 26, 2016, 7:49pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/16 "2016-05-26T19:49:34Z")

</div>

Muhammad,  
You are correct. Devices in two different VLANs require a layer 3 device in order to communicate. That could be a router, or a Layer 3 switch. If you have only, a layer 2 switch, communication would not happen.

---

<div class="post-metadata">

### Author: ![shreekumar001](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/s/e47c2d/32.png) [@shreekumar001](https://forum.networklessons.com/u/shreekumar001)
#### Post date: [May 28, 2016, 4:10am UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/17 "2016-05-28T04:10:01Z")

</div>

Hi Rene,

I have two default gateways defined. Each of them are connected to two different ISPs. Now, if I type [google.com](http://google.com) in my browser, which gateway is selected and why?

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [May 30, 2016, 9:04pm UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/18 "2016-05-30T21:04:37Z")

</div>

Hi Shree,

It depends on the operating system. Windows for example uses a metric to choose between different default routes. A LAN interface will have a better metric than a wifi interface.

You can see this in the routing table btw, try the “route print” command from the Windows command prompt and you’ll see it.

Rene

---

<div class="post-metadata">

### Author: ![samsu2k1](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/s/9de0a6/32.png) [@samsu2k1](https://forum.networklessons.com/u/samsu2k1)
#### Post date: [October 4, 2016, 1:50am UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/19 "2016-10-04T01:50:36Z")

</div>

Hi,

Can some one explain me the packet switching in step by step for the below scenarios.

1. Different Network :

Host A --------------- Switch -----------Router --------- Switch ---------- Host B  
192.168.1.1/24 10.10.10.1/24

1. Same Network :

Host A --------------- Switch -----------Router --------- Switch ---------- Host B  
192.168.1.1/24 192.168.1.2/24

Thanks

---

<div class="post-metadata">

### Author: ![maher1](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@maher1](https://forum.networklessons.com/u/maher1)
#### Post date: [October 4, 2016, 7:33am UTC](https://forum.networklessons.com/t/what-is-a-default-gateway/1267/20 "2016-10-04T07:33:57Z")

</div>

Hi Kaja,

In your case 1, if you mean that IP’s (which are on different subnet) are for HostA and HostB then the 2 hosts can reach each others because there is a Router in between which is L3 device, assuming that you have correct IP sets on the connected routers interfaces and correct IP gateway on each of the Hosts.

In your case 2, and again if you mean that IP’s are for HostA and HostB then this will not work because a Router cannot have on 2 of its interfaces the same range of IP.

Hope I could answer your question.

[Next page](https://forum.networklessons.com/t/what-is-a-default-gateway/1267.md?page=2)
