Configuring IP Address
This section describes the configuration methods of IP address.
- Configuring IP Addresses for Interfaces
To enable network devices to communicate at the network layer, configure interface IP addresses on the device. - Configuring an IP Unnumbered Interface
An IP unnumbered interface can borrow the IP address from another interface when the local interface has no IP address.
Configuring IP Addresses for Interfaces
To enable network devices to communicate at the network layer, configure interface IP addresses on the device.
Configuring a Primary IP Address for an Interface
Procedure
- Run:
system-view
The system view is displayed.
- Run:
interface interface-type interface-number
- On an Ethernet interface, run:
undo portswitch
The interface is switched to Layer 3 mode.
By default, an Ethernet interface works in Layer 2 mode.
If an Ethernet interface already has Layer 2 configuration, this command fails to be executed on the interface. Before running this command on the interface, delete all the Layer 2 configuration of the interface.
NOTE:
If many Ethernet interfaces need to be switched to Layer 3 mode, run the undo portswitch batch interface-type { interface-number1 [ to interface-number2 ] } &<1-10> command in the system view to switch these interfaces to Layer 3 mode in batches.
- Run:
ip address ip-address { mask | mask-length }
A primary IP address is configured for the interface.
Each interface has only one primary IP address. If you configure a new primary IP address for an interface, the original one is deleted and the new primary IP address takes effect.
- Run:
commit
The configuration is committed.
(Optional) Configuring a Secondary IP Address for an Interface
Context
Generally, an interface needs only a primary IP address. In some special scenarios, you need to configure secondary IP addresses for an interface. For example, a switch modules connects to a physical network through an interface, and hosts on this network belong to two network segments. To enable the switch modules to communicate with all hosts on the physical network, configure a primary IP address and a secondary IP address for this interface. You can configure multiple IP address for a Layer 3 interface on a switch modules, one as the primary IP address, and the others as secondary IP addresses. Each Layer 3 interface can have a maximum of 255 secondary IP addresses.
Procedure
- Run:
system-view
The system view is displayed.
- Run:
interface interface-type interface-number
- On an Ethernet interface, run:
undo portswitch
The interface is switched to Layer 3 mode.
By default, an Ethernet interface works in Layer 2 mode.
If an Ethernet interface already has Layer 2 configuration, this command fails to be executed on the interface. Before running this command on the interface, delete all the Layer 2 configuration of the interface.
NOTE:
If many Ethernet interfaces need to be switched to Layer 3 mode, run the undo portswitch batch interface-type { interface-number1 [ to interface-number2 ] } &<1-10> command in the system view to switch these interfaces to Layer 3 mode in batches.
- Run:
ip address ip-address { mask | mask-length } sub
A secondary IP address is configured for the interface.
- Run:
commit
The configuration is committed.
Checking the Configuration
Procedure
- Run the display ip interface [ interface-type interface-number] or display ip interface brief [ interface-type [ interface-number ] | slot slot-id [ card card-number ] | ip-configured [ except interface-type ] ] command to check the IP address configuration of an interface.
- Run the display interface [ interface-type [ interface-number ] ] command to check information about an interface.
Configuring an IP Unnumbered Interface
An IP unnumbered interface can borrow the IP address from another interface when the local interface has no IP address.
Configuring a Primary IP Address for the IP Numbered Interface
Procedure
- Run:
system-view
The system view is displayed.
- Run:
interface interface-type interface-number
The interface view is displayed.
- On an Ethernet interface, run:
undo portswitch
The interface is switched to Layer 3 mode.
By default, an Ethernet interface works in Layer 2 mode.
If an Ethernet interface already has Layer 2 configuration, this command fails to be executed on the interface. Before running this command on the interface, delete all the Layer 2 configuration of the interface.
NOTE:
If many Ethernet interfaces need to be switched to Layer 3 mode, run the undo portswitch batch interface-type { interface-number1 [ to interface-number2 ] } &<1-10> command in the system view to switch these interfaces to Layer 3 mode in batches.
- Run:
ip address ip-address { mask | mask-length }
A primary IP address is configured for the interface.
Each interface has only one primary IP address. If you configure a new primary IP address for an interface, the original one is deleted and the new primary IP address takes effect.
- Run:
commit
The configuration is committed.
Configuring IP Unnumbered on an Interface
Context
In some scenarios, an interface can borrow an IP address from another interface to conserve IP addresses. For example, if an interface is seldom used, configure IP unnumbered on this interface so that the interface can share an IP address with another interface.
An IP unnumbered interface cannot run dynamic routing protocols because it does not have an IP address itself. To enable the interface to communicate with a peer network segment, configure a static route to the network segment.
The restrictions for IP unnumbered interface configuration are as follows:
The IP address to be borrowed cannot be a borrowed IP address.
The IP address can be lent to multiple interfaces.
If an interface has more than one IP address, IP unnumbered interfaces can borrow only the primary IP address.
If the interface assigned to an IP unnumbered interface has no IP address, the IP unnumbered interface obtains the IP address 0.0.0.0.
The interface that borrows an IP address can only be a tunnel interface.
The IP address of the virtual loopback interface can be lent to other interfaces, but the virtual loopback interface cannot borrow an IP address from another interface.
Procedure
- Run:
system-view
The system view is displayed.
- Run:
interface tunnel interface-number
The tunnel interface view is displayed.
- Run:
ip address unnumbered interface interface-type interface-number
The tunnel interface is configured to borrow the IP address from a specified interface.
- Run:
commit
The configuration is committed.
Checking the Configuration
Procedure
- Run the display ip interface [ interface-type interface-number ] or display ip interface brief [ interface-type [ interface-number ] | slot slot-id [ card card-number ] | ip-configured [ except interface-type ] ] command to check the IP address configuration of an interface.
- Run the display interface [ interface-type [ interface-number ] ] command to check information about an interface.