美文网首页
MPLS-VPN简例

MPLS-VPN简例

作者: 65s4dg532 | 来源:发表于2018-06-27 09:27 被阅读0次
    0627.png

    首先在R2上的e0/0上创建两个子接口和两个vrf

     ---【R2】
    

    conf t
    ip vrf A1
    ip vrf B1
    exit
    int e0/0
    no shut
    int e0/0.12
    en dot 12
    ip vrf forwarding A1
    ip add 12.1.1.2 255.255.255.0
    int e0/0.27
    en dot 27
    ip vrf forwarding B1
    ip add 27.1.1.2 255.255.255.0
    end

    // 然后可以在R1上 ping 12.1.1.2 来测试
    // 然后可以在R7上 ping 27.1.1.2 来测试
    // R2 ping R1/R7 需要用 ping vrf A1 12.1.1.1
    // show ip route vrf A1 可以看到指定vrf的路由表

    同理 在R5上创建两个VRF,并划分相应接口

     --- 【R5】
    

    conf t
    ip vrf A2
    ip vrf B2
    exit
    int e0/0
    ip vrf forwarding A2
    ip add 56.1.1.5 255.255.255.0
    no shut
    int e0/2
    ip vrf forwarding B2
    ip add 58.1.1.5 255.255.255.0
    no shut
    end

    //可以在R6上ping 56.1.1.5 来测试
    //可以在R8上ping 58.1.1.5 来测试


    打通 [RIP] R1和R2 的路由:

        ---【R1】
    

    conf t
    router rip
    no au
    ver 2
    net 0.0.0.0
    end

     ---【R2】
    

    conf t
    router rip
    address-family ipv4 vrf A1
    no au
    ver 2
    net 12.0.0.0
    end
    //R2#show ip route vrf A1 //可以看到R1传过来的路由

    打通 [EIGRP]R6和R5的路由

        ---【R6】
    

    conf t
    router eigrp 56
    net 0.0.0.0
    end

        ---【R5】
    

    conf t
    router eigrp 12345
    address-family ipv4 vrf A2 au 56
    net 56.1.1.5 0.0.0.0
    end

    //然后R5和R6会建立eigrp邻居

    打通 [BGP] R8和R5之间的路由

        ---【R8】
    

    conf t
    router bgp 8
    bgp router-id 8.8.8.8
    nei 58.1.1.5 remote 25
    net 8.8.8.8 mask 255.255.255.255
    end
    wr

        ---【R5】
    

    conf t
    ip vrf B2
    rd 8:8
    router bgp 25
    bgp router-id 5.5.5.5
    address-family ipv4 unicast vrf B2
    nei 58.1.1.8 remote 8
    end

    //会建立BGP邻居 然后 R5会收到 R8的路由
    // R5#show ip route vrf B2 查看R5收到的R8的路由

    打通 [OSPF] R7和R2之间的路由

        ---【R7】
    

    conf t
    router ospf 27
    router-id 7.7.7.7
    net 0.0.0.0 0.0.0.0 area 0
    end
    wr

        ---【R2】
    

    conf t
    router ospf 27 vrf B1
    router-id 2.2.2.22
    net 27.1.1.2 0.0.0.0 area 0
    end
    wr
    //然后R2和R7会建立 ospf 邻居

    这个时候路由都在R2和R5上
    [RD:route distinguisher]
    RD:CE的ipv4路由进入全局的vpnv4地址簇时
    在32位的ipv4路由前面增加了一个8字节的RD
    变成了 VPNv4的路由前缀

    配置 RD 在R2和R5之前传递路由[BGP]

        ---【R2】
    

    conf t
    ip vrf A1
    rd 1:1
    ip vrf B1
    rd 7:7
    router bgp 25
    no bgp default ipv4-unicast
    bgp router-id 2.2.2.2
    nei 5.5.5.5 remote 25
    nei 5.5.5.5 up lo0
    address-family vpnv4
    nei 5.5.5.5 act
    end

        ---【R5】
    

    conf t
    ip vrf A2
    rd 6:6
    ip vrf B2
    rd 8:8
    router bgp 25
    no bgp default ipv4-unicast
    bgp router-id 5.5.5.5
    nei 2.2.2.2 remote 25
    nei 2.2.2.2 up lo0
    address-family vpnv4
    nei 2.2.2.2 act
    end

    还需在R2和R5上设置RT值 让路由器知道 放入哪个vrf还是实例的表里

    R2上双向重分布RIP和BGP,R5上双向重分布EIGRP和BGP

        ----【R2】
    

    conf t
    ip vrf A1
    route-target export 1:6
    route-target import 6:1
    router bgp 25
    address-family ipv4 unicast vrf A1
    redistribute rip
    router rip
    address-family ipv4 unicast vrf A1
    redistribute bgp 25 metric 2
    end
    wr

        ----【R5】
    

    conf t
    ip vrf A2
    route-target import 1:6
    route-target export 6:1
    router eigrp 12345
    address-family ipv4 vrf A2 au 56
    redistribute bgp 25 metric 10000 1000 1 255 1500
    router bgp 25
    address-family ipv4 vrf A2
    redistribute eigrp 56
    end

    //R2#show ip route vrf A1 然后就可以在R2的vrf A1的路由表中看到R6的路由

    R2上双向重分布OSPF和BGP,R5上双向重分布BGP

        ----【R2】
    

    conf t
    ip vrf B1
    route-target import 8:7
    route-target export 7:8
    router bgp 25
    address-family ipv4 vrf B1
    redistribute ospf 27
    router ospf 27 vrf B1
    redistribute bgp 25 subnets
    end

        ----【R5】
    

    conf t
    ip vrf B2
    route-target import 7:8
    route-target export 8:7
    end

    //R7#show ip route 可以看到R8环回口的路由了。
    //R8#show ip route 可以看到R7环回口的路由了。
    //R7#ping 8.8.8.8 source lo0 这就可以通了。

    注意事项!!

    1> Lo0的掩码位数应为32位
    不然会导致FEC断层



    ---MPLS VPN配置
    

    R2(config)#mpls label range 200 299
    R2(config)#mpls ldp router-id lo0
    R2(config)#router ospf 1
    R2(config-router)#mpls ldp autoconfig

    R3(config)#mpls label range 300 399
    R3(config)#mpls ldp router-id lo0
    R3(config)#router ospf 1
    R3(config-router)#mpls ldp autoconfig

    R4(config)#mpls label range 400 499
    R4(config)#mpls ldp router-id lo0
    R4(config)#router ospf 1
    R4(config-router)#mpls ldp autoconfig

    R5(config)#mpls label range 500 599
    R5(config)#mpls ldp router-id lo0
    R5(config)#router ospf 1
    R5(config-router)#mpls ldp autoconfig

    // no mpls ip propagate-ttl
    ///关闭 mpls的复制 ttl的功能 可以达到隐藏内部网络的目的



    --IP地址预配:

        【R1】
    

    conf t
    int e0/0
    ip add 12.1.1.1 255.255.255.0
    no shut
    int lo0
    ip add 1.1.1.1 255.255.255.255
    end
    wr

        【R2】
    

    conf t
    int e0/1
    ip add 23.1.1.2 255.255.255.0
    no shut
    int lo0
    ip add 2.2.2.2 255.255.255.255
    router ospf 1
    router-id 2.2.2.2
    net 23.1.1.2 0.0.0.0 a 0
    net 2.2.2.2 0.0.0.0 area 0
    end
    wr

        ---【R3】
    

    conf t
    int e0/1
    ip add 23.1.1.3 255.255.255.0
    no shut
    int e0/0
    ip add 34.1.1.3 255.255.255.0
    no shut
    int lo0
    ip add 3.3.3.3 255.255.255.255
    router ospf 1
    router-id 3.3.3.3
    net 0.0.0.0 0.0.0.0 area 0
    end
    wr

        ---【R4】
    

    conf t
    int e0/0
    ip add 34.1.1.4 255.255.255.0
    no shut
    int e0/1
    ip add 45.1.1.4 255.255.255.0
    no shut
    int lo0
    ip add 4.4.4.4 255.255.255.255
    router ospf 1
    net 0.0.0.0 0.0.0.0 area 0
    end
    wr

    ---【R5】
    

    conf t
    int e0/1
    ip add 45.1.1.5 255.255.255.0
    no shut
    int lo0
    ip add 5.5.5.5 255.255.255.255
    router ospf 1
    router-id 5.5.5.5
    net 45.1.1.5 0.0.0.255 area 0
    net 5.5.5.5 0.0.0.0 area 0
    end

        【R6】
    

    conf t
    int e0/0
    ip add 56.1.1.6 255.255.255.0
    no shut
    int lo0
    ip add 6.6.6.6 255.255.255.255
    end
    wr

        【R7】
    

    conf t
    int e0/0
    ip add 27.1.1.7 255.255.255.0
    no shut
    int lo0
    ip add 7.7.7.7 255.255.255.255
    end
    wr

        【R8】
    

    conf t
    hostname R8
    int e0/2
    ip add 58.1.1.8 255.255.255.0
    no shut
    int lo0
    ip add 8.8.8.8 255.255.255.255
    end
    wr

         【SW9】
    

    conf t
    int e0/2
    sw tr en dot
    sw mo tr
    no shut
    int e0/0
    sw acc vlan 12
    int e0/1
    sw acc vlan 27
    end
    wr

    相关文章

      网友评论

          本文标题:MPLS-VPN简例

          本文链接:https://www.haomeiwen.com/subject/bczvyftx.html