The ip address command configures an IP address for an interface.
The undo ip address command deletes an IP address from an interface.
By default, no IP address is configured for an interface.
ip address ip-address { mask | mask-length } [ sub ]
undo ip address [ ip-address { mask | mask-length } [ sub ] ]
Parameter |
Description |
Value |
---|---|---|
ip-address |
Specifies the IP address of an interface. |
The value is in dotted decimal notation. |
mask |
Specifies a subnet mask. |
The value is in dotted decimal notation. |
mask-length |
Specifies the mask length. |
The value is an integer that ranges from 0 to 32. |
sub |
Configures a secondary IP address for an interface. This parameter is optional. To implement communication between multiple subnets of an interface, configure secondary IP addresses for the interface. |
- |
Usage Scenario
The ip address command configures IP addresses for interfaces on the switch so that the switch can communicate with different network segments. To connect an interface to multiple network segments, configure multiple IP addresses for the interface. Among these IP addresses, one is the primary IP address and the others are secondary IP addresses. If you configure a new primary IP address for the interface, the new IP address overrides the original one.
When you run the undo ip address command:
Precautions
You can configure a secondary IP address only after configuring a primary IP address on the interface. You must delete all secondary IP addresses before deleting the primary IP address.
You can configure multiple IP addresses for a Layer 3 interface on the switch, one as the primary IP address, and the others as secondary IP addresses. Each Layer 3 interface can have a maximum of 31 secondary IP addresses.
The subnet IP address cannot be used as the IP address on an interface.
Only the S5720-EI, S5720-HI, S5730-HI, S5731-H, S5731-S, S5731S-H, S5731S-S, S5732-H, S6720-EI, S6720-HI, S6720S-EI, S6730-H, S6730S-H, S6730-S, and S6730S-S support Ethernet sub-interfaces.
After you run the undo portswitch command to switch Layer 2 interfaces on the preceding series of switches into Layer 3 interfaces, you can configure Ethernet sub-interfaces on the interfaces.
After an interface is added to an Eth-Trunk, sub-interfaces cannot be configured on the interface.
# Configure a primary IP address 10.1.0.1 and a secondary IP address 10.2.0.1 for VLANIF10, with subnet mask 255.255.255.0.
<HUAWEI> system-view [HUAWEI] interface vlanif 10 [HUAWEI-Vlanif10] ip address 10.1.0.1 255.255.255.0 [HUAWEI-Vlanif10] ip address 10.2.0.1 255.255.255.0 sub
# Configure a primary IP address 10.1.0.1 and a secondary IP address 10.2.0.1 for GE0/0/1, with subnet mask 255.255.255.0.
<HUAWEI> system-view [HUAWEI] interface gigabitethernet 0/0/1 [HUAWEI-GigabitEthernet0/0/1] undo portswitch [HUAWEI-GigabitEthernet0/0/1] ip address 10.1.0.1 255.255.255.0 [HUAWEI-GigabitEthernet0/0/1] ip address 10.2.0.1 255.255.255.0 sub