目标:
一、首先为公网的每个路由器配置对应的ip和环回并且用OSPF进行动态选路
r2:
[r2]int gi 0/0/2
[r2-GigabitEthernet0/0/2]ip add 23.1.1.1 24
[r2-GigabitEthernet0/0/2]int lo0
[r2-LoopBack0]ip add 2.2.2.2 24
r3:
[r3]int gi 0/0/0
[r3-GigabitEthernet0/0/0]ip add 23.1.1.2 24
[r3-GigabitEthernet0/0/0]int gi 0/0/1
[r3-GigabitEthernet0/0/1]ip add 34.1.1.1 24
[r3-GigabitEthernet0/0/1]int lo0
[r3-LoopBack0]ip add 3.3.3.3 24
r4:
[r4]int gi 0/0/0
[r4-GigabitEthernet0/0/0]ip add 34.1.1.2 24
[r4-GigabitEthernet0/0/0]int lo0
[r4-LoopBack0]ip add 4.4.4.4 24
OSPF:
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255
[r2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[r3]ospf 1
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255
[r3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[r4]ospf 1
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 34.1.1.0 0.0.0.255
[r4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
二、下面在标签经过的接口上启动MPLS
r2:
[r2]mpls lsr-id 2.2.2.2
[r2]mpls
Info: Mpls starting, please wait... OK!
[r2-mpls]mpls ldp
[r2-mpls-ldp]int gi 0/0/2
[r2-GigabitEthernet0/0/2]mpls
[r2-GigabitEthernet0/0/2]mpls ldp
r3:
[r3]mpls lsr-id 3.3.3.3
[r3]mpls
Info: Mpls starting, please wait... OK!
[r3-mpls]mpls ldp
[r3-mpls-ldp]int gi 0/0/0
[r3-GigabitEthernet0/0/0]mpls
[r3-GigabitEthernet0/0/0]mpls ldp
[r3-GigabitEthernet0/0/0]int gi 0/0/1
[r3-GigabitEthernet0/0/1]mpls ldp
r4:
[r4]mpls lsr-id 4.4.4.4
Info: Mpls starting, please wait... OK!
[r4-mpls]mpls ldp
[r4-mpls-ldp]int gi 0/0/0
[r4-GigabitEthernet0/0/0]mpls
[r4-GigabitEthernet0/0/0]mpls ldp
三、然后配置MPLS VPN
方法:在下面来两幅图中在r2上创建两个两个VRF空间用于r1和r6的私网缓存,r4与r5、r7同理、
具体实现:
r2、r1、r6:
r2:
[r2]ip vpn-instance aa 创建名为aa的VRF
[r2-vpn-instance-aa]ipv4-family 进入IPV4模式中
[r2-vpn-instance-aa-af-ipv4]route-distinguisher 1:1 RD值
[r2-vpn-instance-aa-af-ipv4]vpn-target 1:1 RT值
[r2]int gi 0/0/0
[r2-GigabitEthernet0/0/0]ip binding vpn-instance aa 将这个接口绑定到这个专属的空间中
[r2]int gi 0/0/0
[r2-GigabitEthernet0/0/0]ip add 192.168.2.2 24 为该接口配置ip
以上是空间1与r1连接
-----------------------------------------------------------------------------
这里是空间2与r6连接
[r2]ip vpn-instance bb 创建名为bb的VRF
[r2-vpn-instance-bb]ipv4-family
[r2-vpn-instance-bb-af-ipv4]route-distinguisher 2:2
[r2-vpn-instance-bb-af-ipv4]vpn-target 2:2
[r2-GigabitEthernet0/0/1]ip binding vpn-instance bb
[r2-GigabitEthernet0/0/1]ip add 192.168.2.2 24
r1:
[r1]int lo0
[r1-LoopBack0]ip add 192.168.1.1 24
[r1-LoopBack0]int gi 0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.2.1 24
r6:
[r6]int lo0
[r6-LoopBack0]ip add 192.168.1.2 24
[r6-LoopBack0]int gi 0/0/0
[r6-GigabitEthernet0/0/0]ip add 192.168.2.1 24
这里需要注意:如果需要使用r2与r1进行ping的操作不能直接在接口ping,需要在建立VPN连接的私有空间中ping,如图:
r4、r5、r7:
r4:
[r4]ip vpn-instance aa
[r4-vpn-instance-aa]ipv4-family
[r4-vpn-instance-aa-af-ipv4]route-distinguisher 1:1
[r4-vpn-instance-aa-af-ipv4]vpn-target 1:1
[r4]int gi 0/0/1
[r4-GigabitEthernet0/0/1]ip binding vpn-instance aa
Info: All IPv4 related configurations on this interface are removed!
Info: All IPv6 related configurations on this interface are removed!
[r4-GigabitEthernet0/0/1]ip add 192.168.3.1 24
以上是r4、r5
------------------------------------------------------
以下是r4、r7
[r4]ip vpn-instance bb
[r4-vpn-instance-bb]ipv4-family
[r4-vpn-instance-bb-af-ipv4]route-distinguisher 2:2
[r4-vpn-instance-bb-af-ipv4]vpn-target 2:2
[r4-vpn-instance-bb-af-ipv4]int gi 0/0/2
[r4-GigabitEthernet0/0/2]ip binding vpn-instance bb
[r4-GigabitEthernet0/0/2]ip add 192.168.3.1 24
r5:
[r5]int lo0
[r5-LoopBack0]ip add 192.168.4.1 24
[r5-LoopBack0]int gi 0/0/0
[r5-GigabitEthernet0/0/0]ip add 192.168.3.2 24
r7:
[r7]int gi 0/0/0
[r7-GigabitEthernet0/0/0]ip add 192.168.3.2 24
[r7-GigabitEthernet0/0/0]int lo0
[r7-LoopBack0]ip add 192.168.4.2 24
到这里 MPLS VPN已将建立完成;
四、下面在r2---r4之间建立MP-BGP邻居
r2:
[r2]bgp 1
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 4.4.4.4 as 1这里的邻居会显示在公网中用于公网
[r2-bgp]peer 4.4.4.4 connect-interface lo0
[r2-bgp]ipv4-family vpnv4
[r2-bgp-af-vpnv4]peer 4.4.4.4 enable 这里的是VPN私网的建邻
r4:
[r4]bgp 1
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 2.2.2.2 as 1
[r4-bgp]peer 2.2.2.2 connect-interface lo0
[r4-bgp]ipv4-family vpnv4
[r4-bgp-af-vpnv4]peer 2.2.2.2 enable
五、现在需要在r2和r4上进行双向重发布实现三个区域的互通
要求:
r1和r5 之间使用静态实现
r6和r7之间使用动态实现
r6-r7:
方法:r1与r2之间启动RIP然后r7与r4之间启动OSPF 2再进行双向重发布
[r6]rip 1
[r6-rip-1]v 2
[r6-rip-1]network 192.168.1.0
[r6-rip-1]network 192.168.2.0
[r2]rip 1 vpn-instance bb
[r2-rip-1]version 2
[r2-rip-1]network 192.168.2.0
r7:
[r7]ospf 2 router-id 7.7.7.7
[r7-ospf-2]area 0
[r7-ospf-2-area-0.0.0.0]network 192.168.4.2 0.0.0.0
[r7-ospf-2-area-0.0.0.0]network 192.168.3.0 0.0.0.255
r4:
[r4]ospf 2 vpn-instance bb
[r4-ospf-2]area 0
[r4-ospf-2-area-0.0.0.0]network 192.168.3.0 0.0.0.255
双向重发布:
[r2]rip 1 vpn-instance bb
[r2-rip-1]import-route bgp
[r2]bgp 1
[r2-bgp]ipv4-family vpn-instance bb
[r2-bgp-bb]import-route rip 1
[r4]ospf 2 vpn-instance bb
[r4-ospf-2]import-route bgp
[r4-ospf-2]q
[r4]bgp 1
[r4-bgp]ipv4-family vpn-instance bb
[r4-bgp-bb]import-route ospf 2
查看r1的路由表:
测试:
r1-r5:
[r1]ip route-static 192.168.3.0 24 192.168.2.2
[r1]ip route-static 192.168.4.0 24 192.168.2.2
[r2]ip route-static vpn-instance aa 192.168.1.0 24 192.168.2.1
[r5]ip route-static 192.168.1.0 24 192.168.3.1
[r5]ip route-static 192.168.2.0 24 192.168.3.1
[r4]ip route-static vpn-instance aa 192.168.4.0 24 192.168.3.2
重发布:
[r2]bgp 1
[r2-bgp]ipv4-family vpn-instance aa
[r2-bgp-aa]import-route direct
[r2-bgp-aa]import-route static
[r4]bgp 1
[r4-bgp]ipv4-family vpn-instance aa
[r4-bgp-aa]import-route direct
[r4-bgp-aa]import-route static
测试:
现在完成了1、2要求还有最后一个要求
六、因为疏忽到这里已经造成了一个无法挽回的失误r4本来与r7有两条线但是现在已经无法加了所以最后一个要求今天无法完成了!