Example for Configuring Primary and Secondary IP Addresses for an Interface
Networking Requirements
As shown in Figure 1-5, the Router has only one idle interface GE1/0/0 to connect to a LAN. The hosts on the LAN are located on two network segments: 10.16.1.0/24 and 10.16.2.0/24. The interface must be configured with two interfaces to provide access for hosts on the two network segments.
Configuration Roadmap
The configuration roadmap is as follows:
Configure a primary IP address and a secondary IP address for the interface.
IP addresses of the same interface must be on different network segments.
Procedure
- Configure a primary IP address and a secondary IP address for GE1/0/0.
<Huawei> system-view [Huawei] interface gigabitethernet 1/0/0 [Huawei-GigabitEthernet1/0/0] ip address 10.16.1.1 24 [Huawei-GigabitEthernet1/0/0] ip address 10.16.2.1 24 sub
- Verify the configuration.
# Ping a host on network segment 10.16.1.0/24 from the Router. The ping operation succeeds.
<Huawei> ping 10.16.1.2 PING 10.16.1.2: 56 data bytes, press CTRL_C to break Reply from 10.16.1.2: bytes=56 Sequence=1 ttl=128 time=25 ms Reply from 10.16.1.2: bytes=56 Sequence=2 ttl=128 time=27 ms Reply from 10.16.1.2: bytes=56 Sequence=3 ttl=128 time=26 ms Reply from 10.16.1.2: bytes=56 Sequence=4 ttl=128 time=26 ms Reply from 10.16.1.2: bytes=56 Sequence=5 ttl=128 time=26 ms --- 10.16.1.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 25/26/27 ms
# Ping a host on network segment 10.16.2.0/24 from the Router. The ping operation succeeds.
<Huawei> ping 10.16.2.2 PING 10.16.2.2: 56 data bytes, press CTRL_C to break Reply from 10.16.2.2: bytes=56 Sequence=1 ttl=128 time=25 ms Reply from 10.16.2.2: bytes=56 Sequence=2 ttl=128 time=26 ms Reply from 10.16.2.2: bytes=56 Sequence=3 ttl=128 time=26 ms Reply from 10.16.2.2: bytes=56 Sequence=4 ttl=128 time=26 ms Reply from 10.16.2.2: bytes=56 Sequence=5 ttl=128 time=26 ms --- 10.16.2.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 25/25/26 ms
# The hosts on the two network segments can ping through each other.