Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

Why for Default Gateway IP address in Switch!!!

Hi All,

To assign an IP address to the management VLAN (default is VLAN 1)

Cmd are:

Switch(config)# interface vlan vlan-id

Switch(config-if)# ip address ip-address netmask

Switch(config-if)# ip default-gateway ip-address

Switch(config-if)# no shutdown

1.I can't understand why for the Default gateway address is needed in this. 2.Whether the Default Gateway should be in the same subnet as the IP address of the Management VLAN(ie., VLAN1)

Is the below cmd mandatory:

Switch(config-if)# ip default-gateway ip-address

Kindly help in this issue.

Thanks in Advance!!!!

Regards,

GuruPrasad.R

3 REPLIES
Bronze

Re: Why for Default Gateway IP address in Switch!!!

Morning GuruPrasad.R,

Good question. The default gateway servers the same purpose as a configured default gateway on a switch. If your intention is to manage the switch from a remote VLAN/subnet you must configure an IP default gateway who can forward the traffic between VLANs.

Similar to PC and IP gateway, proper configuration requires the default-gateway and switch IP to be in the same subnet.

One last thing, I believe the IP default-gateway is a global configuration command.

HTH,

Ryan

Bronze

Re: Why for Default Gateway IP address in Switch!!!

The default gateway needs to be in the same subnet as the Management VLAN. When the Mgmt. vlan needs to talk to anything within the same subnet, it issues an arp for the IP address to find the mac address so it can complete the packet build and establish communication. If it tried to do the same for something outside of its subnet, it would not get a response (in most situations). As such, it needs an IP to send info to for anything outside its subnet.

The ip default-gateway command is a global config command, not an interface config command. If you are using a multi-layer switch, it is better to use the

ip route 0.0.0.0 0.0.0.0

command. Hope this helps.

Hall of Fame Super Silver

Re: Why for Default Gateway IP address in Switch!!!

In answering this question I believe that we need to distinguish between a layer 2 switch and a layer 3 switch. A layer 3 switch with routing enabled does not need and does not use a default-gateway (but it will probably need a default route). A layer 2 switch does need and does use a default-gateway. A layer 2 switch has the same kind of IP stack as a PC. They layer 2 switch operates as an IP host on the network. As such it will ARP for addresses in its local subnet and will forward to its default gateway for addresses outside of its local subnet.

From that fact we can also answer the second part of the question: yes the default-gateway should be in the same subnet as the address configured on the switch.

HTH

Rick

250
Views
0
Helpful
3
Replies