CCENT (ICND1)CCNA (ICND2)CCNA-ConfigsSwitching

Configuring an IP address and Default-Gateway on a Cisco Switch

Default GatewayThe configuration of an IP address and default-gateway on a switch is slightly different from a router. Firstly a router doesn’t have a default-gateway but rather a default route. A switch on the other hand can have a default-gateway, especially if the device is in layer 2 mode. If the switch is a multi-layer switch with routing enabled, then it will behave much like a router and have a default route.

On a router, IP addresses are configured on the physical interfaces, however on a switch the physical interfaces are Layer 2 and therefore cannot have have an IP addresses configured on them. This rule doesn’t apply if you are using a multi-layer switch and convert the port to a routed port using the no swithport command.

A switch does not need an IP address to be able to switch packets but in order for you to connect to the switch via telnet or SSH it needs to have a management IP address configured. Similarly, if you are connecting to the switch from a different subnet, the switch will require a default-gateway in order to have the packets routed back to you.

Since the IP address is not bound to any physical interface on the switch, it needs to be bound to a logical interface. On a switch the logical interface is known as a ‘vlan interface’ (VLAN – Virtual LAN). This is similar to a loopback interface found on a Cisco router.


Configuration used in live demo

AOIP.ORG_Switch# conf t

Enter global configuration mode

AOIP.ORG_Switch(config)# interface vlan 1

This enters the logical interface ‘vlan 1’. Vlan 1 is the native vlan and used for management purposes.

AOIP.ORG_Switch(config-if)# ip address

Assigns the IP address to the interface with subnet mask

AOIP.ORG_Switch(config-if)# no shut

Activates the interface

AOIP.ORG_Switch(config-if)# exit

Exit interface mode

AOIP.ORG_Switch(config)# ip default-gateway

Defines a default-gateway for this switch.


Live Demo



3 thoughts on “Configuring an IP address and Default-Gateway on a Cisco Switch

  1. wow thanks for the explanation! what does the output would be look like? for the switch’s ip default-gateway?

Leave a Reply

Your email address will not be published. Required fields are marked *