ip address [ip] [mask]
Assigns an IPv4 address and subnet mask to an interface, enabling IP communication on that interface.
Definition: ip address [ip] [mask] is a Cisco IOS interface config command. Assigns an IPv4 address and subnet mask to an interface, enabling IP communication on that interface.
Overview
The `ip address` command in Cisco IOS is used to assign an IPv4 address and subnet mask to a router or switch interface, enabling IP communication on that interface. This command is fundamental to network configuration because without an IP address, an interface cannot participate in IP routing or forwarding packets. The networking concept behind this command is the assignment of a Layer 3 address to a Layer 2 interface, allowing the device to be reachable at the network layer.
You would reach for this command when configuring any routed interface, such as a physical port, subinterface, or loopback interface, to establish connectivity. Alternatives include using DHCP to obtain an address dynamically (via `ip address dhcp`) or configuring unnumbered interfaces (via `ip unnumbered`), but static assignment is typical for infrastructure links and loopbacks. In the broader configuration workflow, IP addressing is often one of the first steps after basic interface configuration (like `no shutdown`), and it is a prerequisite for routing protocols, ACLs, and other features.
Important IOS behavior: the command is executed in interface configuration mode; it immediately updates the running configuration; the interface must be in Layer 3 mode (i.e., not a switchport) for the command to be accepted; secondary addresses can be added using the `secondary` keyword; the command can be removed with `no ip address`; and the address/mask combination must be valid (e.g., not a network or broadcast address). The command requires privilege level 15 (enable mode) to configure. Understanding this command is critical for CCNA and CCNP candidates as it forms the basis of IP connectivity.
ip address [ip] [mask]When to Use This Command
- Configuring a router's GigabitEthernet interface with an IP address to connect to a local subnet.
- Setting up a management IP on a switch VLAN interface for remote access.
- Assigning a secondary IP address to an interface for multi-networking.
- Configuring an IP address on a loopback interface for router identification or OSPF router-id.
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| ip | A.B.C.D | The IPv4 address to assign to the interface. Must be a valid unicast address (not network or broadcast). Common mistakes include using an address that conflicts with another device on the same subnet or using a reserved address. |
| mask | A.B.C.D | The subnet mask for the IP address, typically expressed in dotted decimal (e.g., 255.255.255.0) or CIDR notation (e.g., /24) in some IOS versions. The mask must be contiguous. Common mistakes include using an incorrect mask that results in overlapping subnets or misconfiguring the prefix length. |
Command Examples
Assign primary IP address to GigabitEthernet0/0
interface GigabitEthernet0/0
ip address 192.168.1.1 255.255.255.0
no shutdownRouter(config-if)#ip address 192.168.1.1 255.255.255.0 Router(config-if)#no shutdown Router(config-if)# *Mar 1 00:01:23.456: %LINK-3-UPDOWN: Interface GigabitEthernet0/0, changed state to up *Mar 1 00:01:24.456: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
The command assigns IP 192.168.1.1 with mask 255.255.255.0. 'no shutdown' activates the interface. Syslog messages confirm interface and line protocol are up.
Assign secondary IP address to an interface
interface GigabitEthernet0/0
ip address 10.0.0.1 255.255.255.0 secondaryRouter(config-if)#ip address 10.0.0.1 255.255.255.0 secondary Router(config-if)#
Adds a secondary IP 10.0.0.1/24 to the same interface. No output besides the prompt; use 'show ip interface brief' to verify.
Understanding the Output
The 'ip address' command itself produces no direct output; success is indicated by the prompt returning without error. Use 'show ip interface brief' to verify the IP is assigned: the 'IP-Address' column shows the primary IP, 'Method' shows 'manual', 'Status' and 'Protocol' should be 'up' for a working interface. For secondary IPs, use 'show ip interface' to see all addresses.
A common issue is an overlapping subnet error if the IP conflicts with another interface on the same router.
Configuration Scenarios
Assign IP address to a router's GigabitEthernet interface for point-to-point link
Two routers, R1 and R2, are connected via a direct Ethernet link. Each router needs an IP address on the same subnet to communicate.
Topology
R1(Gi0/0)---10.0.12.0/30---(Gi0/0)R2Steps
- 1.Step 1: Enter global configuration mode: R1> enable then R1# configure terminal
- 2.Step 2: Enter interface configuration mode for Gi0/0: R1(config)# interface GigabitEthernet0/0
- 3.Step 3: Assign IP address and mask: R1(config-if)# ip address 10.0.12.1 255.255.255.252
- 4.Step 4: Enable the interface: R1(config-if)# no shutdown
- 5.Step 5: Repeat on R2 with address 10.0.12.2 and same mask.
! R1 configuration interface GigabitEthernet0/0 ip address 10.0.12.1 255.255.255.252 no shutdown
Verify: Use 'show ip interface brief' to verify the interface is up and has the correct IP address. Expected output: Gi0/0 is up, line protocol is up, Internet address is 10.0.12.1/30.
Watch out: Forgetting to issue 'no shutdown' will leave the interface administratively down, preventing communication even with correct IP addressing.
Configure a secondary IP address on a router interface for multi-networking
A router interface needs to serve two subnets due to IP address exhaustion or migration. A secondary IP address allows the interface to be reachable on both subnets.
Topology
R1(Gi0/0)---192.168.1.0/24 and 10.0.1.0/24Steps
- 1.Step 1: Enter interface configuration mode: R1(config)# interface GigabitEthernet0/0
- 2.Step 2: Assign primary IP: R1(config-if)# ip address 192.168.1.1 255.255.255.0
- 3.Step 3: Assign secondary IP: R1(config-if)# ip address 10.0.1.1 255.255.255.0 secondary
- 4.Step 4: Enable the interface: R1(config-if)# no shutdown
! R1 configuration interface GigabitEthernet0/0 ip address 192.168.1.1 255.255.255.0 ip address 10.0.1.1 255.255.255.0 secondary no shutdown
Verify: Use 'show ip interface Gi0/0' to see both IP addresses listed. Expected output includes 'Internet address is 192.168.1.1/24' and 'Secondary address 10.0.1.1/24'.
Watch out: Secondary addresses are not advertised by routing protocols by default unless explicitly configured (e.g., with 'network' statements under the routing protocol). Also, ensure the secondary subnet does not overlap with the primary subnet.
Troubleshooting with This Command
When troubleshooting IP address configuration, the first step is to verify the interface status and IP address using 'show ip interface brief' or 'show ip interface'. Healthy output shows the interface as 'up/up' with the correct IP address and mask. Problem indicators include 'administratively down' (interface shutdown), 'down/down' (cable or peer issue), or 'up/down' (Layer 2 problem).
Focus on the 'Internet address' field: if it shows 'unassigned' or an incorrect address, the interface lacks proper IP configuration. Common symptoms this command helps diagnose include inability to ping the interface, routing protocol neighbors not forming, or traffic not being forwarded. A step-by-step diagnostic flow: 1) Check interface status with 'show ip interface brief'. 2) If down, check 'show interfaces' for error counters or 'show running-config interface' for 'shutdown'. 3) Verify IP address with 'show ip interface'. 4) Ensure the subnet mask matches the peer's mask. 5) Test Layer 3 connectivity with 'ping' from the router. 6) If ping fails, check ARP with 'show arp' or 'show ip arp' to see if the router has learned the peer's MAC address.
Correlate with 'debug ip packet' cautiously to see if packets are being sent and received. Also, use 'show ip route' to confirm the connected route appears. If the interface has multiple IP addresses (secondary), ensure routing is aware of both subnets.
Common misconfigurations include using the wrong mask (e.g., /24 instead of /30 on a point-to-point link) or assigning an address that is already in use. The 'ip address' command itself does not generate errors for duplicate addresses; that is detected later via ARP conflicts. Always verify with 'show running-config interface' to confirm the configuration is present.
CCNA Exam Tips
Remember that the 'ip address' command is configured in interface configuration mode; you must first enter 'interface <type> <number>'.
The 'secondary' keyword allows multiple IPs on one interface; CCNA may test that secondary IPs are used for legacy multi-networking.
Always use 'no shutdown' after assigning an IP to bring the interface up; exam questions often forget this step.
The subnet mask can be in dotted decimal (e.g., 255.255.255.0) or prefix length (e.g., /24) — both are valid but CCNA typically uses dotted decimal.
Common Mistakes
Forgetting to enter interface configuration mode before typing 'ip address' — results in '% Invalid input detected'.
Using the wrong subnet mask, causing IP address overlap or incorrect subnetting.
Assigning an IP address without using 'no shutdown' — interface remains administratively down.
Attempting to assign a secondary IP without the 'secondary' keyword, which overwrites the primary IP.
ip address [ip] [mask] vs no shutdown
Both 'ip address' and 'no shutdown' are essential interface configuration commands, often used together to bring an interface into an operational state. They are commonly confused because a new engineer might think assigning an IP address automatically enables the interface, or vice versa, but they have distinct and complementary roles.
| Aspect | ip address [ip] [mask] | no shutdown |
|---|---|---|
| Purpose | Assigns IPv4 address and subnet mask to an interface | Enables an administratively disabled interface |
| Effect on interface state | Sets Layer 3 addressing; does not change administrative state (remains shutdown if disabled) | Changes administrative state from shutdown to up (no shutdown); does not assign an address |
| Configuration requirement | May be configured before or after no shutdown; address takes effect only when interface is up | Must be applied after shutdown if interface was disabled; no effect on addressing |
| Persistence after reload | Persists in running-config and startup-config if saved | Persists in config; by default interfaces are shutdown on reload unless no shutdown is saved |
| Dependencies | Requires interface to be in Layer 3 mode (e.g., no switchport on switches) | Works on any interface type regardless of Layer 2 or Layer 3 mode |
| Typical use | Use when configuring an interface for IP communication (e.g., on a router or L3 switch) | Use after creating or connecting a new interface that is disabled by default |
Use ip address [ip] [mask] when you need to assign an IPv4 address and subnet mask to an interface to enable IP routing or communication on that interface.
Use no shutdown when you need to enable an interface that is administratively down (e.g., after default configuration or after a shutdown command was applied).
Platform Notes
In IOS-XE (e.g., Catalyst 9000 switches), the 'ip address' command syntax is identical to classic IOS. However, on switches running IOS-XE, interfaces may default to Layer 2 switchport mode; you must first issue 'no switchport' to make the interface a routed port before assigning an IP address. On NX-OS (e.g., Nexus switches), the equivalent command is also 'ip address' but the interface must be in 'no switchport' mode as well.
NX-OS uses the same syntax but supports additional options like 'ip address dhcp' and 'ip address 10.0.0.1/24' (CIDR notation). On ASA firewalls, the command is 'ip address' but it is configured in interface configuration mode, and the ASA uses a different concept of 'nameif' for security levels. The ASA also supports 'ip address dhcp' and 'ip address pppoe'.
For IOS-XR (e.g., ASR 9000), the command is 'ipv4 address' under interface configuration, and it requires a prefix length in CIDR format (e.g., 'ipv4 address 10.0.0.1 255.255.255.0' is not valid; use 'ipv4 address 10.0.0.1/24'). Additionally, IOS-XR uses a commit model, so changes are not applied until 'commit' is issued. In older IOS versions (12.x), the 'ip address' command behaves the same but may not support certain features like 'ip address negotiated' for PPP.
In 15.x and 16.x, the command remains consistent. Always check the specific platform documentation for any nuances.
Related Commands
interface [type] [number]
Enters interface configuration mode for a specific interface (e.g., GigabitEthernet0/1) to configure Layer 2 or Layer 3 parameters.
no shutdown
Enables an interface that has been administratively disabled, allowing it to forward traffic and participate in network operations.
show ip interface
Displays the status and configuration of all IP interfaces on a Cisco router, including IP address, protocol status, and interface statistics, used for verifying interface IP configuration and troubleshooting connectivity issues.
show ip interface brief
Displays a one-line summary of all interfaces showing the IP address assigned, operational status (up/down), and line protocol status. The fastest way to get a device health overview.
Practice for the CCNA 200-301
Test your knowledge with practice questions covering all CCNA 200-301 exam domains.
Practice CCNA 200-301 Questions