cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
989
Views
40
Helpful
9
Replies

Default Gateway

Asfandyar70754
Level 1
Level 1

Hey guys,

I have starting recap of Routing and I have been using IP default gateway command on L2 switches but while doing lab I am not sure what it benefit is?

Can someone explain a bit under what scenarios this command is used.

9 Replies 9

you need this command to make sure you can access device's management IP from other networks.

Please rate this and mark as solution/answer, if this resolved your issue
Good luck
KB

Hi Kasun,

Thank you for your response. Can you elaborate it a bit. 

Hello,

consider the below example: Switch 1 is your access layer switch, with Vlan 99 being the management Vlan. Switch 2 is the distribution/core layer 3 switch:

Switch1

interface Vlan 99
ip address 192.168.99.2 255.255.255.0
!
ip default-gateway 192.168.99.1

Switch2

interface Vlan 99
ip address 192.168.99.1 255.255.255.0

So basically, the 'ip default-gateway' command is used to have connectivity for layer 2 devices...hope that makes sense.

you can configure management IP for switches. that IP can use to access switch remotely via telnet/SSH or web management. but when you access the switch IP from different network, switch should know a gateway to send different network return traffic. so we are configuring default gateway in switches.

Please rate this and mark as solution/answer, if this resolved your issue
Good luck
KB

Jon Marshall
Hall of Fame
Hall of Fame

 

It is so you can connect to and manage the switch from a remote subnet. 

 

If the device you were connecting to the switch from was in the same subnet you wouldn't need a default gateway but if it is in a different subnet the switch needs to know where to send the return traffic to and that is what it is for. 

 

Jon

As @Jon Marshall notes, it's how you inform the switch, as a host, what gateway to use for non-locally connected networks.  (Basically, the same as on a PC, when you configure its default-gateway.)  (I believe you wouldn't need to use if if the local gateway device was doing proxy ARP.)

Since you mention "I have starting recap of Routing . . .", you might also have used or seen usage of a default route on L3 switches.  That does for routing devices, much like default gateway does for non-routing devices.  On a L2 switch, transit traffic is forwarded L2, i.e. no need for a L3 address.  (Again, the default-gateway is for the switch, itself, as a host, to communicate with other devices on non-locally connected network.)

On a L3 routing device (i.e. L3 switch or router) the default route applies not only to locally generated device traffic, i.e. from the host device itself, but also to transit L3 traffic.

I recall (?) a Cisco L3 switch, when routing is enabled, default route will preempt default-gateway, but in theory, you could have both actively going to different next hops, i.e. again in theory, host generated traffic to default-gateway and transit L3 traffic to default route (assuming there's not a known destination network, or aggregate, better than the default).

Hello
The most simplistic way of understanding a L2 switch - is think to of it as a PC (single host device)
Just like a pc that requires a ip address/subnet mask/default-gateway to be able to communicate externally a L2 switch requires exactly the same.

PC/ L2 switch

ip addresss x.x.x.x
subnet mask x.x.x.x
default-gateway x.x.x.x


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

simple Lab two SW with and without GW, 
as you can see Router can telnet to both SW whatever GW is config.
BUT note the proxy-arp is not disable in Router and Router in same Subnet.
ghghghghgh.png

I would answer the original post by starting from some basic principles. A layer 2 switch forwards frames received from connected devices using mac addresses of source and destination. The layer 2 switch does not need any IP information for this forwarding to work. But the switch might want an IP address for management purposes (do you want to be able to telnet/ssh to the switch, do you want the switch to be able to send log messages to a syslog server, do you want the switch to be able to communicate with a network management server). So you could configure a vlan interface with an IP address for one of the vlans. For example

interface vlan 100

ip address 192.168.100.10 255.255.255.0

This would allow the layer 2 switch to communicate with any device that is in network 192.168.100.0. But how could the switch communicate with anything in a different network? To access destinations in remote networks you need to use the ip default-network command.

HTH

Rick
Review Cisco Networking products for a $25 gift card