Example for Configuring an IP Unnumbered Interface
Networking Requirements
As shown in Figure 1-6, RouterA and RouterC are interconnected through a tunnel. Tunnel interfaces (Tunnel0/0/15) of RouterA and RouterC are seldom used, so they have no IP address configured. IP unnumbered needs to be configured on the tunnel interfaces so that the two switches can communicate through the tunnel.
Configuration Roadmap
The configuration roadmap is as follows:
Configure OSPF to ensure that there are reachable routes between RouterA and RouterC.
Create tunnel interfaces on RouterA and RouterC and configure the tunnel interfaces to borrow IP addresses from loopback interfaces to save IP addresses.
Procedure
- Configure IP addresses for physical interfaces.# Configure RouterA.
<Huawei> system-view [Huawei] sysname RouterA [RouterA] interface loopback 0 [RouterA-LoopBack0] ip address 10.1.1.1 255.255.255.0 [RouterA-LoopBack0] quit [RouterA] interface gigabitethernet 1/0/0 [RouterA-GigabitEthernet1/0/0] ip address 20.1.1.1 255.255.255.0 [RouterA-GigabitEthernet1/0/0] quit
# Configure RouterB.<Huawei> system-view [Huawei] sysname RouterB [RouterB] interface gigabitethernet 1/0/0 [RouterB-GigabitEthernet1/0/0] ip address 20.1.1.2 255.255.255.0 [RouterB-GigabitEthernet1/0/0] quit [RouterB] interface gigabitethernet 2/0/0 [RouterB-GigabitEthernet2/0/0] ip address 30.1.1.1 255.255.255.0 [RouterB-GigabitEthernet2/0/0] quit
# Configure RouterC.
<Huawei> system-view [Huawei] sysname RouterC [RouterC] interface loopback 0 [RouterC-LoopBack0] ip address 10.1.2.1 255.255.255.0 [RouterC-LoopBack0] quit [RouterC] interface gigabitethernet 1/0/0 [RouterC-GigabitEthernet1/0/0] ip address 30.1.1.2 255.255.255.0 [RouterC-GigabitEthernet1/0/0] quit
- Configure OSPF.
# Configure RouterA.
[RouterA] ospf 1 [RouterA-ospf-1] area 0 [RouterA-ospf-1-area-0.0.0.0] network 20.1.1.0 0.0.0.255 [RouterA-ospf-1-area-0.0.0.0] quit [RouterA-ospf-1] quit
# Configure RouterB.
[RouterB] ospf 1 [RouterB-ospf-1] area 0 [RouterB-ospf-1-area-0.0.0.0] network 20.1.1.0 0.0.0.255 [RouterB-ospf-1-area-0.0.0.0] network 30.1.1.0 0.0.0.255 [RouterB-ospf-1-area-0.0.0.0] quit [RouterB-ospf-1] quit
# Configure RouterC.
[RouterC] ospf 1 [RouterC-ospf-1] area 0 [RouterC-ospf-1-area-0.0.0.0] network 30.1.1.0 0.0.0.255 [RouterC-ospf-1-area-0.0.0.0] quit [RouterC-ospf-1] quit
# After the preceding configurations, run the display ip routing-table command on RouterA and RouterC. The command output shows that RouterA and RouterC have learned OSPF routes to the network segment of the peer.
# The following uses the display on RouterA as an example.
[RouterA] display ip routing-table protocol ospf Route Flags: R - relay, D - download to fib, T - to vpn-instance ------------------------------------------------------------------------------ Public routing table : OSPF Destinations : 1 Routes : 1 OSPF routing table status : <Active> Destinations : 1 Routes : 1 Destination/Mask Proto Pre Cost Flags NextHop Interface 30.1.1.0/24 OSPF 10 2 D 20.1.1.2 GigabitEthernet1/0/0 OSPF routing table status : <Inactive> Destinations : 0 Routes : 0
- Configure tunnel interfaces.
# Configure RouterA.
[RouterA] interface tunnel 0/0/15 [RouterA-Tunnel0/0/15] tunnel-protocol gre [RouterA-Tunnel0/0/15] ip address unnumbered interface loopback 0 [RouterA-Tunnel0/0/15] source 20.1.1.1 [RouterA-Tunnel0/0/15] destination 30.1.1.2 [RouterA-Tunnel0/0/15] quit
# Configure RouterC.
[RouterC] interface tunnel 0/0/15 [RouterC-Tunnel0/0/15] tunnel-protocol gre [RouterC-Tunnel0/0/15] ip address unnumbered interface loopback 0 [RouterC-Tunnel0/0/15] source 30.1.1.2 [RouterC-Tunnel0/0/15] destination 20.1.1.1 [RouterC-Tunnel0/0/15] quit
- Configure static routes.
# Configure RouterA.
[RouterA] ip route-static 10.1.2.0 24 tunnel 0/0/15
# Configure RouterC.
[RouterC] ip route-static 10.1.1.0 24 tunnel 0/0/15
- Verify the configuration.
# Ping 10.1.2.1 from RouterA.
[RouterA] ping 10.1.2.1 PING 10.1.2.1: 56 data bytes, press CTRL_C to break Reply from 10.1.2.1: bytes=56 Sequence=1 ttl=255 time=1 ms Reply from 10.1.2.1: bytes=56 Sequence=2 ttl=255 time=1 ms Reply from 10.1.2.1: bytes=56 Sequence=3 ttl=255 time=1 ms Reply from 10.1.2.1: bytes=56 Sequence=4 ttl=255 time=1 ms Reply from 10.1.2.1: bytes=56 Sequence=5 ttl=255 time=1 ms --- 10.1.2.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 1/1/1 ms
Configuration Files
Configuration file of RouterA
# sysname RouterA # interface GigabitEthernet1/0/0 ip address 20.1.1.1 255.255.255.0 # interface LoopBack0 ip address 10.1.1.1 255.255.225.0 # interface Tunnel0/0/15 ip address unnumbered interface LoopBack0 tunnel-protocol gre source 20.1.1.1 destination 30.1.1.2 # ospf 1 area 0.0.0.0 network 20.1.1.0 0.0.0.255 # ip route-static 10.1.2.0 255.255.255.0 Tunnel0/0/15 # return
Configuration file of RouterB
# sysname RouterB # interface GigabitEthernet1/0/0 ip address 20.1.1.2 255.255.255.0 # interface GigabitEthernet2/0/0 ip address 30.1.1.1 255.255.255.0 # ospf 1 area 0.0.0.0 network 20.1.1.0 0.0.0.255 network 30.1.1.0 0.0.0.255 # return
Configuration file of RouterC
# sysname RouterC # interface GigabitEthernet1/0/0 ip address 30.1.1.2 255.255.255.0 # interface LoopBack0 ip address 10.1.2.1 255.255.225.0 # interface Tunnel0/0/15 ip address unnumbered interface LoopBack0 tunnel-protocol gre source 30.1.1.2 destination 20.1.1.1 # ospf 1 area 0.0.0.0 network 30.1.1.0 0.0.0.255 # ip route-static 10.1.1.0 255.255.255.0 Tunnel0/0/15 # return