Assign an IP Address to a VLAN

Assign an IP address to a VLAN so that it supports routing operations.

Before you begin

  • You must create the VLAN.

  • Activate IP forwarding globally.

  • If you use this procedure to create a Secondary IP Interface, you must first create the primary IP address.

About this task

If an IP interface is configured without specifying the VRF instance, it maps to VRF 0 by default.

Procedure

  1. Enter VLAN Interface Configuration mode:

    enable

    configure terminal

    interface vlan <1–4059>

  2. Assign a primary IP address to a VLAN:

    ip address {<A.B.C.D/X>|<A.B.C.D> <A.B.C.D>} [dvr-one-ip] [name WORD <0-64>] [state-disabled]

  3. Optional: Assign a Secondary IP Interface to a VLAN:

    ip address {<A.B.C.D/X>|<A.B.C.D> <A.B.C.D>} secondary

  4. Optional: If required, associate the VLAN with a VRF:

    vrf WORD<1–16>

Example

Add a primary IP address to the VLAN and configure it as the DvR-One-IP interface. Give the address a name.

Switch:1>enable 
Switch:1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Switch:1(config)#interface vlan 2
Switch:1(config-if)#ip address 192.0.2.5 255.255.255.0 dvr-one-ip name Boston

Variable Definitions

The following table defines parameters for the ip address command.

Variable

Value

<A.B.C.D/X>|<A.B.C.D> <A.B.C.D>

Specifies the IP address and subnet mask in the format A.B.C.D/X or A.B.C.D A.B.C.D.

dvr-one-ip

Specifies that the IP address will be used as the DvR gateway IP address and will be used by all other DvR Controllers for the DvR VLAN subnet.

name WORD <0-64>

Specifies the name associated with the IP address on a VLAN.

This parameter does not apply to all hardware platforms.

secondary

Identifies the IP address as a Secondary IP Interface.

state-disabled

Creates the IP interface in an administratively disabled state. This parameter is useful if you want to preconfigure an IP interface, including the routing protocol configuration for that interface, and enable it later during a maintenance window. This parameter applies only to the primary IP address. By default, the switch enables an IP interface after you configure the primary IP address.

Note: This parameter is not saved in the configuration file.

The following table defines parameters for the vrf command.

Variable

Value

WORD<0-16>

Specifies the VRF of the VLAN.