Overview

Configuring an IP address on a router’s interface connects the router to the IP network.Configuring an IP address is an important step in router configuration.Learn more about the IP address configuration commands for Cisco routers.

IP address configuration command

To configure an IP address on a Cisco router interface, use the following command in configuration mode for the appropriate interface

IP address configuration command

(config)#interface <interface-name>
(config-if)#ip address <ip-address> <subnetmask> [secondary]

<interface-name> : Name of the interface on which the IP address is to be configured
<ip-address> : IP address
<subnetmask> : subnetmask

If you configure an IP address on an interface with this command, that interface is connected to the network. Note that the router interface is shutdown by default, so do not forget no shutdown as well.

Error message when configuring IP address

IP address overlapping

The following error message may appear when configuring an IP address.

R1(config-if)# ip address 192.168.1.10 255.255.255.224
% 192.168.1.0 overlaps with FastEthernet0/0

This error message indicates that the IP addresses overlap. One IP network is connected on one interface of the router. An IP network, in other words, is a collection of IP addresses. The range of the collection of IP addresses must not overlap on a per-interface basis. If the collection of IP addresses (network addresses) of multiple interfaces overlap, the above error message will be displayed due to overlapping IP addresses.

Figure: Overlapping IP address
Figure: Overlapping IP address

Bad subnet mask

If you attempt to configure an IP address with an incorrect subnet mask, you will receive the following error message

R1(config-if)# ip address 192.168.1.254 255.255.5.0
Bad mask 0xFFFF0500 for address 192.168.1.254

A subnet mask is always a sequence of bit “1s” followed by a sequence of bit “0s”. A subnet mask in which bits “1” and “0” appear alternately is an invalid subnet mask.This error message means that the subnet mask is incorrect.

Secondary IP address

Normally, only one IP address is configured for an interface. However, by adding the secondary option, multiple IP addresses can be configured on a single interface. The IP address in the normal configuration is called the primary IP address; the second and subsequent IP addresses configured with the secondary option are called secondary IP addresses.

The operation of sending and receiving packets using a secondary IP address is as follows

  • Receive Packets: Receive all packets whose destination IP address is the configured IP address.
  • Sending packets: The source IP address of packets sent from the interface is the primary IP address.

The following figure summarizes the sending and receiving of packets when a secondary IP address is configured.

 Figure: Secondary IP address
Figure: Secondary IP address

ip unnumbered : reuse IP address

Routers have multiple interfaces, and by configuring IP addresses on the interfaces, multiple networks can be interconnected to send and receive IP packets.

As a rule, IP addresses must be unique for each interface.However, it is possible to duplicate the IP address of another interface in exceptional cases, mainly on point-to-point interfaces such as leased lines. To do so, configure ip unnumbered.

The configuration of ip unnumbered allows you to save IP addresses by using IP addresses of other interfaces. ip unnumbered can be configured with the following commands

ip unnumbered

(config)#interface <interface-name1>
(config-if)#ip unnumbered <interface-name2>

<interface-name1> : Interface name to be configured with ip unnumbered
<interface-name2> : Name of the interface with the IP address you want to reuse

The following figure shows an example configuration for ip unnumbered.

 Figure: ip unnumbered
Figure: ip unnumbered

R1 and R2 are connected by a point-to-point interface, Se0/0. Instead of configuring a unique IP address for Se0/0 on R1, the following configuration is made on Se0/0 to reuse the Fa0/0 IP address, 192.168.1.1.

R1 ip unnumbered configuration

interface serial 0/0
 ip unnumbered FastEthernet0/0

Then the IP address of Se0/0 is also 192.168.1.1, the same as Fa0/0. When Se0/0 on R1 sends IP packets, the source IP address is 192.168.1.1, the IP address of Fa0/0. show ip interface brief and show ip interface show the following

R1 show ip inteface brief/show ip interface

R1#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.12.1    YES NVRAM  up                    up
Serial0/0                  192.168.12.1    YES TFTP   up                    up
R1#show ip interface serial 0/0
Serial0/0 is up, line protocol is up
  Interface is unnumbered. Using address of FastEthernet0/0 (192.168.12.1)
  Broadcast address is 255.255.255.255
  Peer address is 192.168.12.2
-- omitted --

Note that the ip unnumbered configuration itself can be specified for interfaces other than point-to-point interfaces such as Ethernet. However, in this case, address resolution may not work properly and communication may not be possible.

IP Address Verification Commands

The main commands to verify the IP address configured for an interface are as follows

CommandSummary
#show ip interface briefList IP addresses configured on the interface and the status of the interface.
#show interfaceDisplays detailed L1/L2 status of the interface.
#show ip interface Displays detailed L3 status of the interface.
#show ip routeDisplays the routing table.
Table: IP address verification commands

show ip interface brief

When verifying IP addresses, it is useful to first look at the show ip interface brief command, which lists the IP addresses. However, the subnet mask is not known.

show ip interface brief

R1#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.12.1    YES NVRAM  up                    up
FastEthernet0/1            10.1.1.1        YES NVRAM  up                    up

show interface

You can also verify the IP address by using show interface to display detailed L1/L2 information about the interface.

show interface

R1#show interfaces FastEthernet0/0
FastEthernet0/0 is up, line protocol is up
  Hardware is Gt96k FE, address is c201.6dd0.0000 (bia c201.6dd0.0000)
  Internet address is 192.168.12.1/24
  MTU 1500 bytes, BW 10000 Kbit/sec, DLY 1000 usec,
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation ARPA, loopback not set
  Keepalive set (10 sec)
-- omitted --

show ip interface

The show ip interface command allows you to verify the L3 status of an interface in detail. Of course, you can also see the IP address.

show ip interface

R1#show ip interface FastEthernet0/0
FastEthernet0/0 is up, line protocol is up
  Internet address is 192.168.12.1/24
  Broadcast address is 255.255.255.255
  Address determined by non-volatile memory
  MTU is 1500 bytes
  Helper address is not set
  Directed broadcast forwarding is disabled
  Outgoing access list is not set
  Inbound  access list is not set
-- omitted --

show ip route

The show ip route command displays the routing table. configuring an IP address is to connect the network. The route information for the network address of the configured IP address is registered in the routing table.

show ip route

R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, FastEthernet0/0
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, FastEthernet0/1

Depending on the IOS, in addition to Directly Connected (code “C”), Local (code “L”) route information is also registered.

Summary

Points

  • To configure an IP address, enter the following command in interface configuration mode
    (config)#interface <interface-name>
    (config-if)#ip address <ip-address> <subnetmask>[secondary]
  • Configuration with overlapping IP addresses or incorrect subnet masks is not allowed.
  • Multiple IP addresses can be configured on one interface with the secondary option.
  • ip unnumbered allows the IP address of another interface to be reused.