Ip routing vs. Ip default-gateway
When we talk about cisco switches the "ip routing" and "default-gateway" is two common commands that we use for configure the routing info. But if you didn't use this 2 carefully it can cause some serious routing issues. You cannot use both of this in same time in any switches.
Use of default-gateway
To define a default gateway (router) when IP routing is disabled, use the ip default-gateway global configuration command. To disable this function, use the no form of this command.
ip default-gateway ip-address
ex : ip default-gateway 172.16.15.4
this command is used in layer 2 switches to define the default gateway of it.
In here we define what is the gateway for this range of ips since layer 2 switch donot have any routing capabilities itself.
Use of ip routing
Since the introduce of layer 3 switches it added the routing capabilities to the switch. Which means layer 3 switch also can act as router by default.
ip routing is not enabled by default in layer 3 switch so it will not find any routing details. To enable it all you need to do is goto configuration terminal and type
but before do this you need to make sure that you do not have default-gateway setup on there. If you have enable ip routing while default-gateway configured you will lost access to the switch. Its more important if you connect remotely.
What are the issues if you have configured default-gateway in layer 3 switch?
If you have different class of ips configured on switch this will cause lot of issues. For example lets say in your layer 3 switch you have different class as main ip and different class for the ports. Then you have requirement to break it to vlans. Then you break it to sub nets and create new vlans and assign it to one of user pc or server. So in here you will only able to ping to the its gateway ip ( vlan interface ip ) and you will not be able to ping to any other. And also in server or pc end it will not be able to access internet or ping to any. Its because the switch do not getting any routing information about these. So to fix it you have to disable default-gateway with no default-gateway command and then enable ip routing
if any questions please feel free to ask me on firstname.lastname@example.org