Set VLAN 1 IP Address

The objective is to assign an IP address to the device on VLAN 1. This is often sufficient for small local area networks that use Dynamic Host Configuration Protocol (DHCP) or static IP address allocation. The system implements a DHCP client that, once enabled, will send out requests for IP address configuration. Those requests are received by a DHCP server on the network (if present and appropriately configured). The server will then search through its pool of available IP addresses, allocate one, and return it to the DHCP client. The returned information typically includes IP address, netmask, and default gateway, but may also contain other information such as Domain Name Service (DNS) server addresses. The configuration proceeds in the same manner as setting the hostname: Enter configuration mode, input and execute configuration commands, leave configuration mode. The following commands instruct the device to use DHCP to obtain an IP address, or, if DHCP fails, to use a static fallback address. Inclusion of a fallback IP is optional and may be omitted.

my-device# configure terminal
my-device(config)# interface vlan 1
my-device(config-if-vlan)# ip address dhcp fallback 172.16.1.2 255.255.0.0
my-device(config-if-vlan)# exit
my-device(config)#

Notice how the prompt changes; the interface vlan 1 command enters a configuration sub-mode that allows, among other things, configuration of IP address. Also note that IP addresses can only be assigned to VLAN interfaces. After configuration is complete, the resulting IP address can be inspected. As seen below, the DHCP negotiation succeeded and the device obtained an address:

my-device# show ip interface brief
Vlan Address Method Status
---- -------------------- -------- ------
1 172.16.1.17/16 DHCP UP
my-device#

show ip interface brief displays all configured and active IP interfaces. The status should be UP. If it isn’t, then the reason could be that there is no link on any port. If DHCP negotiation failed then the fallback IP of 172.16.1.2/255.255.0.0 would be assigned. Now the most basic system configuration is complete. Management connectivity can be verified by issuing a ping command to a well-known external IP address:

my-device# ping ip 172.16.1.1
PING server 172.16.1.1, 56 bytes of data.
64 bytes from 172.16.1.1: icmp_seq=0, time=0ms
64 bytes from 172.16.1.1: icmp_seq=1, time=0ms
64 bytes from 172.16.1.1: icmp_seq=2, time=0ms
64 bytes from 172.16.1.1: icmp_seq=3, time=0ms
64 bytes from 172.16.1.1: icmp_seq=4, time=0ms
Sent 5 packets, received 5 OK, 0 bad
my-device#

If the ping is successful, network logins can now be performed through telnet or ssh to the address on VLAN interface 1, 172.16.1.17 (or 172.16.1.2).

Last updated