Configuration Example

In this example, the hostname and VLAN 1 IP address is configured, verified, and saved. This example assumes the session is initially unprivileged.

  1. Raise privilege level:

> enable
Password: ***

2.Enter global configuration mode:

#configure terminal

3.Input configuration commands. The IP address is set from within the

! VLAN interface submode:
(config)# hostname my-device
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

4.Leave global configuration mode and go back to Privileged Exec:

my-device(config)# end

5. Inspect and verify the configuration (some output omitted for brevity):

my-device# show running-config
Building configuration...
hostname my-device
username admin privilege 15 password encrypted
3ad61dc090116a16a7cc9861485e60e6407c5a328015b1985b585ab353c37a4441e034172401
528229795a5c9529dfbc04c86e01
!
vlan 1
name default
!
interface GigabitEthernet 1/1
!
interface GigabitEthernet 1/2
!
...
interface vlan 1
ip address dhcp fallback 172.16.1.2 255.255.0.0
!
...
end
! More verification: Display IP interfaces and assigned IP address and status:
my-device# show ip interface brief
Vlan Address Method Status
---- -------------------- -------- ------
1 172.16.1.15/24 DHCP UP
! An address was obtained from DHCP, so the fallback wasn’t used
! Try to inspect hostname:
my-device# show hostname
^
% Invalid word detected at '^' marker.
! No such command exists, but it is possible to extract a single line from
! running-config by using a filter:
my-device# show running-config | include hostname
hostname my-device

6. Save configuration to flash:

my-device# copy running-config startup-config
Building configuration...
% Saving 1272 bytes to flash:startup-config

Last updated