Configure an IP address on a switch

By default, Cisco switches forward Ethernet frames without any configuration. This means that you can buy a Cisco switch, plug in the right cables to connect various devices to the switch, power it on, and the switch will work properly.

However, to perform switch management over the network or use protocols such as SNMP, the switch will need to have an IP address. The IP address is configured under a logical interface, known as the management domain or VLAN. Usually, the default VLAN 1 acts like the switch’s own NIC for connecting into a LAN to send IP packets. Here are the steps to configure an IP address under VLAN 1:

  1. enter the VLAN 1 configuration mode with the interface vlan 1 global configuration command.
  2. assign an IP address with the ip address IP_ADDRESS SUBNET_MASK interface subcommand.
  3. enable the VLAN 1 interface with the no shutdown interface subcommand.
  4. (Optional) use the ip default-gateway IP_ADDRESS global configuration command to configure the default gateway.
  5. (Optional) Add the ip name-server IP_ADDRESS global configuration command to configure the DNS server.

 

Here is a simple example network:

Configure IP address on a switch example network

We have a simple network of a host and a switch. We can assign the switch with an IP address to enable IP communication between the two devices:

SW1(config)#int vlan 1
SW1(config-if)#
SW1(config-if)#
SW1(config-if)#ip address 10.0.0.2 255.0.0.0
SW1(config-if)#no shutdown

SW1(config-if)#
%LINK-5-CHANGED: Interface Vlan1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up

To verify the IP address set on a switch, we can use the show int vlan 1 command:

SW1#show int vlan 1
Vlan1 is up, line protocol is up
Hardware is CPU Interface, address is 0030.a3e8.6b3c (bia 0030.a3e8.6b3c)
Internet address is 10.0.0.2/8
....

We can verify that the host can reach the switch using its IP address by pinging it from Host A:

C:\>ping 10.0.0.2

Pinging 10.0.0.2 with 32 bytes of data:

Reply from 10.0.0.2: bytes=32 time<1ms TTL=255
Reply from 10.0.0.2: bytes=32 time<1ms TTL=255
...
upravnik