Lessons · Network switches · the default gateway
Reaching it from another subnet
`ip default-gateway` tells the switch where to send replies that are going outside its own subnet.
Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.
What it is for
Without it a switch answers anything on its own network and nothing from anywhere else, which looks exactly like a firewall problem and is not.
How to think about it
Set it to the router's address in the management VLAN. The test is whether somebody on a different subnet can reach the switch, not whether you can.
Worked example
enableThe # prompt.
configure terminalInto configuration mode.
interface vlan 1The management interface.
ip address 192.168.10.2 255.255.255.0An address on the management network.
exitBack to (config)#, because the gateway is a global setting, not an interface one.
ip default-gateway 192.168.10.1The router. Replies to anywhere outside 192.168.10.0/24 now have somewhere to go.
endOut.
show running-configBoth lines are there: the address under interface Vlan1, the gateway on its own at the bottom.
Your turn
Point the switch at the router at 192.168.10.1.
ip 192.168.10.1
Console into a switch
The trap
Setting it inside `interface vlan 1`. It is global, and typing it in the wrong mode gives an invalid-input error that reads as though the command does not exist.