Cisco IOS command guide

Every command the free NanoTech-kw Network Lab understands - 177 commands in 28 categories, each with its mode and an example. Try any of them on a simulated router or switch.

â–¶ Open the free Network Lab
Modes & navigationBasic device setupIPv4 addressingVLANs & trunkingInter-VLAN routingStatic routingOSPFEIGRPRIPDHCPNAT / PATACLsIPv6VerificationPC / server promptSpanning TreeEtherChannelHSRPSecurityRemote accessServicesConsoleOutput filtersSave & reloadHuawei / HP-H3C (VRP, Comware)Dell OS10Aruba AOS-CXTips

Modes & navigation

enableuser

Enter privileged EXEC mode (prompt changes from > to #).

Example: enable
disablepriv

Return to user EXEC mode.

Example: disable
configure terminalpriv

Enter global configuration mode.

Example: conf t
exitany config

Go back one mode level.

Example: exit
endany config

Return straight to privileged EXEC mode.

Example: end
do <command>any config

Run an EXEC command (show, ping…) without leaving configuration mode.

Example: do show ip interface brief
? / helpany

List the commands available in the current mode.

Example: ?
copy running-config startup-configpriv

Save the configuration (labs are saved automatically too).

Example: wr
clearpriv

Clear the terminal screen.

Example: clear

Basic device setup

hostname <name>config

Rename the device.

Example: hostname HQ-R1
interface <type><number>config

Enter interface configuration mode. Short forms work: g0/0, fa0/1, s0/0/0, g0/0/1.

Example: int g0/0
description <text>config-if

Label an interface.

Example: description Link to SW1
shutdownconfig-if

Administratively disable the interface.

Example: shutdown
no shutdownconfig-if

Enable the interface (router ports start shut down).

Example: no shut
speed / duplexconfig-if

Accepted for compatibility (no effect in the simulator).

Example: speed 100

IPv4 addressing

ip address <ip> <mask>config-if

Set the interface's IPv4 address.

Example: ip address 192.168.1.1 255.255.255.0
no ip addressconfig-if

Remove the IPv4 address.

Example: no ip address
ip default-gateway <ip>config

Layer-2 switch: default gateway for its management SVI.

Example: ip default-gateway 192.168.1.1

VLANs & trunking

vlan <id>config

Create a VLAN and enter VLAN mode.

Example: vlan 10
name <text>config-vlan

Name the VLAN.

Example: name Sales
no vlan <id>config

Delete a VLAN (VLAN 1 can't be deleted).

Example: no vlan 20
switchport mode accessconfig-if

Make the port an access port (one VLAN).

Example: switchport mode access
switchport access vlan <id>config-if

Put an access port in a VLAN.

Example: sw acc vlan 10
switchport mode trunkconfig-if

Carry all VLANs (802.1Q tagged, native VLAN 1) to another switch or a router.

Example: switchport mode trunk
switchport trunk encapsulation dot1qconfig-if

Accepted for compatibility with 3560/3650 switches.

Example: switchport trunk encapsulation dot1q
show vlan briefpriv

List VLANs and their access ports.

Example: show vlan brief
show interfaces trunkpriv

List trunk ports and their state.

Example: show interfaces trunk

Inter-VLAN routing

interface <port>.<n>config

Router: create a subinterface (router-on-a-stick).

Example: int g0/0.10
encapsulation dot1Q <vlan>config-subif

Tie the subinterface to a VLAN tag.

Example: encapsulation dot1Q 10
interface vlan <id>config

Switch: create a VLAN interface (SVI). It starts shut down.

Example: int vlan 10
ip routingconfig

Layer-3 switch: route between its SVIs / routed ports.

Example: ip routing
no switchportconfig-if

Layer-3 switch: turn the port into a routed port that takes an IP address.

Example: no switchport
no interface <name>config

Remove a subinterface or SVI.

Example: no int g0/0.10

Static routing

ip route <net> <mask> <next-hop>config

Add a static route via a next-hop address.

Example: ip route 192.168.2.0 255.255.255.0 10.0.0.2
ip route <net> <mask> <exit-if>config

Static route out of an interface (good for serial links).

Example: ip route 0.0.0.0 0.0.0.0 s0/0/0
ip route 0.0.0.0 0.0.0.0 <next-hop>config

Default route (gateway of last resort).

Example: ip route 0.0.0.0 0.0.0.0 203.0.113.1
ip route <net> <mask> <next-hop> <distance>config

Floating static route (backup with a higher distance).

Example: ip route 10.0.0.0 255.0.0.0 10.1.1.2 200
no ip route <net> <mask>config

Remove a static route.

Example: no ip route 192.168.2.0 255.255.255.0

OSPF

router ospf <process-id>config

Start OSPF and enter router mode.

Example: router ospf 1
network <net> <wildcard> area <id>config-router

Run OSPF on interfaces inside this range.

Example: network 192.168.1.0 0.0.0.255 area 0
passive-interface <if>config-router

Advertise the network but send no hellos on the interface.

Example: passive-interface g0/2
default-information originateconfig-router

Advertise this router's default route to OSPF neighbours.

Example: default-information originate
router-id <ip>config-router

Set the OSPF router ID.

Example: router-id 1.1.1.1
no router ospf <id>config

Remove OSPF.

Example: no router ospf 1
show ip ospf neighborpriv

List OSPF neighbours (FULL state).

Example: show ip ospf neighbor

EIGRP

router eigrp <as-number>config

Start EIGRP; neighbours must use the same AS number.

Example: router eigrp 100
network <net> [wildcard]config-router

Run EIGRP on matching interfaces (no wildcard = the whole classful network).

Example: network 10.0.0.0 0.0.0.255
passive-interface <if>config-router

Advertise the network but form no neighbours on it.

Example: passive-interface g0/2
no router eigrp <as>config

Remove EIGRP.

Example: no router eigrp 100
show ip eigrp neighborspriv

EIGRP neighbours.

Example: show ip eigrp neighbors
show ip eigrp topologypriv

Successors and feasible distances.

Example: show ip eigrp topology

RIP

router ripconfig

Start RIP and enter router mode.

Example: router rip
version 2config-router

Use RIPv2.

Example: version 2
network <classful-net>config-router

Run RIP on interfaces in this classful network.

Example: network 192.168.1.0
no auto-summaryconfig-router

Accepted (RIPv2 best practice).

Example: no auto-summary
passive-interface <if>config-router

Don't send RIP updates out of the interface.

Example: passive-interface g0/1
show ip protocolspriv

Show running routing protocols and their networks.

Example: show ip protocols

DHCP

ip dhcp pool <name>config

Create a DHCP pool on the router and enter dhcp-config mode.

Example: ip dhcp pool LAN
network <net> <mask>config-dhcp

Subnet the pool hands addresses from.

Example: network 192.168.1.0 255.255.255.0
default-router <ip>config-dhcp

Gateway given to clients.

Example: default-router 192.168.1.1
dns-server <ip>config-dhcp

DNS server given to clients.

Example: dns-server 8.8.8.8
ip dhcp excluded-address <first> [last]config

Addresses the pool must never hand out.

Example: ip dhcp excluded-address 192.168.1.1 192.168.1.9
ip helper-address <server-ip>config-if

Relay DHCP broadcasts from this subnet to a server on another subnet.

Example: ip helper-address 10.0.0.10
show ip dhcp bindingpriv

Show addresses leased to clients.

Example: show ip dhcp binding

NAT / PAT

ip nat insideconfig-if

Mark the LAN-side interface.

Example: ip nat inside
ip nat outsideconfig-if

Mark the Internet-side interface.

Example: ip nat outside
ip nat inside source list <acl> interface <if> overloadconfig

PAT: translate addresses permitted by the ACL to the outside interface's address.

Example: ip nat inside source list 1 interface g0/0 overload
ip nat inside source static <local> <global>config

Static NAT: publish an inside host on a public address.

Example: ip nat inside source static 192.168.1.10 203.0.113.5
show ip nat translationspriv

Show NAT entries created by traffic.

Example: show ip nat translations

ACLs

access-list <1-99> permit|deny <source>config

Standard ACL: match by source only. Source: any | host <ip> | <ip> <wildcard>.

Example: access-list 1 permit 192.168.1.0 0.0.0.255
access-list <100-199> permit|deny <proto> <src> <dst>config

Extended ACL: protocol ip | icmp | tcp | udp, source and destination.

Example: access-list 100 deny icmp host 192.168.1.10 host 192.168.2.100
access-list <n> permit ip any anyconfig

Allow everything else (ACLs end with an implicit deny).

Example: access-list 100 permit ip any any
ip access-group <n> in|outconfig-if

Apply an ACL to an interface in one direction.

Example: ip access-group 100 in
no access-list <n>config

Delete an ACL.

Example: no access-list 100
show access-listspriv

Show all ACLs and their entries.

Example: show access-lists

IPv6

ipv6 unicast-routingconfig

Enable IPv6 routing on a router.

Example: ipv6 unicast-routing
ipv6 address <addr>/<len>config-if

Set an IPv6 address.

Example: ipv6 address 2001:db8:1::1/64
no ipv6 addressconfig-if

Remove the IPv6 address.

Example: no ipv6 address
ipv6 route <prefix>/<len> <next-hop>config

IPv6 static route.

Example: ipv6 route 2001:db8:2::/64 2001:db8:12::2
show ipv6 interface briefpriv

IPv6 addresses per interface.

Example: show ipv6 int br
show ipv6 routepriv

IPv6 routing table.

Example: show ipv6 route
ipconfig /renew6host

Get an IPv6 address automatically (SLAAC) from the router's advertisement.

Example: ipconfig /renew6
ipv6 router ospf <id>config

Start OSPFv3.

Example: ipv6 router ospf 1
ipv6 ospf <id> area <n>config-if

Run OSPFv3 on this interface.

Example: ipv6 ospf 1 area 0
show ipv6 ospf neighborpriv

OSPFv3 neighbours.

Example: show ipv6 ospf neighbor

Verification

show ip interface briefpriv

Every interface with its IP, status and protocol.

Example: sh ip int br
show ip routepriv

IPv4 routing table (C, L, S, O, R codes).

Example: show ip route
show running-configpriv

The whole current configuration.

Example: sh run
show cdp neighborspriv

Directly connected Cisco devices.

Example: show cdp neighbors
show versionpriv

Model and interface count.

Example: show version
ping <ip>user/priv

Send 5 echo requests; the packet is animated and logged.

Example: ping 192.168.2.10
traceroute <ip>user/priv

List each router on the path.

Example: traceroute 192.168.2.10
show mac address-tablepriv

Which MAC addresses the switch learned on which port.

Example: show mac address-table
show arppriv

IP-to-MAC mappings the router knows.

Example: show arp
show interfaces <if>priv

Detailed status, MAC, IP, bandwidth and packet counters.

Example: show interfaces g0/0
show ip interface <if>priv

IP settings of one interface (helper, ACLs, NAT).

Example: show ip interface g0/0
show interfaces descriptionpriv

Status and descriptions of all interfaces.

Example: show interfaces description
show running-config interface <if>priv

Configuration of one interface.

Example: show run int g0/0
show ip route <ip> | static | connected | ospf | rippriv

Look up one destination, or one route type.

Example: show ip route 192.168.2.10
ping <ip> repeat <n> size <n> source <ip|if>user/priv

Extended ping, e.g. from a loopback.

Example: ping 10.0.0.2 source lo0 repeat 10
show history / show clock / show flashpriv

Recent commands, the time, the files in flash.

Example: show history

PC / server prompt

ipconfighost

Show the IP address, mask and gateway.

Example: ipconfig
ipconfig /allhost

Also MAC address, DHCP and DNS settings.

Example: ipconfig /all
ipconfig /renewhost

Get an address from DHCP.

Example: ipconfig /renew
ipconfig /releasehost

Give the DHCP address back.

Example: ipconfig /release
ping <ip | name>host

Test reachability (names need a DNS server).

Example: ping 192.168.1.1
tracert <ip | name>host

Show the routers on the path.

Example: tracert 192.168.2.10
nslookup <name>host

Ask the DNS server for a name.

Example: nslookup intranet.local
arp -ahost

Neighbours on the same subnet with their MAC addresses.

Example: arp -a
clshost

Clear the screen.

Example: cls

Spanning Tree

show spanning-treepriv

Root bridge, this switch's ports, their role (Root/Desg/Altn) and state (FWD/BLK).

Example: show spanning-tree
spanning-tree vlan <id> priority <n>config

Lower priority wins the root election (multiples of 4096).

Example: spanning-tree vlan 1 priority 4096
spanning-tree vlan <id> root primaryconfig

Make this switch the root bridge (priority 24576).

Example: spanning-tree vlan 1 root primary
spanning-tree portfastconfig-if

Edge port for a single host - skips listening/learning.

Example: spanning-tree portfast
spanning-tree bpduguard enableconfig-if

Err-disable the port if a switch is plugged into it.

Example: spanning-tree bpduguard enable

EtherChannel

interface range <ports>config

Configure several ports at once.

Example: interface range fa0/1 - 2
channel-group <n> mode active|passive|on|desirable|autoconfig-if

Bundle ports into one logical link. LACP: active/passive, PAgP: desirable/auto, static: on.

Example: channel-group 1 mode active
show etherchannel summarypriv

Bundles and their member ports (P = bundled, s = suspended).

Example: show etherchannel summary

HSRP

standby <group> ip <virtual-ip>config-if

Share a virtual gateway address between routers.

Example: standby 1 ip 192.168.1.254
standby <group> priority <n>config-if

Higher priority becomes Active (default 100).

Example: standby 1 priority 110
standby <group> preemptconfig-if

Take the Active role back when this router returns.

Example: standby 1 preempt
show standby briefpriv

HSRP state per interface.

Example: show standby brief

Security

switchport port-securityconfig-if

Limit which/how many MAC addresses may use an access port.

Example: switchport port-security
switchport port-security maximum <n>config-if

Number of allowed MAC addresses.

Example: switchport port-security maximum 1
switchport port-security mac-address stickyconfig-if

Learn and remember the first MAC addresses seen.

Example: switchport port-security mac-address sticky
switchport port-security violation shutdown|restrict|protectconfig-if

What happens to an unknown device (shutdown = err-disable the port).

Example: switchport port-security violation shutdown
show port-securitypriv

Secure ports, address counts and violations.

Example: show port-security
show interfaces statuspriv

Port status including err-disabled.

Example: show interfaces status

Remote access

ip domain-name <name>config

Needed before generating SSH keys.

Example: ip domain-name nanotech.local
crypto key generate rsaconfig

Create RSA keys - enables SSH.

Example: crypto key generate rsa
username <name> secret <password>config

Local user account for login local.

Example: username admin secret Cisco123
enable secret <password>config

Password for the enable command on remote sessions.

Example: enable secret class
line vty 0 4config

Configure the remote-access lines.

Example: line vty 0 4
transport input ssh|telnet|allconfig-line

Which remote protocols are allowed.

Example: transport input ssh
login localconfig-line

Ask for a username and password from the local user list.

Example: login local
ssh -l <user> <ip>host

From a PC: open an encrypted session to a router or switch.

Example: ssh -l admin 192.168.1.1
telnet <ip>host

From a PC: unencrypted remote session.

Example: telnet 192.168.1.1

Services

http <ip | name>host

From a PC: open a web page (TCP port 80).

Example: http www.example.com
interface loopback <n>config

A virtual interface that is always up - handy for router IDs and tests.

Example: interface loopback 0

Console

terminal length <0-512>user/priv

Lines per page before --More--. 0 = no paging (Space = next page, Enter = next line, q = stop).

Example: terminal length 0
Ctrl+Z / Ctrl+Cconfig

Leave configuration mode straight to privileged EXEC (shows ^Z).

exit / logoutuser

End the console session - press RETURN to start again.

Example: logout

Output filters

<show command> | include <text>priv

Only lines containing the text (regular expressions work).

Example: show running-config | include hostname
<show command> | exclude <text>priv

Hide lines containing the text.

Example: show ip interface brief | exclude unassigned
<show command> | begin <text>priv

Start the output at the first matching line.

Example: show running-config | begin interface
<show command> | section <text>priv

Matching sections with their indented lines.

Example: show running-config | section router
<show command> | count <text>priv

Count matching lines.

Example: show ip route | count via

Save & reload

copy running-config startup-configpriv

Save the running configuration to NVRAM (asks for the destination filename - press Enter).

Example: copy run start
write memorypriv

Same as copy run start, without the question.

Example: wr
show startup-configpriv

The saved configuration.

Example: show startup-config
reloadpriv

Restart the device - unsaved changes are lost (it offers to save first).

Example: reload
erase startup-configpriv

Delete the saved configuration (factory reset after reload). Also: write erase.

Example: erase startup-config
default interface <if>config

Reset an interface to its factory settings.

Example: default interface fa0/1

Huawei / HP-H3C (VRP, Comware)

system-viewuser view

Enter system view (like conf t). Prompt changes from <R1> to [R1].

Example: system-view
quit / returnany

quit = one level up (like exit); return = back to user view (like end).

Example: return
display ...any

Huawei's show: display ip interface brief | ip routing-table | vlan | current-configuration | ospf peer | this.

Example: display ip interface brief
sysname <name>system

Set the device name (like hostname).

Example: sysname HW-SW1
vlan batch 10 20 / vlan batch 10 to 20system

Create several VLANs at once.

Example: vlan batch 10 20
port link-type access|trunkinterface

Port mode (like switchport mode).

Example: port link-type access
port default vlan <id> (HP: port access vlan <id>)interface

Access VLAN of the port.

Example: port default vlan 10
port trunk allow-pass vlan all (HP: port trunk permit vlan all)interface

VLANs allowed on a trunk.

Example: port trunk allow-pass vlan 10 20
ip address <ip> <mask|length>interface

Interface address; the mask can be a length (24).

Example: ip address 10.1.1.1 24
dot1q termination vid <vlan> (HP: vlan-type dot1q vid)interface

Router subinterface VLAN (router-on-a-stick).

Example: dot1q termination vid 10
interface Vlanif<id>system

VLAN interface on a Huawei L3 switch (routes by default).

Example: interface Vlanif10
ip route-static <net> <mask> <next-hop>system

Static route.

Example: ip route-static 0.0.0.0 0 203.0.113.1
ospf 1 → area 0 → network <net> <wildcard>system

OSPF: areas are their own view on Huawei.

Example: ospf 1
ip pool <name> → gateway-list / network <net> mask <m> / dns-listsystem

DHCP server pool.

Example: ip pool LAN
undo <command>any

Remove a setting (like no).

Example: undo shutdown
saveuser view

Save the configuration (like write).

Example: save

Dell OS10

interface ethernet 1/1/1config

Dell port names; otherwise very close to Cisco (switchport access vlan, show running-configuration).

Example: interface ethernet 1/1/1
ip address <ip>/<length>interface

Address with prefix length.

Example: ip address 10.1.1.1/24

Aruba AOS-CX

interface 1/1/1config

Aruba port names (member/slot/port).

Example: interface 1/1/1
vlan access <id>interface

Access VLAN of the port.

Example: vlan access 10
vlan trunk allowed allinterface

Make the port a trunk.

Example: vlan trunk allowed all
routing / ip address <ip>/<len>interface

Routed port with an address.

Example: ip address 10.1.1.1/24

Tips

Abbreviationsany

Any unambiguous prefix works, like on real IOS: conf t, int g0/0, sh ip int br, no shut, sw acc vlan 10.

Example: sh ip int br
Tab / ↑ ↓any

Tab completes a word; the arrow keys recall earlier commands.