Okay, for this question-and-answer vlog I got a question from Remus.
He asks, What is the use of giving a default gateway to a switch using the IP default gateway command?
Okay Remus, here's the answer to the question. In this GNS3 topology I've got a router connected to a layer 3 switch which in turn is connected
to a layer 2 switch, a layer 3 switch has IP routing enabled.
In other words, it will route from VLAN 1 to VLAN 2 and back again, switch 2 is a layer 2 switch.
In other words, it doesn't have IP routing enabled.
So for the CCNA, this could be a 2950 switch or 2960 and this could be a 3750 or 3550 as
an example.
So on router 1, is router 1 able to ping switch 2? Answer is
no, the router is not able to ping switch 2.
What about trace and to speed things up I'm gonna type
no IP domain
look-up. So traceroute to 10.1.1.1
Okay so the traffic gets to switch 1 so it goes from router 1 to switch 1 10.1.2.2
54
and then the trace fails. So can i ping 10.1.254?
Yes, I can and I would have known that from the trace
but what I like to do is check the following.
Can router 1 ping this IP address on the other side
on switch 1.
Yes, it can.
So that means that the problem is not here.
The problem is somewhere on this side. So on switch, 1 can we ping switch 2?
The answer is yes.
On switch 2 can it ping switch 1 on VLAN 1?
Yes it can.
But can it ping across switch 1? Remember 1 was able to ping this IP address in VLAN 1. So
switch 1 is doing inter VLAN routing but can switch 2 ping switch 1 IP address in VLAN 2?
and it looks like it can't this is a very typical scenario where
you can't ping or telnet to a switch in a remote subnet.
Now on the switch when we use the command show IP route notice no default gateway has been set.
This means that IP writing has been disabled on the switch.
So what I need to do is type IP default gateway and point the switch to its default gateway. So show
IP route
notice default gateway set I'll do that command again there's the default gateway.
So on router 1 can we ping switch 2? Answer is yes.
So you need to configure a default gateway on a layer 2 switch.
In other words, a switch that hasn't got IP routing enabled to allow that switch to send traffic to remote
subnets. Traffic from router 1 could get to switch 2 but won't be able to get back again if switch
2 doesn't have a default gateway configured.
Now, this can get confusing if the switch is a Layer 3 switch or supports Layer 3 functionality.
Notice at the moment once again IP routing is disabled because we don't see a routing table here.
Show run pipe include IP route
Notice this command
no IP routing, IP routing was disabled on this switch.
That's a default on all the switches.
So IP routing, let's enable that do the show IP route
command again notice the output is very different.
Notice also that the gateway of last resort is not set.
So can router 1 ping switch 2? Answer is no, show run pipe include default.
We still have the IP default gateway command configured on the switch but because IP routing is enabled
that command is ignored.
So you only use the IP default gateway command when IP routing is disabled. So let's do that again,
No IP routing
pings succeeds, IP routing
ping fail.
So an IP routing is enabled like this.
What you need to do is you need to create a default route to your default gateway. So something like that
and now routing works.
So here's the thing to remember if IP routing is enabled on a switch you must use a static default route
like this or run a routing protocol. If IP routing is disabled
He used the IP default gateway command to allow a switch to send traffic to a remote subnet. Remus
I'm hoping that answers your question and I hope that helps everyone else.
Don't forget to ask questions in the comments below.
Please also look at the video and please subscribe.
I want to wish you all the very best.