What is a default gateway

This topic is to discuss the following lesson:

https://networklessons.com/cisco/ccna-routing-switching-icnd1-100-105/what-is-a-default-gateway/

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

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

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

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

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

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

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

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

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

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

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

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

Hi Emmanuel,

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

R1(config)#interface FastEthernet 0/0
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#no shutdown
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

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.

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

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.

Hi Rene,

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

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

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

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.