“网络三结义”--mpls 进阶实验详细配置

版权声明:HUGO https://blog.csdn.net/weixin_42078367/article/details/85219422

实验拓扑:

基础配置:

                    1. 对每个设备进行ip地址的配置   (这些基础配置就不在这里赘述)

               2.在R2 R3 R4 上运行ospf协议

               3. 运行 ospf协议之后, R2 R4 运行bgp协议,并建立bgp邻居关系

 

R2(config)#router bgp 1

R2(config-router)#neighbor 10.4.4.4 remote-as 1

R2(config-router)#neighbor 10.4.4.4  update-source  lo 0

 

R4(config)#router bgp 1

R4(config-router)#neighbor 10.2.2.2 remote-as 1

R4(config-router)#neighbor 10.2.2.2  update-source  lo 0

 

      4.由于会出现数据层面的路由黑洞问题,因此在 R2 R3 R4需要运行mpls 协议

      MPLS在ospf中使用小技巧:  注意对于与np中区别

 

 

R2(config)#router ospf 1

R2(config-router)#mpls ldp autoconfig  

R2(config-router)#mpls ldp router-id loo 0 force

 

R3(config)#router ospf 1

R3(config-router)#mpls ldp autoconfig

R3(config-router)#mpls ldp router-id loo 0 force

 

R4(config)#router ospf 1

R4(config-router)#mpls ldp autoconfig

                      R4(config-router)#mpls ldp router-id loo 0 force

              由于一些研发者 默认的原因,导致加force就是强制指定关系,这样的话才能建立号mpls邻居。

 

 

注意: MPLS不会为BGP的路由分配标签 

 

注:CEF可以同时操作路由表与FLIB(转发标签信息表 )

    如果有相同的目的路径就,可以用同一个标签进行转发

 

从路由表的角度: 1.首先查 100.4.4.4  得知下一跳 为10.4.4.4

                                  2.查到10.4.4.4 又要进行 递归查找 ,在标签表中 查到

                                  3.  在标签表中 根据 转发等价类的说明 就拿到了 17 号标签

 

最佳标签产生过程:

 

 

 

               1.在show ip cef 中可以找到去10.4.4.4 的下一跳地址-10.1.34.2

                2.然后在 show mpls ldp neighbor 中 找到 10.1.34.2对应的邻居是谁

                  然后就优选 10.4.4.4 给的标签(在 show MPLS ldp blinding  优选)

 

MPLS环路问题

  1. 通过路由表来防止环路—> 通过各种路由协议,借助别人来防止环路
  2. TTL防止回路(默认MPLSTTL会和IPTTL同步)

 

      为什么会trace出来 mpls标签出来?

      这个就要牵涉到Trace 的原理:

      一般举例来说,去百度的话 。发一个包,默认来说 TTL设成255,过一个路由器 就减一   。 trace的机制就是 把TTL 设置成1 ,应该是到网关(只能过一跳)(总之来说就是到下一个 ip) ,下一个ip 一看 你要去百度,但是到我这,你就停下来了。trace就是个 echo 包 ,他需要给返回包。这个返回包 就是 以 下一个ip 的接口为源,返回给你。

     接下里 把TTL 设置成 2 ,3   4   知道百度给你回包。这个程序才会停止下来。此时呈现在屏幕就是去 百度的路径 

     在MPLS 里 trace 时 MPLS的TTL默认是跟 ip的TTL是自动同步的。当同步TTL值为1时,正好赶上 要压上去下一跳的标签。下一跳会回弹个echo包  同时也罢 标签号 给压上

     在这个里面 同步是关键的。

 

倘若 MPLS的TTL 跟ip的TTL 不同步,会发生什么效果呢?

 

     如果trace时,ipTTL1  MPLSTTL255(默认最大)。由于走的是标签通道所以 每过一跳 MPLSTTL 就减1,不影响ipTTL 直到消耗完mpls的标签TTL,或者说 中途被某台设备 撕去了标签,这时才看 ipTTL,此时 最多在向前走一跳,然后从这开始回弹个 echo这样的效果就是看不见 所走过的mpls路径。

 

 

5.完成上面mpls的配置之后,路由黑洞问题解决呢,现在就考虑如何传 Vrf路由。

    a.首先在PE端(R2 R4)进行相应的VRF的配置

       

       R2(config)#ip vrf A-1

       R2(config-vrf)#rd 100:100

        R2(config-vrf)#exit

 

       R2(config)#interface e0/1

       R2(config-if)#no ip address

        R2(config-if)#ip vrf f

      R2(config-if)#ip vrf forwarding A-1

       R2(config-if)#IP ADDress 10.1.1.1 255.255.255.0 

       R2(config-if)#no shutdown

 

 

       R2(config-if)#ip vrf B-1

      R2(config-vrf)#RD 100:200

       R2(config-vrf)#EXIT

 

      R2(config)#interface e1/0

       R2(config-if)#no ip address

       R2(config-if)#ip vrf forwarding A-2

        R2(config-if)#ip add 10.1.1.1 255.255.255.0

       R2(config-if)#no shutdown

 

          R4(config)#ip vrf A-2

        R4(config-vrf)#rd 200:100

          R4(config-vrf)#exit

        R4(config)#interface e1/0

R4(config-if)#no ip address

R4(config-if)#ip vrf forwarding A-2

R4(config-if)#ip address 10.1.2.1 255.255.255.0

R4(config-if)#no shut

R4(config-if)#

 

R4(config)#ip vrf B-2

R4(config-vrf)#rd 200:200

R4(config-vrf)#exit                 

R4(config)#interface e1/1

R4(config-if)#no ip add

R4(config-if)# ip vrf forwarding B-2

R4(config-if)#ip address 10.1.2.1 255.255.255.0

R4(config-if)#no shutdown

 

R4(config)#ip vrf C

R4(config-vrf)#rd 200:300

R4(config-vrf)#exit

R4(config)#interface e1/2

R4(config-if)#no ip address

R4(config-if)#ip vrf forwarding C

R4(config-if)#IP ADDress 10.1.3.1 255.255.255.0

R4(config-if)#NO SHUtdown

R4(config-if)#EXIT

 

 

  b.对ce端(R1 R5 R6 R7 R8)进行配置,并运行相应的路由协议,为了让实验环境更加真实,于是 R5--->运行ospf

       R1---->运行eigrp

       R6---->运行ospf

       R7---->静态路由

       R8----> 运行bgp 协议

      

这些均是常规设置,于是就不在这里赘述!!!!!

 

 

  c..在vrf中运行路由协议,把ce端的路由 进入 R2 ( 或R4 )的 vrf中

 

R2(config)#router ospf 2 vrf A-1

R2(config-router)#router-id 100.2.2.2

R2(config-router)#network 10.1.1.0 0.0.0.255 a 0

 

 

R2(config)#router eigrp 100

R2(config-router)#address-family ipv4 UNicast vrf  B-1  AUtonomous-system  90

R2(config-router-af)#NETwork 0.0.0.0

R2(config-router-af)#exit

R2(config-router)#exit

R2(config)#end

 

 

 

R4(config)#router ospf 2 vrf A-2

R4(config-router)# network 10.1.2.0 0.0.0.255 a 0 

R4(config-router)#EXIT

 

 

R4(config)#ip route vrf B-2 10.1.0.0 255.255.0.0 10.1.2.2

 

 

R4(config)#router bgp 1

R4(config-router)#address-family ipv4 vrf C

R4(config-router-af)#neighbor 10.1.3.2 remote-as 2

R4(config-router-af)#network 10.1.3.0 mask 255.255.255.0

 

 

d.现在配置RT 值 ,可以保证进入正确的vrf里 (这里以A-1 A-2 为例)

 

R2(config)#ip vrf A-1

R2(config-vrf)#route-target export 100:1   

R2(config-vrf)#route-target import 100:2

R2(config-vrf)#exit

 

 

R4(config)#ip vrf A-2

R4(config-vrf)#route-target export 100:2         

R4(config-vrf)#route-target import 100:1

R4(config-vrf)#exit

 

e.配置好rt值之后,现在就有运输工具来 运输这 特殊路由(IPV4路由+RD+RT

 

 

R2(config)#router bgp 1

R2(config-router)#address-family vpnv4

R2(config-router-af)#neighbor 10.4.4.4 activate

R2(config-router-af)#neighbor 10.4.4.4 send-community extended

 

 

 

 

R4(config)#router bgp 1

R4(config-router)#address-family  vpnv4

R4(config-router-af)#neighbor 10.2.2.2 activate

R4(config-router-af)#neighbor 10.2.2.2 send-community  extended

 

 

f.现在就需要路由去触发它,由分析得 两边的路由均在 各自的VR里面,现在就需要把 vrf里的路由导入进 mp-bgp里 用vpnv4去传。

 

R2(config)#router bgp 1

R2(config-router)#address-family ipv4  vrf A-1

R2(config-router-af)#redistribute ospf 2

 

 

 

R4(config)#router bgp 1

R4(config-router)#address-family ipv4 vrf A-2

R4(config-router-af)#REdistribute  OSpf 2

 

 

g.将特殊路由传过去之后,现在把特殊路由弄到 ce端设备去,因此需要进行重发布,

 

 

R2(config)#router ospf 2 vrf A-1

R2(config-router)#REdistribute  bgp 1 subnets

 

 

 

R4(config)#router ospf  2 vrf A-2

R4(config-router)#REdistribute BGP 1 SUbnets

 

路由层面:

数据层面:

 

 

猜你喜欢

转载自blog.csdn.net/weixin_42078367/article/details/85219422