ip address (interface view)

Function

The ip address command configures an IP address for an interface.

The undo ip address command deletes the IP address of an interface.

By default, no IP address is configured for interfaces.

Format

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

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

Parameters

Parameter Description Value
ip-address

Specifies an IP address.

The value is in dotted decimal notation.

mask

Specifies a subnet mask.

The IP address with the subnet mask of 255.255.255.255 can be assigned only to a Loopback interface.

The value is in dotted decimal notation.

mask-length

Specifies the length of the subnet mask.

The IP address with the subnet mask length of 32 can be assigned only to a Loopback interface.

The value is an integer ranging from 0 to 32.

sub

Indicates a secondary IP address. To implement communication between subnets on one interface, configure secondary IP addresses.

-

Views

100ge sub-interface view, 100GE interface view, 10GE sub-interface view, 10GE interface view, 200GE sub-interface view, 25GE sub-interface view, 25GE interface view, 400GE sub-interface view, 400GE interface view, 40GE sub-interface view, 40GE interface view, 50GE sub-interface view, 50GE interface view, Eth-Trunk sub-interface view, Eth-Trunk interface view, FlexE interface view, GE optical interface view, GE sub-interface view, GE interface view, GE electrical interface view, GMPLS-UNI interface view, Global VE sub-interface view, LMP interface view, Loopback interface view, Tunnel interface view, VBDIF interface view, VE sub-interface view, VLANIF interface view, Management interface view, Virtual template view

Default Level

2: Configuration level

Task Name and Operations

Task Name Operations
interface-mgr write

Usage Guidelines

Usage Scenario

To configure an IP address and its mask for an interface, run the ip address command. This configuration allows the interface to access a network. To connect an interface to several subnets, configure several IP addresses for the interface, one of which is the primary IP address and the others are secondary IP addresses. Each interface can have a maximum of one primary IP address and 255 secondary IP addresses configured.

Configuration Impact

  • The undo ip address command deletes all IP addresses of an interface.
  • The undo ip address ip-address mask command deletes the primary IP address.
  • The undo ip address ip-address mask sub command deletes secondary IP addresses.
  • When you configure a new primary IP address for an interface, the newly configured address overrides the previous one.
  • After an interface is configured with an IP address, if the interface is Up, the system generates the host route and network segment route based on the IP address.

Precautions

  • The following conditions are prohibited for different interfaces on the same device:
  • The IP addresses are the same.
  • The broadcast addresses (with the host ID field containing all 1s in the binary mode) corresponding to the IP addresses are the same. For example, if the IP address of interface A is 10.1.1.1/16 and its corresponding broadcast address is 10.1.255.255 and the IP address of interface B is 10.1.1.2/24 and its corresponding broadcast address is 10.1.1.255, the configuration is successful. However, if the IP address of interface B is also 10.1.1.2/16 and its corresponding broadcast address is also 10.1.255.255, the configuration fails.
  • The IP address of an interface is the same as the broadcast address of another interface. For example, if the IP address of interface A is 1.1.1.1/28 and its broadcast address is 1.1.1.15 and the IP address of interface B is 1.1.1.15/26, the configuration fails.
  • IP addresses configured for interfaces cannot be multicast or broadcast addresses. Ethernet interfaces cannot be configured with loopback addresses.
  • All secondary IP addresses must be deleted before you delete the primary IP address.
  • The configured IP address cannot be the same as the network ID corresponding to the IP address. For example, given the IP address of 10.0.0.88 and subnet mask of 255.255.255.248 (or subnet mask length of 29), the network ID corresponding to the IP address is 10.0.0.88. In this case, the configured IP address is the same as the network ID and therefore is an invalid IP address.

Example

# Configure a primary IP address 10.102.0.1 and a secondary IP address 10.38.160.1 with the subnet mask 255.255.255.0 for GE 0/1/1.
<HUAWEI> system-view
[~HUAWEI] interface GigabitEthernet0/1/1
[~HUAWEI-GigabitEthernet0/1/1] ip address 10.102.0.1 255.255.255.0
[*HUAWEI-GigabitEthernet0/1/1] ip address 10.38.160.1 255.255.255.0 sub
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >