HCIP-IERS部署企业级路由交换网络_BGP协议特性与配置_BGP故障排除

目录

第三章 BGP协议特性与配置

实验 3-6 BGP故障排除

学习目的

拓扑图

场景

学习任务

步骤一.基础配置与IP编址

步骤二.配置IGP及BGP

步骤三.排除对等建立的故障

步骤四.BGP安全

附加实验: 思考并验证

最终设备配置


第三章 BGP协议特性与配置

实验 3-6 BGP故障排除

学习目的

·掌握BGP邻居无法建立的故障排除

·掌握BGP相关Debug命令的使用

拓扑图

图3-6 BGP故障排除

场景

你是公司的网络管理员。公司的网络采用了BGP协议作为路由协议。公司的网络由多个自治系统组成,不同的分支机构使用了不同的AS号。现在你已经完成公司网络的搭建工作,可是在配置BGP的过程中你遇到了不少问题,最后你通过故障排除的思想和方法,你成功的找到了各种错误,并进行了网络的故障排除。

学习任务

步骤一.基础配置与IP编址

首先给所有路由器配置物理接口及Loopback接口的IP地址和掩码,各Loopback接口均为32位掩码,地址的规划如拓扑图中所示。

<R1>system-view

Enter system view, return user view with Ctrl+Z.

[R1]interface Serial 1/0/0

[R1-Serial1/0/0]ip address 10.0.12.1 24

[R1-Serial1/0/0]quit

[R1]interface LoopBack 0

[R1-LoopBack0]ip add 10.0.1.1 32

[R1-LoopBack0]quit

[R2]interface Serial 1/0/0

[R2-Serial1/0/0]ip address 10.0.12.2 24

[R2-Serial1/0/0]quit

[R2]interface Serial 2/0/0

[R2-Serial2/0/0]ip address 10.0.23.2 24

[R2-Serial2/0/0]quit

[R2]interface LoopBack 0

[R2-LoopBack0]ip address 10.0.2.2 32

[R2-LoopBack0]quit

[R3]interface Serial 2/0/0

[R3-Serial2/0/0]ip address 10.0.23.3 24

[R3-Serial2/0/0]quit

[R3]interface LoopBack 0

[R3-LoopBack0]ip address 10.0.3.3 32

[R3-LoopBack0]quit

配置完成后,测试直连链路的连通性。

[R2]ping -c 1 10.0.12.1

  PING 10.0.12.1: 56  data bytes, press CTRL_C to break

    Reply from 10.0.12.1: bytes=56 Sequence=1 ttl=255 time=40 ms

  --- 10.0.12.1 ping statistics ---

    1 packet(s) transmitted

    1 packet(s) received

    0.00% packet loss

    round-trip min/avg/max = 40/40/40 ms

[R2]ping -c 1 10.0.23.3

  PING 10.0.23.3: 56  data bytes, press CTRL_C to break

    Reply from 10.0.23.3: bytes=56 Sequence=1 ttl=255 time=38 ms

  --- 10.0.23.3 ping statistics ---

    1 packet(s) transmitted

    1 packet(s) received

    0.00% packet loss

round-trip min/avg/max = 38/38/38 ms

结果显示直连链路连通性正常。

步骤二.配置IGP及BGP

在这个场景中,在AS 64512内部我们使用OSPF作为IGP,所有设备属于区域0。各路由器使用Loopback0的地址作为Router ID。R1的S1/0/0和Loopback 0所连接的网段运行OSPF。

[R1]router-id 10.0.1.1

[R1]ospf 1

[R1-ospf-1]area 0

[R1-ospf-1-area-0.0.0.0]network 10.0.12.1 0.0.0.0

[R1-ospf-1-area-0.0.0.0]network 10.0.1.1 0.0.0.0

[R1-ospf-1-area-0.0.0.0]quit

[R1-ospf-1]quit

R2的S1/0/0和Loopback 0所连接的网段运行OSPF。

[R2]router id 10.0.2.2

[R2]ospf 1

[R2-ospf-1]area 0

[R2-ospf-1-area-0.0.0.0]network 10.0.12.2 0.0.0.0

[R2-ospf-1-area-0.0.0.0]network 10.0.2.2 0.0.0.0

[R2-ospf-1-area-0.0.0.0]quit

[R2-ospf-1]quit

配置完成以后检查R1到R2的Loopback0地址的连通性。

[R1]ping -c 1 -a 10.0.1.1 10.0.2.2    

  PING 10.0.2.2: 56  data bytes, press CTRL_C to break

    Reply from 10.0.2.2: bytes=56 Sequence=1 ttl=255 time=40 ms

  --- 10.0.2.2 ping statistics ---

    1 packet(s) transmitted

    1 packet(s) received

    0.00% packet loss

    round-trip min/avg/max = 40/40/40 ms

在R1、R2之间配置IBGP,在R2和R3之间配置EBGP,均使用Loopback地址建立对等体关系,为保证路由信息的正常传递,在R2上针对R1配置Next-hop-local,在R3上你错误的将对等体10.0.2.2的AS号配置为64514了。

[R1]bgp 64512

[R1-bgp]peer 10.0.2.2 as-number 64512

[R1-bgp]quit

[R2]bgp 64512

[R2-bgp]peer 10.0.1.1 as-number 64512

[R2-bgp]peer 10.0.1.1 next-hop-local

[R2-bgp]peer 10.0.3.3 as-number 64513

[R2-bgp]quit

[R3]router id 10.0.3.3

[R3]bgp 64513

[R3-bgp]peer 10.0.2.2 as-number 64514

[R3-bgp]quit

步骤三.排除对等建立的故障

在完成上面的配置以后,你发现路由器之间对等体关系并没有建立起来,首先在R2上观察对等体关系。

[R2]display bgp peer

 BGP local router ID : 10.0.2.2

 Local AS number : 64512

 Total number of peers : 2                Peers in established state : 0

  Peer          V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  10.0.1.1      4       64512        0        0     0  00:05:36      Active 0

  10.0.3.3      4       64513        0        0     0  00:05:21        Idle 0

从上面的输出中我们可以看到,10.0.1.1的状态为Active,10.0.3.3的状态为Idle。BGP对等体关系建立正常的情况下,State的状态应为Established。长时间停留在其他状态均为故障的现象,下面将逐步排除各种故障。

一般情况下,当对等体IP地址对于本地路由器是不可达的时,对等体状态会显示为Idle。也就是路由器根本没有向对等体发起TCP连接。当对等体IP地址可达,但TCP连接建立存在问题时,就可以看到对等体之间停留在Active状态。

首先考虑R2与R3之间的对等体关系的问题,先检查R2和R3之间Loopback地址之间的连通性。

[R2]ping -c 1 -a 10.0.2.2 10.0.3.3

  PING 10.0.3.3: 56  data bytes, press CTRL_C to break

    Request time out

  --- 10.0.3.3 ping statistics ---

    1 packet(s) transmitted

    0 packet(s) received

100.00% packet loss

发现R2与R3的Loopback0接口地址之间的通讯存在问题。

检查R2的路由表。

[R2]display ip routing-table

Route Flags: R - relay, D - download to fib

----------------------------------------------------------------------------

Routing Tables: Public

         Destinations : 14       Routes : 14       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.0.1.1/32 OSPF  10   1562        D   10.0.12.1       Serial1/0/0

       10.0.2.2/32 Direct  0    0           D   127.0.0.1       LoopBack0

      10.0.12.0/24 Direct  0    0           D   10.0.12.2       Serial1/0/0

      10.0.12.1/32 Direct  0    0           D   10.0.12.1       Serial1/0/0

      10.0.12.2/32 Direct  0    0           D   127.0.0.1       Serial1/0/0

    10.0.12.255/32 Direct  0    0           D   127.0.0.1       Serial1/0/0

      10.0.23.0/24 Direct  0    0           D   10.0.23.2       Serial2/0/0

      10.0.23.2/32 Direct  0    0           D   127.0.0.1       Serial2/0/0

      10.0.23.3/32 Direct  0    0           D   10.0.23.3       Serial2/0/0

    10.0.23.255/32 Direct  0    0           D   127.0.0.1       Serial2/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/32Direct  0    0           D   127.0.0.1       InLoopBack0

255.255.255.255/32Direct  0    0           D   127.0.0.1       InLoopBack0

发现没有到达地址10.0.3.3的路由。

检查R3的路由表。

[R3]display ip routing-table

Route Flags: R - relay, D - download to fib

----------------------------------------------------------------------------

Routing Tables: Public

         Destinations : 9        Routes : 9        

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.0.3.3/32 Direct  0    0           D   127.0.0.1       LoopBack0

      10.0.23.0/24 Direct  0    0           D   10.0.23.3       Serial2/0/0

      10.0.23.2/32 Direct  0    0           D   10.0.23.2       Serial2/0/0

      10.0.23.3/32 Direct  0    0           D   127.0.0.1       Serial2/0/0

    10.0.23.255/32 Direct  0    0           D   127.0.0.1       Serial2/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/32Direct  0    0           D   127.0.0.1       InLoopBack0

255.255.255.255/32Direct  0    0           D   127.0.0.1       InLoopBack0

也没有到达R2的Loopback0地址10.0.2.2的路由。

对于不同的AS,使用静态路由可以实现相邻路由器的Loopback接口地址之间的可达性。

在这里,我们需要在R2和R3上分别添加到对端Loopback接口连接网段的静态路由。

[R2]ip route-static 10.0.3.3 32 10.0.23.3

[R3]ip route-static 10.0.2.2 32 10.0.23.2

检查R2到R3之间的连通性。

[R2]ping -c 1 -a 10.0.2.2 10.0.3.3

  PING 10.0.3.3: 56  data bytes, press CTRL_C to break

    Reply from 10.0.3.3: bytes=56 Sequence=1 ttl=255 time=30 ms

  --- 10.0.3.3 ping statistics ---

    1 packet(s) transmitted

    1 packet(s) received

    0.00% packet loss

round-trip min/avg/max = 30/30/30 ms

检查R2的BGP对等体关系。

[R2]display bgp peer         

 BGP local router ID : 10.0.2.2

 Local AS number : 64512

 Total number of peers : 2                Peers in established state : 0

  Peer           V         AS  MsgRcvd  MsgSent  OutQ  Up/Down      State PrefRcv

  10.0.1.1      4       64512        0        0     0 05:23:27      Active       0

  10.0.3.3      4       64513        0        0     0 05:23:02      Active       0

R2和R3之间的状态由刚才的Idle状态转变为Active状态。

接下来考虑R1和R2之间的对等体关系,刚才在配置OSPF之后已经验证了R1的Loopback接口地址到R2的Loopback接口地址之间的连通性。

BGP是通过TCP 179端口进行通信的。首先检查路由器的179端口是否处于打开状态。

在R1和R2上分别检查TCP状态。

[R1]display tcp status

TCPCB    Tid/Soid  Local Add:port       Foreign Add:port      VPNID  State

37a32f14  76 /1 0.0.0.0:80             0.0.0.0:0 23553 Listening

37a33b34  239/2 0.0.0.0:179            10.0.2.2:0 0 Listening

37a3321c  76  /3 0.0.0.0:443            0.0.0.0:0 23553 Listening

[R2]display tcp status

TCPCB    Tid/Soid Local Add:port       Foreign Add:port     VPNID  State

37a32f14 76 /1    0.0.0.0:80            0.0.0.0:0             23553  Listening

37a33b34 239/2    0.0.0.0:179           10.0.1.1:0            0      Listening

390888bc 239/4    0.0.0.0:179           10.0.3.3:0            0      Listening

37a3321c 76 /3    0.0.0.0:443           0.0.0.0:0             23553  Listening

可以看到,对等体之间对应地址的179端口均处于监听状态。显示BGP协议在单个路由器上工作正常。

然后通过debug命令在R1上观察是否收到R2发来的BGP数据包。

<R1>terminal monitor

<R1>terminal debugging

<R1>debugging tcp packet

Nov 16 2016 16:34:56.300.1+00:00 R1 SOCKET/7/TCP PACKET:

TCP debug packet information:

1479314096: Input: no port,

(src = 10.0.12.2:64316,dst = 10.0.1.1:179,VrfIndex = 0,seq = 4034991477,

ack = 0,datalen = 0,optlen = 4,flag =  SYN ,window = 16384,ttl = 0,tos = 0,MSS = 0)

Nov 16 2016 16:34:56.300.2+00:00 R1 SOCKET/7/TCP PACKET:

TCP debug packet information:

1479314096: Output: task = (0), socketid = 0,

(src = 10.0.1.1:179,dst = 10.0.12.2:64316,VrfIndex = 0,seq = 0,

ack = 4034991478,datalen = 0,optlen = 0,flag =  ACK  RST ,window = 0,ttl = 255,tos = 0,MSS = 0)

<R1>undo debugging all

Info: All possible debugging has been turned off

从上面的输出中可以看到R2发来的目的端口号为179的数据包的源地址为10.0.12.2。查看拓扑后发现该地址为R2的Serial1/0/0的接口地址。

在建立对等体关系时,使用的是R2的Loopback接口地址,这就造成R1和R2之间的对等体关系建立不起来。所以我们需要在建立对等体关系时需使用connect-interface指定更新源地址。

同样的,R2和R3之间也存在这个问题。在这里,一并进行修改。

[R1]bgp 64512

[R1-bgp]peer 10.0.2.2 connect-interface LoopBack 0

[R1-bgp]quit

[R2]bgp 64512

[R2-bgp]peer 10.0.1.1 connect-interface LoopBack 0

[R2-bgp]peer 10.0.3.3 connect-interface LoopBack 0

[R2-bgp]quit

[R3]bgp 64513

[R3-bgp]peer 10.0.2.2 connect-interface LoopBack 0

[R3-bgp]quit

修改完成以后再次在R2上检查对等体关系。

[R2]display bgp peer

 BGP local router ID : 10.0.2.2

 Local AS number : 64512

 Total number of peers : 2                Peers in established state : 1

  Peer           V         AS  MsgRcvd  MsgSent  OutQ  Up/Down       State  PrefRcv

  10.0.1.1      4       64512       16       17 0 00:14:18 Established 0

  10.0.3.3      4       64513        0        0 0 00:14:35        Idle 0

看到R1与R2之间的状态已经是Established状态了。

在R3上使用debug命令测试是否收到BGP数据包,并检查数据包的内容。

<R3>terminal monitor

<R3>terminal debugging

<R3>debugging ip packet

Nov 16 2016 16:52:11.880.4+00:00 R3 IP/7/debug_case:

Receiving, interface = Serial2/0/0, version = 4, headlen = 20, tos = 192,

pktlen = 40, pktid = 3446, offset = 0, ttl = 1, protocol = 6,

checksum = 37526, s = 10.0.2.2, d = 10.0.3.3

prompt: Out interface if is loopback0 and packet is going to IP Distribute.

<R3>undo debugging all

Info: All possible debugging has been turned off

注意到R3收到的BGP数据包TTL值为1。对于EBGP来说,路由器向对等体发送的数据包默认的TTL就是1。

在这个场景中,R2和R3之间使用Loopback地址建立对等体关系。从R2的Loopback地址到R3的Loopback地址有2跳。所以该数据包在还没有到达R2的Loopback地址之前就因为TTL超时被丢弃了。

为了解决这个问题,我们需要修改EBGP对等体之间发送的数据包的TTL值。

[R2]bgp 64512

[R2-bgp]peer 10.0.3.3 ebgp-max-hop 2

[R2-bgp]quit

[R3]bgp 64513

[R3-bgp]peer 10.0.2.2 ebgp-max-hop 2

[R3-bgp]quit

配置完成以后,在R2上重新检查对等体之间的关系。

[R2]display bgp peer

 BGP local router ID : 10.0.2.2

 Local AS number : 64512

 Total number of peers : 2                Peers in established state : 1

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  10.0.1.1        4       64512        3        4     0 00:01:34 Established       0

  10.0.3.3        4       64513        0        1     0 00:00:44       Idle          0

R2和R3之间仍停留在Idle状态。

在R3上检查BGP的错误。

[R3]display bgp error

Error Type    : Peer Error

 Date/Time     : 2016/11/16 17:01:48    

 Peer Address  : 10.0.2.2

 VRF Name      : Public

 Error Info    : Incorrect remote AS

 Error Type    : Peer Error

 Date/Time     : 2016/11/16 17:03:06    

 Peer Address  : 10.0.2.2

 VRF Name      : Public

 Error Info    : Incorrect remote AS

 Error Type    : Peer Error

 Date/Time     : 2016/11/16 17:03:38    

 Peer Address  : 10.0.2.2

 VRF Name      : Public

 Error Info    : Incorrect remote AS

<R3>terminal debugging

<R3>debugging bgp packet

Nov 16 2016 17:10:02.860.2+00:00 R3 RM/6/RMDEBUG:

 BGP.Public: Err/SubErr: 2/2 Errdata: 41040000fc00

 Identified in OPEN MSG from 10.0.2.2.

Nov 16 2016 17:10:02.860.3+00:00 R3 RM/6/RMDEBUG:

Nov 16 2016 17:10:02.860.4+00:00 R3 RM/6/RMDEBUG:

 BGP.Public: Err/SubErr: 2/2 Errdata: 41040000fc00

 Identified in OPEN MSG from 10.0.2.2.

出现的是AS号错误的消息。

使用debug命令来诊断该错误。

从上面的输出中我们可以看到,错误号/子错误号是2。翻阅文档可知,该错误就是AS号不匹配。接下来我们在R3上修改对等体的AS号。

[R3]bgp 64513

[R3-bgp]undo peer 10.0.2.2

[R3-bgp]peer 10.0.2.2 as-number 64512

[R3-bgp]peer 10.0.2.2 ebgp-max-hop 2

[R3-bgp]peer 10.0.2.2 connect-interface LoopBack0

[R3-bgp]quit

这时再检查R2和R3之间的对等体关系。

[R2]display bgp peer

 BGP local router ID : 10.0.2.2

 Local AS number : 64512

 Total number of peers : 2                Peers in established state : 2

  Peer          V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  10.0.1.1      4       64512       81       82 0 01:19:18 Established      0

  10.0.3.3      4       64513        3        4 0 00:01:12 Established      0

步骤四.BGP安全

BGP通常用在骨干网上,其安全性显得尤为重要。一旦BGP路由器被攻击,将会造成大面积网络瘫痪。

通常为了防止非法恶意用户冒充合法路由器与BGP路由器建立对等体关系,在BGP对等体会话之间会设置MD5认证。

R1和R2之间开启MD5的认证。首先设置一个错误的密码。在R1上设置密码为huawei,在R2上设置密码为123,观察对等体关系的变化情况。

[R1]bgp 64512

[R1-bgp]peer 10.0.2.2 password simple huawei

[R1-bgp]quit

[R2]bgp 64512

[R2-bgp]peer 10.0.1.1 password simple 123

[R2-bgp]quit

在R1上重置BGP对等体关系,这时可以观察到R1与R2的对等体关系已停留在Connect和Active状态。无法进入Established状态。

<R1>reset bgp 10.0.2.2

[R1]display bgp peer

 BGP local router ID : 10.0.1.1

 Local AS number : 64512

 Total number of peers : 1                Peers in established state : 0

  Peer          V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  10.0.2.2      4       64512        0        0     0 00:03:39     Connect       0

我们把R2的密码改成huawei。

[R2]bgp 64512

[R2-bgp]undo peer 10.0.1.1 password

[R2-bgp]peer 10.0.1.1 password simple huawei

[R2-bgp]quit

等待约半分钟,再次查看对等体关系。

 [R2]display bgp peer

 BGP local router ID : 10.0.2.2

 Local AS number : 64512

 Total number of peers : 2                Peers in established state : 2

  Peer          V          AS  MsgRcvd  MsgSent  OutQ  Up/Down      State  PrefRcv

  10.0.1.1      4       64512        2        2 0 00:00:34 Established     0

  10.0.3.3      4       64513      166      167 0 02:44:05 Established     0

这时,R1和R2之间的对等体关系已经到达了Established状态。

在这个场景中AS 64512的管理员不希望AS64513中的路由器看自己的真实AS号。

fake-as的功能就能达到这个目的,该命令可以用来为本端对等体指定一个伪AS号。

我们在R2上针对R3配置这条命令,伪装以后的AS号为100。

同时,也要修改R3配置的BGP对等体R2的AS号。

[R2]bgp 64512

[R2-bgp]peer 10.0.3.3 fake-as 100

[R2-bgp]quit

[R3]bgp 64513

[R3-bgp]undo peer 10.0.2.2

[R3-bgp]peer 10.0.2.2 as-number 100

[R3-bgp]peer 10.0.2.2 ebgp-max-hop 2

[R3-bgp]peer 10.0.2.2 connect-interface LoopBack0

[R3-bgp]quit

在R3上检查对等体,发现R2的AS号已经变成了100。

[R3]display bgp peer

 BGP local router ID : 10.0.3.3

 Local AS number : 64513

 Total number of peers : 1                Peers in established state : 1

  Peer          V         AS  MsgRcvd  MsgSent  OutQ  Up/Down       State   PrefRcv

  10.0.2.2     4         100        2        2     0 00:00:28   Established      0

在R2上发布自己的Loopback 0接口所在网段,观察在R3上学习到的BGP路由的AS-Path属性。

[R2]bgp 64512

[R2-bgp]network 10.0.2.2 32

[R2-bgp]quit

[R3]display bgp routing-table

 BGP Local router ID is 10.0.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 1

      Network            NextHop        MED       LocPrf    PrefVal Path/Ogn

     10.0.2.2/32        10.0.2.2        0                      0      100i

可以看到在R3上学习到的路由10.0.2.2/32的AS-Path是100,即R3认为该路由是在AS100始发的,这样就达到了隐藏AS 64512的目的。

BGP还提供了一种安全特性:GTSM。该特性通过检测IP报文头中的TTL值是否在一个预先定义好的范围内来对路由器进行保护。也就是说,若收到的BGP报文的TTL值超出了预先设定的值的范围以后,就丢弃该报文。注意GTSM和ebgp-max-hop功能均会影响到发送出去的BGP报文的TTL值,存在冲突。只能对同一对等体或对等体组使能两种功能中的一种。

在这个场景中,我们对R2和R3之间的链路开启该特性,观察BGP报文的交互。首先在R2的系统视图下设置违背GTSM规则的缺省动作,在这里我们选择drop,即不符合要求的BGP数据包将会被丢弃。

[R2]gtsm default-action drop

然后在BGP视图下针对R3开启GTSM特性。在配置之前需先要删除ebgp-max-hop的配置,注意这里从R2和R3是直连的,所以这里的valid-ttl-hops参数填1。

[R2]bgp 64512

[R2-bgp]undo peer 10.0.3.3 ebgp-max-hop  

[R2-bgp]peer 10.0.3.3 valid-ttl-hops 1

[R2-bgp]peer 10.0.1.1 valid-ttl-hops 1

[R2-bgp]quit

在R1和R3上进行相同的操作。

[R1]gtsm default-action drop

[R1]bgp 64512

[R1-bgp]peer 10.0.2.2 valid-ttl-hops 1

[R1-bgp]quit

[R3]gtsm default-action drop

[R3]bgp 64513

[R3-bgp]undo  peer 10.0.2.2 ebgp-max-hop

[R3-bgp]peer 10.0.2.2 valid-ttl-hops 1

[R3-bgp]quit

检查R2和R3之间的对等体关系。

[R3]dis bgp peer

 BGP local router ID : 10.0.3.3

 Local AS number : 64513

 Total number of peers : 1                Peers in established state : 1

  Peer          V          AS  MsgRcvd  MsgSent  OutQ  Up/Down      State PrefRcv

  10.0.2.2      4         100        3        2     0 00:00:06   Established     1

在R3上观察使用了该命令以后BGP报文TTL值的变化。

<R3>terminal monitor

<R3>terminal debugging

<R3>debugging ip packet

Nov 16 2016 17:24:45.340.1+00:00 R3 IP/7/debug_case:

Receiving, interface = S2/0/0, version = 4, headlen = 20, tos = 192,

pktlen = 59, pktid = 4015, offset = 0, ttl = 255, protocol = 6,

checksum = 37449, s = 10.0.2.2, d = 10.0.3.3

prompt: Receiving IP packet from S2/0/0

   

45 c0 00 3b 0f af 00 00 ff 06 92 49 0a 00 02 02

0a 00 03 03

Nov 16 2016 17:24:45.340.2+00:00 R3 IP/7/debug_case:

Receiving, interface = Serial2/0/0, version = 4, headlen = 20, tos = 192,

pktlen = 59, pktid = 4015, offset = 0, ttl = 255, protocol = 6,

checksum = 37449, s = 10.0.2.2, d = 10.0.3.3

prompt: IP Process By Board Begin!

   

45 c0 00 3b 0f af 00 00 ff 06 92 49 0a 00 02 02

0a 00 03 03

<R3>undo debugging all

Info: All possible debugging has been turned off

这时看到R3接收到的从R2发来的数据包的TTL值为255,而不是EBGP的默认值1。为了确认GTSM会丢弃TTL不合规定的BGP数据包,我们首先在R3上打开GTSM日志记录功能,当有数据包被GTSM丢弃时就记录相应信息。

[R3]gtsm log drop-packet all

然后在R2上配置ebgp-max-hop命令,使R2发给R3的BGP数据包的TTL值小于254。

[R2]bgp 64512

[R2-bgp]undo peer 10.0.3.3 valid-ttl-hops

[R2-bgp]peer 10.0.3.3 ebgp-max-hop 253

[R2-bgp]quit

等待一段时间以后,可以看到R2和R3之间的对等体关系进入了IDLE状态。现在R3上查看GTSM统计信息可以发现,已经有数据包被GTSM丢弃了。

[R3]

Nov 16 2016 17:30:44+00:00 R3 %%01BGP/3/STATE_CHG_UPDOWN(l)[6]:The status of the peer 10.0.2.2 changed from ESTABLISHED to IDLE. (InstanceName=Public, StateChangeReason=Hold Timer Expired)

[R3]display gtsm statistics all

GTSM Statistics Table

----------------------------------------------------------------

SlotId Protocol  Total Counters  Drop Counters  Pass Counters  

----------------------------------------------------------------

 0      BGP 29              15             14             

 0      BGPv6 0               0              0              

 0      OSPF 0               0              0              

 0      LDP 0               0              0              

 0      OSPFv3 0               0              0              

 0      RIP 0               0              0              

----------------------------------------------------------------

把R2的配置修改回来,间隔一段时间以后再观察是否有数据包被丢弃掉。

[R2]bgp 64512

[R2-bgp]undo peer 10.0.3.3 ebgp-max-hop

[R2-bgp]peer 10.0.3.3 valid-ttl-hops 1

[R2-bgp]quit

[R3]display gtsm statistics all

GTSM Statistics Table

----------------------------------------------------------------

SlotId Protocol  Total Counters  Drop Counters  Pass Counters  

----------------------------------------------------------------

 0      BGP 69              37            32             

 0      BGPv6 0               0              0              

 0      OSPF 0               0              0              

 0      LDP 0               0              0              

 0      OSPFv3 0               0              0              

 0      RIP 0               0              0              

----------------------------------------------------------------

这时我们看到已经没有新的数据包被丢弃掉了。

附加实验: 思考并验证

GTSM主要用于防止哪种类型的攻击?

在联盟环境中是否可以使用fake-as?

最终设备配置

<R1>display current-configuration

[V200R007C00SPC600]

#

 sysname R1

#

router id 10.0.1.1

#

gtsm default-action drop

#

interface Serial1/0/0

 link-protocol ppp

 ip address 10.0.12.1 255.255.255.0

#

interface LoopBack0

 ip address 10.0.1.1 255.255.255.255

#

bgp 64512

 peer 10.0.2.2 as-number 64512

 peer 10.0.2.2 connect-interface LoopBack0

 peer 10.0.2.2 password simple huawei

 peer 10.0.2.2 valid-ttl-hops 1

 #

 ipv4-family unicast

  undo synchronization

  peer 10.0.2.2 enable

#

ospf 1 router-id 10.0.1.1

 area 0.0.0.0

  network 10.0.12.1 0.0.0.0

  network 10.0.1.1 0.0.0.0

#

return

<R2>display current-configuration 

[V200R007C00SPC600]

#

 sysname R2

#

router id 10.0.2.2

#

gtsm default-action drop

#

acl number 2001  

 rule 5 permit source 10.0.2.2 0

#

interface Serial1/0/0

 link-protocol ppp

 ip address 10.0.12.2 255.255.255.0

#

interface Serial2/0/0

 link-protocol ppp

 ip address 10.0.23.2 255.255.255.0

#

interface LoopBack0

 ip address 10.0.2.2 255.255.255.255

#

bgp 64512

 peer 10.0.1.1 as-number 64512

 peer 10.0.1.1 connect-interface LoopBack0

 peer 10.0.1.1 password simple huawei

 peer 10.0.1.1 valid-ttl-hops 1

 peer 10.0.3.3 as-number 64513

 peer 10.0.3.3 connect-interface LoopBack0

 peer 10.0.3.3 fake-as 100

 peer 10.0.3.3 valid-ttl-hops 1

 #

 ipv4-family unicast

  undo synchronization

  network 10.0.2.2 255.255.255.255

  peer 10.0.1.1 enable                    

  peer 10.0.1.1 next-hop-local

  peer 10.0.3.3 enable

#

ospf 1 router-id 10.0.2.2

 area 0.0.0.0

  network 10.0.12.2 0.0.0.0

  network 10.0.2.2 0.0.0.0

#

route-policy change_origin deny node 10

 if-match acl 2001

apply origin egp 100

#

 ip route-static 10.0.3.3 255.255.255.255 10.0.23.3

#

return

<R3>display current-configuration

[V200R007C00SPC600]

#

 sysname R3

#

router id 10.0.3.3

#

gtsm default-action drop

 gtsm log drop-packet all

#

interface Serial2/0/0

 link-protocol ppp

 ip address 10.0.23.3 255.255.255.0

#

interface LoopBack0

 ip address 10.0.3.3 255.255.255.255

#

bgp 64513

 peer 10.0.2.2 as-number 100

 peer 10.0.2.2 connect-interface LoopBack0

 peer 10.0.2.2 valid-ttl-hops 1

 #

 ipv4-family unicast

  undo synchronization

  peer 10.0.2.2 enable

#

 ip route-static 10.0.2.2 255.255.255.255 10.0.23.2

#

return

猜你喜欢

转载自blog.csdn.net/weixin_57099902/article/details/131854288
今日推荐