Step 1 – Enter global configuration mode:
Step 2 – Enter interface configuration mode, and enter the VLAN to which the IP information is assigned. The range is 1 to 4094.
interface vlan <vlan-id>
Step 3 – Enter the IP address and subnet mask.
ip address <ip-address> <subnet-mask>
Step 4 – Return to global configuration mode.
Step 5 – Enter the IP address of the next-hop router interface that is directly connected to the switch where a default gateway is being configured. The default gateway receives IP packets with unresolved destination IP addresses from the switch.
ip default-gateway <ip-address>
Once the default gateway is configured, the switch has connectivity to the remote networks with which a host needs to communicate.
Note: When your switch is configured to route with IP, it does not need to have a default gateway set.
Step 6 – Return to privileged EXEC mode.
Step 7 – Verify the configured IP address.
show interfaces vlan <vlan-id>
Step 8 – Verify the configured default gateway.
show ip redirects
Step 9 – (Optional) Save your work in the configuration file.
copy running-config startup-config – OR – copy ru st – OR – wr mem