配置接口借用其它接口IP地址示例

组网需求

图1所示,SwitchA和SwitchC的Tunnel1接口不常用,没有配置IP地址,要求SwitchA和SwitchC借用Loopback口的IP地址后可以通过Tunnel口互通。

图1 配置Tunnel接口借用Loopback接口IP地址组网图
配置接口借用其它接口IP地址示例

配置思路

配置接口借用其他接口IP地址的配置思路如下:

  1. 在SwitchA、SwitchB和SwitchC上配置各接口的IP地址。
  2. 配置OSPF路由,实现SwitchA和SwitchC之间IPv4路由可达。
  3. 在SwitchA和SwitchC上创建Tunnel接口,配置GRE隧道,指定Tunnel的源地址和目的地址。
  4. 在SwitchA和SwitchC上配置Tunnel接口借用Loopback接口的IP地址。
  5. 在SwitchA和SwitchC上配置Tunnel路由,通过静态路由实现。

操作步骤

  1. 配置接口的IP地址 

    # 配置SwitchA。

    <HUAWEI> system-view
    [~HUAWEI] sysname SwitchA
    [*HUAWEI] commit
    [~SwitchA] vlan batch 10
    [*SwitchA] interface 10ge 1/0/1
    [*SwitchA-10GE1/0/1] port link-type trunk
    [*SwitchA-10GE1/0/1] port trunk allow-pass vlan 10
    [*SwitchA-10GE1/0/1] quit
    [*SwitchA] interface vlanif 10
    [*SwitchA-Vlanif10] ip address 10.2.1.1 24
    [*SwitchA-Vlanif10] quit
    [*SwitchA] interface loopback 0
    [*SwitchA-LoopBack0] ip address 10.1.1.1 24
    [*SwitchA-LoopBack0] quit
    [*SwitchA] commit

    # 配置SwitchB。

    <HUAWEI> system-view
    [~HUAWEI] sysname SwitchB
    [*HUAWEI] commit
    [~SwitchB] vlan batch 10 20
    [*SwitchB] interface 10ge 1/0/1
    [*SwitchB-10GE1/0/1] port link-type trunk
    [*SwitchB-10GE1/0/1] port trunk allow-pass vlan 10
    [*SwitchB-10GE1/0/1] quit
    [*SwitchB] interface 10ge 1/0/2
    [*SwitchB-10GE1/0/2] port link-type trunk
    [*SwitchB-10GE1/0/2] port trunk allow-pass vlan 20
    [*SwitchB-10GE1/0/2] quit
    [*SwitchB] interface vlanif 10
    [*SwitchB-Vlanif10] ip address 10.2.1.2 24
    [*SwitchB-Vlanif10] quit
    [*SwitchB] interface vlanif 20
    [*SwitchB-Vlanif20] ip address 10.3.1.1 24
    [*SwitchB-Vlanif20] quit
    [*SwitchB] commit

    # 配置SwitchC。

    <HUAWEI> system-view
    [~HUAWEI] sysname SwitchC
    [*HUAWEI] commit
    [~SwitchC] vlan batch 20
    [*SwitchC] interface 10ge 1/0/1
    [*SwitchC-10GE1/0/1] port link-type trunk
    [*SwitchC-10GE1/0/1] port trunk allow-pass vlan 20
    [*SwitchC-10GE1/0/1] quit
    [*SwitchC] interface vlanif 20
    [*SwitchC-Vlanif20] ip address 10.3.1.2 24
    [*SwitchC-Vlanif20] quit
    [*SwitchC] interface loopback 0
    [*SwitchC-LoopBack0] ip address 10.1.2.1 24
    [*SwitchC-LoopBack0] quit
    [*SwitchC] commit

     

  2. 配置设备间使用OSPF路由 

    # 配置SwitchA。

    [~SwitchA] ospf 1
    [*SwitchA-ospf-1] area 0
    [*SwitchA-ospf-1-area-0.0.0.0] network 10.2.1.0 0.0.0.255
    [*SwitchA-ospf-1-area-0.0.0.0] quit
    [*SwitchA-ospf-1] quit
    [*SwitchA] commit

    # 配置SwitchB。

    [~SwitchB] ospf 1
    [*SwitchB-ospf-1] area 0
    [*SwitchB-ospf-1-area-0.0.0.0] network 10.2.1.0 0.0.0.255
    [*SwitchB-ospf-1-area-0.0.0.0] network 10.3.1.0 0.0.0.255
    [*SwitchB-ospf-1-area-0.0.0.0] quit
    [*SwitchB-ospf-1] quit
    [*SwitchB] commit

    # 配置SwitchC。

    [~SwitchC] ospf 1
    [*SwitchC-ospf-1] area 0
    [*SwitchC-ospf-1-area-0.0.0.0] network 10.3.1.0 0.0.0.255
    [*SwitchC-ospf-1-area-0.0.0.0] quit
    [*SwitchC-ospf-1] quit
    [*SwitchC] commit

     

  3. Tunnel1接口借用Loopback0接口的IP地址并配置GRE隧道 

    # 配置SwitchA(CE12800)。

    [~SwitchA] ip tunnel mode gre
    [*SwitchA] commit
    配置接口借用其它接口IP地址示例

    配置完成后,需要保存配置并重启设备才能生效。您可以选择立即重启或完成所有配置后再重启。

    [~SwitchA] interface tunnel 1
    [*SwitchA-Tunnel1] tunnel-protocol gre
    [*SwitchA-Tunnel1] ip address unnumbered interface loopback 0
    [*SwitchA-Tunnel1] source 10.2.1.1
    [*SwitchA-Tunnel1] destination 10.3.1.2
    [*SwitchA-Tunnel1] quit
    [*SwitchA] commit

    # 配置SwitchC(CE12800)。

    [~SwitchC] ip tunnel mode gre
    [*SwitchC] commit
    配置接口借用其它接口IP地址示例

    配置完成后,需要保存配置并重启设备才能生效。您可以选择立即重启或完成所有配置后再重启。

    [~SwitchC] interface tunnel 1
    [*SwitchC-Tunnel1] tunnel-protocol gre
    [*SwitchC-Tunnel1] ip address unnumbered interface loopback 0
    [*SwitchC-Tunnel1] source 10.3.1.2
    [*SwitchC-Tunnel1] destination 10.2.1.1
    [*SwitchC-Tunnel1] quit
    [*SwitchC] commit

     

  4. 配置静态路由 

    # 配置SwitchA。

    [~SwitchA] ip route-static 10.1.2.0 255.255.255.0 tunnel 1
    [*SwitchA] commit

    # 配置SwitchC。

    [~SwitchC] ip route-static 10.1.1.0 255.255.255.0 tunnel 1
    [*SwitchC] commit

     

  5. 检查配置结果 

    # 在SwitchA上Ping地址10.1.2.1。

    [~SwitchA] 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=2 ms
        Reply from 10.1.2.1: bytes=56 Sequence=2 ttl=255 time=3 ms
        Reply from 10.1.2.1: bytes=56 Sequence=3 ttl=255 time=3 ms
        Reply from 10.1.2.1: bytes=56 Sequence=4 ttl=255 time=3 ms
        Reply from 10.1.2.1: bytes=56 Sequence=5 ttl=255 time=3 ms
    
      --- 10.1.2.1 ping statistics ---
        5 packet(s) transmitted
        5 packet(s) received
        0.00% packet loss
        round-trip min/avg/max = 2/2/3 ms
    

     

配置文件

  • SwitchA的配置文件(CE12800)
    #
    sysname SwitchA
    #
    vlan batch 10
    # ip tunnel mode gre
    #
    interface Vlanif10
     ip address 10.2.1.1 255.255.255.0
    #
    interface 10GE1/0/1
     port link-type trunk
     port trunk allow-pass vlan 10
    #
    interface LoopBack0
     ip address 10.1.1.1 255.255.225.0
    #
    interface Tunnel1
     ip address unnumbered interface LoopBack0
     tunnel-protocol gre
     source 10.2.1.1
     destination 10.3.1.2
    #
    ospf 1
     area 0.0.0.0
      network 10.2.1.0 0.0.0.255
    #
    ip route-static 10.1.2.0 255.255.255.0 Tunnel1
    #
    return
  • SwitchB的配置文件
    #
    sysname SwitchB
    #
    vlan batch 10 20
    #
    interface Vlanif10
     ip address 10.2.1.2 255.255.255.0
    #
    interface Vlanif20
     ip address 10.3.1.1 255.255.255.0
    #
    interface 10GE1/0/1
     port link-type trunk
     port trunk allow-pass vlan 10
    #
    interface 10GE1/0/2
     port link-type trunk
     port trunk allow-pass vlan 20
    #
    ospf 1
     area 0.0.0.0
      network 10.2.1.0 0.0.0.255
      network 10.3.1.0 0.0.0.255
    #
    return
  • SwitchC的配置文件(CE12800)
    #
    sysname SwitchC
    #
    vlan batch 20
    # ip tunnel mode gre
    #
    interface Vlanif20
     ip address 10.3.1.2 255.255.255.0
    #
    interface 10GE1/0/1
     port link-type trunk
     port trunk allow-pass vlan 20
    #
    interface LoopBack0
     ip address 10.1.2.1 255.255.225.0
    #
    interface Tunnel1
     ip address unnumbered interface LoopBack0
     tunnel-protocol gre
     source 10.3.1.2
     destination 10.2.1.1
    #
    ospf 1
     area 0.0.0.0
      network 10.3.1.0 0.0.0.255
    #
    ip route-static 10.1.1.0 255.255.255.0 Tunnel1
    #
    return
阅读剩余
THE END