How to configuring default gateway on switch
Question:
I took some very good advice & signed up for the Cisco Learning Lab. The wording on the intial switch setup instructions & the default gateway is a little confusing.
For a switch the ip default-gateway command should be run in the global config mode, correct? The DG value should be for entire switch (any interface), not just vlan1, right?
Using Cisco labs I tried it both ways. Configuring it on vlan1 specifically displays it in the show running-config. Doing it in the global mode (not interface specific) results in no default gateway value displayed. This may be normal for the running-config, or just the way the lab works.
It wouldn't make sense to specify a DG value just for vlan1, would it?
Answer;
I may not be understanding you completely. The IP address configured as the next hop should be on the same subnet as the management vlan (vlan 1 by default). However, the configuration is not technically an interface command.
For example in Cisco WS-C3750X-48PF-S :
switch#config t
switch(config)#interface vlan 1
switch(config-if)#ip address 192.168.1.2 255.255.255.0
switch(config-if)#no shut
switch(config-if)#ip default-gateway 192.168.1.1
While the above will work, it is the equivalent of doing the following.
switch#config t
switch(config)#interface vlan 1
switch(config-if)#ip address 192.168.1.2 255.255.255.0
switch(config-if)#no shut
switch(config-if)#exit
switch(config)#ip default-gateway 192.168.1.1
A show run would look like the following in either case.
switch#show run
interface vlan 1
ip address 192.168.1.2 255.255.255.0
ip default-gateway 192.168.1.1
The output from my show command lost the indention due to the formatting on the site. In the output, you can see if something is a sub command by its indentation. I'll represent it as a "->" to show it below.
switch#show run
interface vlan 1
->ip address 192.168.1.2 255.255.255.0
ip default-gateway 192.168.1.1