ip [virtual-ip]
Configures a virtual IP address for an HSRP group on a Cisco Nexus interface.
Overview
The 'ip [virtual-ip]' command in Cisco NX-OS is used within HSRP (Hot Standby Router Protocol) configuration mode to assign a virtual IP address to an HSRP group. HSRP provides first-hop redundancy by allowing two or more routers to share a virtual IP and MAC address, so that if the active router fails, a standby router takes over transparently to hosts. This command is essential for defining the gateway address that end devices will use. On Nexus switches, HSRP configuration is done per interface and per group. The command must be executed after entering the HSRP configuration submode for a specific group (e.g., 'hsrp 1'). The virtual IP must be in the same subnet as the interface's primary IP address. This command is typically used during initial HSRP setup or when modifying the virtual IP for network changes. In troubleshooting workflows, verifying the virtual IP is the first step to ensure HSRP is correctly configured.
ip [virtual-ip]When to Use This Command
- Setting the virtual gateway IP for a subnet to provide first-hop redundancy.
- Configuring multiple HSRP groups with different virtual IPs for load balancing.
- Changing the virtual IP address during network migration without affecting active sessions.
- Enabling HSRP on an interface by assigning the virtual IP that clients use as default gateway.
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| virtual-ip | A.B.C.D | The virtual IP address assigned to the HSRP group. Must be a valid unicast address in the same subnet as the interface IP. This IP is used by hosts as their default gateway. |
Command Examples
Configure HSRP virtual IP
ip 10.1.1.254Sets the virtual IP address for the HSRP group (default group 0) to 10.1.1.254. No output indicates success.
Configure HSRP virtual IP for group 10
ip 10.1.2.254Assumes already in HSRP configuration mode for group 10. Sets virtual IP to 10.1.2.254.
Understanding the Output
The 'ip [virtual-ip]' command does not produce output on successful execution. To verify the configuration, use 'show hsrp' or 'show running-config interface <interface>'. The 'show hsrp' output displays the virtual IP address under the group details. A healthy configuration shows the virtual IP correctly assigned and the group state as Active or Standby. Problem values include a missing virtual IP or mismatched IPs across peers.
Configuration Scenarios
Basic HSRP Configuration
Two Nexus switches providing gateway redundancy for VLAN 10.
Topology
Hosts -- SwitchA (Active) -- SwitchB (Standby)
Both switches in VLAN 10 with IPs 10.1.1.1 and 10.1.1.2.Steps
- 1.On SwitchA: configure terminal, interface vlan 10, ip address 10.1.1.1/24, hsrp 1, ip 10.1.1.254, priority 110, preempt.
- 2.On SwitchB: configure terminal, interface vlan 10, ip address 10.1.1.2/24, hsrp 1, ip 10.1.1.254, priority 100, preempt.
! SwitchA
interface Vlan10
ip address 10.1.1.1/24
hsrp 1
ip 10.1.1.254
priority 110
preempt
! SwitchB
interface Vlan10
ip address 10.1.1.2/24
hsrp 1
ip 10.1.1.254
priority 100
preemptVerify: Use 'show hsrp' to verify virtual IP and group state. Active router shows state Active, standby shows Standby.
Watch out: Ensure both switches have the same virtual IP and that the interface IPs are in the same subnet.
Troubleshooting with This Command
When troubleshooting HSRP on Nexus, start by verifying the virtual IP configuration with 'show running-config interface <interface>' or 'show hsrp'. If the virtual IP is missing, HSRP will not form. Check that the virtual IP is in the same subnet as the interface IP; a mismatch causes HSRP to stay in Init state. Use 'debug hsrp' to see events. Common issues include duplicate virtual IPs across groups or interfaces, and incorrect subnet masks. On Nexus, ensure that the HSRP group number matches on both peers. If the virtual IP is correct but HSRP is not active, check interface state and IP connectivity between peers.
CCNA Exam Tips
Remember that the virtual IP must be in the same subnet as the interface IP.
HSRP group number can be 0-255; default is 0 if not specified.
The virtual IP cannot be the same as the interface IP.
Common Mistakes
Forgetting to enter HSRP configuration mode (e.g., 'interface vlan 10' then 'hsrp 1' before 'ip').
Assigning a virtual IP outside the interface subnet, causing HSRP to fail.
Using the same virtual IP on multiple HSRP groups on the same interface.
Platform Notes
On Cisco NX-OS, the HSRP configuration is similar to IOS but uses the 'hsrp' command under interface configuration. Unlike IOS, Nexus requires explicit 'hsrp <group>' submode. The 'ip' command is used within that submode. There is no 'standby' command; HSRP is the default FHRP. For VRRP or GLBP, use 'vrrp' or 'glbp' respectively. Nexus supports HSRP version 1 and 2; version 2 is default on some platforms. The virtual IP must be unique per group and cannot overlap with interface IPs.
Practice for the CCNA 200-301
Test your knowledge with hundreds of CCNA practice questions covering all exam domains.
Practice CCNA Questions