Learn Cisco CLI – Part 4 – Host Table Configuration

Table of Contents
Learn Cisco CLI - Part 4

Host Table Configuration

These blog posts I created to help me as a reference tool, as well as a way of retaining the knowledge. If you find it useful that’s just a plus.

Configuration Commands

IP Host

Creates a static hostname-to-IP address mapping in the host table.

Multiple IP addresses can be assigned to a single hostname for load balancing or redundancy.

				
					Syntax:
ip host <hostname> [port-number] <IP-address1> [IP-address2] ... [IP-address8]

				
			
  • <hostname> : The name you want to assign to the IP address.
  • [port-number] : (Optional) Specified a TCP port number for Telnet sessions.
  • <IP-address> : The IP address(es) associated with the hostname.

Example 1: Assigning a single IP address to a hostname.

				
					Router1>enable
Router1#configure terminal
Router1(config)#ip host Server1 192.168.10.10
				
			

Example 2: Assigning multiple IP addresses to a hostname.

				
					Router1>enable
Router1#configure terminal
Router1(config)#ip host WebServer 192.168.20.10 192.168.20.11 192.168.20.12
				
			

Example 3: Assigning a hostname with a specific Telnet port.

				
					Router1>enable
Router1#configure terminal
Router1(config)#ip host RemoteRouter 2323 10.0.0.1
				
			

No IP Host

Removes a hostname-to-IP address mapping from the host table.

				
					Syntax:
no ip host <hostname>
				
			

Example:

				
					Router1>enable
Router1#configure terminal
Router1(config)#no ip host Server1
				
			

Hostname

Sets or changes the hostname of the device itself.

Useful for identifying devices within a network easily.

				
					Syntax:
hostname <hostname>
				
			

Example:

				
					Router1>enable
Router1#configure terminal
Router1(config)#hostname BranchRouter1
				
			

Verification

Show Hosts

Displays the current contents of the host table, including both static and dynamically learned entries.

Provides information on temporary DNS entries and permanent host mappings.

				
					Syntax:
show hosts
				
			

Example:

				
					Router1>enable
Router1#show hosts
				
			

Sample Output:

				
					Default domain is not set
Name/address lookup uses static mappings

Host               Port  Flags      Age Type   Address(es)
Server1              0    IP           0      192.168.10.10
WebServer            0    IP           0      192.168.20.10
                                             192.168.20.11
                                             192.168.20.12

				
			

Ping

Tests connectivity to a host using its hostname or IP address.

Helps verify that the hostname resolves correctly to the intended IP address.

				
					Syntax:
ping <hostname | IP-address>
				
			

Example 1: Pinging using hostname.

				
					BranchRouter1# ping Server1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.10.10, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/3 ms

				
			

Example 2: Pinging using IP address.

				
					BranchRouter1# ping 192.168.20.10

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.10, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/3/4 ms

				
			

Telnet

Initiates a Telnet session to a remote device using its hostname or IP address.

Useful for testing connectivity and remote management capabilities.

				
					Syntax:
telnet <hostname | IP-address> [port]
				
			
  • <hostname> : The hostname of the remote device.
  • <IP-address> : The IP of the remote device.
  • [port] : (Optional) Specifies a port number if different from the default Telnet port (23).

Example 1: Telnet using hostname.

				
					BranchRouter1#telnet RemoteRouter

Trying 10.0.0.1 ... Open
User Access Verification

Password:

				
			

Example 2: Telnet using hostname and custom port.

				
					BranchRouter1# telnet RemoteRouter 2323

Trying 10.0.0.1 ... Open
User Access Verification

Password:

				
			

Clear Host

Clears dynamically learned entries from the host table.

Does not remove statically configured entries created with the ip host command.

				
					Syntax:
clear host [hostname | *]
				
			
  • <hostname> : The specific hostname to clear from the host table.
  • * : Clears all temporary (non-static) entries from the host table.

Example 1: Clearing a specific hostname.

				
					Router1>enable
Router1#clear host TempServer
				
			

Example 2: Clearing all temporary entries.

				
					Router1>enable
Router1#clear host *
				
			

EVE-NG Lab

You have a small network with the following devices:

  • Server1 with IP address 192.168.10.10
  • WebServer with IP addresses 192.168.20.10, 192.168.20.11, and 192.168.20.12
  • RemoteRouter with IP address 10.0.0.1 accessible over Telnet on port 2323

You want to configure your router (BranchRouter1) to resolve these hostnames locally without relying on external DNS services.

Device IP Address
Server1
192.168.10.10
WebServer
192.168.20.10
WebServer
192.168.20.11
WebServer
192.168.20.12
RemoteRouter
10.0.0.1

Step-by-Step Configuration

Set Router's Hostname

Enter global configuration mode:

				
					Router1>enable
Router1#configure terminal
				
			

Set the hostname:

				
					Router1(config)#hostname BranchRouter1
BranchRouter1(config)#
				
			

Configure Host Table Entries

Add Server1 to the host table:

				
					BranchRouter1>enable
BranchRouter1#configure terminal
BranchRouter1(config)#ip host Server1 192.168.10.10
				
			

Add WebServer with multiple IP addresses:

				
					BranchRouter1>enable
BranchRouter1#configure terminal
BranchRouter1(config)#ip host WebServer 192.168.20.10 192.168.20.11 192.168.20.12
				
			

Add RemoteRouter with custom Telnet port:

				
					BranchRouter1>enable
BranchRouter1#configure terminal
BranchRouter1(config)#ip host RemoteRouter 2323 10.0.0.1
				
			

Exit the global configuration mode:

				
					BranchRouter1(config)# exit
				
			

Verify Host Table Entries

Display the host table:

				
					BranchRouter1>enable
BranchRouter1#show hosts
				
			

Expected Output:

				
					Default domain is not set
Name/address lookup uses static mappings

Host               Port  Flags      Age Type   Address(es)
Server1              0    IP           0      192.168.10.10
WebServer            0    IP           0      192.168.20.10
                                            192.168.20.11
                                            192.168.20.12
RemoteRouter       2323   IP           0      10.0.0.1

				
			

Test Connectivity

Ping Server1:

				
					BranchRouter1>enable
BranchRouter1#ping Server1
				
			

Ping WebServer:

				
					BranchRouter1>enable
BranchRouter1#ping WebServer
				
			

Telnet to RemoteRouter:

				
					BranchRouter1>enable
BranchRouter1#telnet RemoteRouter
				
			

Modify Host Table Entries

Remove Server1 from the host table:

				
					BranchRouter1#configure terminal
BranchRouter1(config)#no ip host Server1
BranchRouter1(config)#exit
				
			

Verify removal:

				
					BranchRouter1>enable
BranchRouter1#show hosts
				
			

Leave a Comment