zoukankan      html  css  js  c++  java
  • GRE协议基础配置

    GRE(Generic Routing Encapsulation 通用路由协议)提供了一种协议的报文封装在另一个协议报文中的机制,使报文能够在异咱网络(如IPv4网络)中传输,而异咱报文传输的通道称为tunnel。

    GRE协议也可以做为VPN的第三层隧道(tunnel)协议,为VPN数据提供透明传输通道,Tunnel是一个虚拟的点对点连接,可以看成仅支持点对点连接的虚拟接口,这个接口提供一条通路,使封装的数据报能够这个通路上传输,并在一个Tunnel的两端分别在对数据报进行封装及解封装。

    AR2配置默认路由

    ip route-static 0.0.0.0 0 12.1.1.2

    AR3配置默认路由

    ip route-static 0.0.0.0 0 10.1.23.2 

    PC1测试与server1的连通性

     可以观察到跨越了公网的两个私网网段之间默认是无法直接通信的,此时可以通过GRE协议来实现通信

    配置GRE

    在路由器R2和R3上配置GRE tunnel

    R2配置

    interface Serial1/0/0
     link-protocol ppp
     ip address 10.1.12.1 255.255.255.0 
    
    interface GigabitEthernet0/0/0
     ip address 192.168.10.254 255.255.255.0
    
    interface Tunnel0/0/0
     ip address 172.16.1.1 255.255.255.0 
     tunnel-protocol gre
     source 10.1.12.1
     destination 10.1.23.3
    #
    ip route-static 0.0.0.0 0.0.0.0 10.1.12.2

    R3配置

    interface Serial1/0/1
     link-protocol ppp
     ip address 10.1.23.3 255.255.255.0 
    
    interface GigabitEthernet0/0/0
     ip address 192.168.20.254 255.255.255.0 
    
    interface Tunnel0/0/0
     ip address 172.16.1.2 255.255.255.0 
     tunnel-protocol gre
     source 10.1.23.3
     destination 10.1.12.1
    
    ip route-static 0.0.0.0 0.0.0.0 10.1.23.2

    R1配置

    interface Serial1/0/0
     link-protocol ppp
     ip address 10.1.12.2 255.255.255.0 
    #
    interface Serial1/0/1
     link-protocol ppp
     ip address 10.1.23.2 255.255.255.0 
    [R2]dis interface Tunnel 0/0/0
    Tunnel0/0/0 current state : UP
    Line protocol current state : UP
    Last line protocol up time : 2020-06-03 10:46:00 UTC-08:00
    Description:HUAWEI, AR Series, Tunnel0/0/0 Interface
    Route Port,The Maximum Transmit Unit is 1500
    Internet Address is 172.16.1.1/24
    Encapsulation is TUNNEL, loopback not set
    Tunnel source 10.1.12.1 (Serial1/0/0), destination 10.1.23.3
    Tunnel protocol/transport GRE/IP, key disabled
    keepalive disabled
    Checksumming of packets disabled
    Current system time: 2020-06-03 10:49:19-08:00
        300 seconds input rate 0 bits/sec, 0 packets/sec
        300 seconds output rate 8 bits/sec, 0 packets/sec
        0 seconds input rate 0 bits/sec, 0 packets/sec
        0 seconds output rate 0 bits/sec, 0 packets/sec
        0 packets input,  0 bytes
        0 input error
        5 packets output,  540 bytes
        0 output error
        Input bandwidth utilization  : --
        Output bandwidth utilization : --
    [R3]dis interface Tunnel 0/0/0
    Tunnel0/0/0 current state : UP
    Line protocol current state : UP
    Last line protocol up time : 2020-06-03 10:36:58 UTC-08:00
    Description:HUAWEI, AR Series, Tunnel0/0/0 Interface
    Route Port,The Maximum Transmit Unit is 1500
    Internet Address is 172.16.1.2/24
    Encapsulation is TUNNEL, loopback not set
    Tunnel source 10.1.23.3 (Serial1/0/1), destination 10.1.12.1
    Tunnel protocol/transport GRE/IP, key disabled
    keepalive disabled
    Checksumming of packets disabled
    Current system time: 2020-06-03 10:49:45-08:00
        300 seconds input rate 0 bits/sec, 0 packets/sec
        300 seconds output rate 0 bits/sec, 0 packets/sec
        0 seconds input rate 0 bits/sec, 0 packets/sec
        0 seconds output rate 0 bits/sec, 0 packets/sec
        0 packets input,  0 bytes
        0 input error
        5 packets output,  540 bytes
        0 output error
        Input bandwidth utilization  : --
        Output bandwidth utilization : --
    [R2]dis ip routing-table 
    Route Flags: R - relay, D - download to fib
    ------------------------------------------------------------------------------
    Routing Tables: Public
             Destinations : 15       Routes : 15       
    
    Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface
    
            0.0.0.0/0   Static  60   0          RD   10.1.12.2       Serial1/0/0
          10.1.12.0/24  Direct  0    0           D   10.1.12.1       Serial1/0/0
          10.1.12.1/32  Direct  0    0           D   127.0.0.1       Serial1/0/0
          10.1.12.2/32  Direct  0    0           D   10.1.12.2       Serial1/0/0
        10.1.12.255/32  Direct  0    0           D   127.0.0.1       Serial1/0/0
          127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
          127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
    127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
         172.16.1.0/24  Direct  0    0           D   172.16.1.1      Tunnel0/0/0
         172.16.1.1/32  Direct  0    0           D   127.0.0.1       Tunnel0/0/0
       172.16.1.255/32  Direct  0    0           D   127.0.0.1       Tunnel0/0/0
       192.168.10.0/24  Direct  0    0           D   192.168.10.254  GigabitEthernet
    0/0/0
     192.168.10.254/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
    0/0/0
     192.168.10.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
    0/0/0
    255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

    可能观察到R2和R3的路由表中已经有所配置隧道接口的路由条目,即R2和R3之间已经形成了类似点到点直连的逻辑链路,但是没有互相接收到对方的私网络信息

    配置基于GRE接口的动态路由协议

     还是连通不了

    R2上配置

    ospf 1 router-id 2.2.2.2 
     area 0.0.0.0 
      network 172.16.1.0 0.0.0.255 
      network 192.168.10.0 0.0.0.255 

    R3配置

    ospf 1 router-id 3.3.3.3 
     area 0.0.0.0 
      network 172.16.1.0 0.0.0.255 
      network 192.168.20.0 0.0.0.255 
    [R2]dis ip routing-table p o
    Route Flags: R - relay, D - download to fib
    ------------------------------------------------------------------------------
    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
    
       192.168.20.0/24  OSPF    10   1563        D   172.16.1.2      Tunnel0/0/0
    
    OSPF routing table status : <Inactive>
             Destinations : 0        Routes : 0
    [R3]dis ip routing-table p os
    Route Flags: R - relay, D - download to fib
    ------------------------------------------------------------------------------
    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
    
       192.168.10.0/24  OSPF    10   1563        D   172.16.1.1      Tunnel0/0/0
    
    OSPF routing table status : <Inactive>
             Destinations : 0        Routes : 0

    测试

  • 相关阅读:
    CodeForces 734F Anton and School
    CodeForces 733F Drivers Dissatisfaction
    CodeForces 733C Epidemic in Monstropolis
    ZOJ 3498 Javabeans
    ZOJ 3497 Mistwald
    ZOJ 3495 Lego Bricks
    CodeForces 732F Tourist Reform
    CodeForces 732E Sockets
    CodeForces 731E Funny Game
    CodeForces 731D 80-th Level Archeology
  • 原文地址:https://www.cnblogs.com/liujunjun/p/13036144.html
Copyright © 2011-2022 走看看