Switches are Layer – 2 devices of but that doesn’t mean that you can’t assign any ip addresses to a switch ! Surely IP is a Layer – 3 protocol and mostly used on Layer – 3 devices such as routers. Routers decide the best path via different algorithms according to IP routing protocol that is used for routing. They always check the source and destination IP addresses and make routing using that information.
Why We Assign IP Address To A Switch ?
Answer is very easy : For remote connection ! There are two types of connection that you can connect to a switch which are console and remote. If you don’t have chance to the same location of switch, you need to connect the devices remotely and manage them via SSH or Telnet. If you don’t assign an IP address of a switch, it is almost impossible to connect and manage it remotely. So that, network administrators assign an IP address and default gateway to switches.
How To Assign IP Address To A Switch ?
To assign an IP address to a switch, you need to configure the related management VLAN. You can’t assign IP address to a physical port like a router does. Here is the example configuration :
SWITCH_A(conf)#interface VLAN 30 SWITCH_A(conf-if)#ip address 10.21.23.15 255.255.255.0
How To Assign Default Gateway To A Switch ?
To assign a default gateway to a switch, you need to make the configuration on global config mode.
SWITCH_A(conf)#ip default-gateway 10.21.23.1