ip address

Use ip address to assign an IP address to the interface.

Use undo ip address to remove the IP address from the interface.

Syntax

ip address ip-address { mask-length | mask } [ sub ]

undo ip address [ ip-address { mask-length | mask } [ sub ] ]

ip address ip-address { mask-length | mask } [ sub ]

undo ip address ip-address { mask-length | mask } [ sub ]

Default

No IP address is assigned to an interface.

Views

Interface view

Predefined user roles

network-admin

mdc-admin

Parameters

ip-address: Specifies the IP address of the interface, in dotted decimal notation.

mask-length: Specifies the subnet mask length in the range of 1 to 31. For a loopback interface, the value range is 1 to 32.

mask: Specifies the subnet mask in dotted decimal notation.

sub: Assigns a secondary IP address to the interface.

Usage guidelines

Use the command to assign a primary or secondary IP address to an interface.

An interface can have only one primary IP address. A newly configured primary IP address overwrites the previous address. If the interface connects to multiple subnets, configure primary and secondary IP addresses on the interface so the subnets can communicate with each other through the interface.

You cannot assign secondary IP addresses to an interface that obtains an IP address through BOOTP, PPP address negotiation, IP unnumbered, or DHCP.

If you do not specify any parameters, the undo ip address command removes all IP addresses from the interface. The undo ip address ip-address { mask | mask-length } command removes the primary IP address. The undo ip address ip-address { mask | mask-length } sub command removes a secondary IP address.

The primary and secondary IP addresses assigned to the interface can be located on the same network segment. Different interfaces on your device must reside on different network segments.

Examples

# Assign VLAN-interface 10 a primary IP address 129.12.0.1 and a secondary IP address 202.38.160.1, with subnet masks both 255.255.255.0.

<Sysname> system-view
[Sysname] interface vlan-interface 10
[Sysname-Vlan-interface10] ip address 129.12.0.1 255.255.255.0
[Sysname-Vlan-interface10] ip address 202.38.160.1 255.255.255.0 sub

Related commands

display ip interface

display ip interface brief