1.实验题目
2.IP划分
R2,R3,R4之间使用OSPF
R7使用缺省指向公网
[r7]ip route-static 0.0.0.0 0 47.1.1.1
其中R2和R4建立BGP链接
3.MPLS开启
3.1.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 g0/0/2
[r2-GigabitEthernet0/0/2]mpls
[r2-GigabitEthernet0/0/2]mpls ldp
3.2.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 g0/0/2
[r3-GigabitEthernet0/0/2]mpls
[r3-GigabitEthernet0/0/2]mpls ldp
[r3-GigabitEthernet0/0/2]int g0/0/0
[r3-GigabitEthernet0/0/0]mpls
[r3-GigabitEthernet0/0/0]mpls ldp
3.3.R4
[r4]mpls lsr-id 4.4.4.4
[r4]mpls
Info: Mpls starting, please wait... OK!
[r4-mpls]mpls ldp
[r4-mpls-ldp]int g0/0/0
[r4-GigabitEthernet0/0/0]mpls
[r4-GigabitEthernet0/0/0]mpls ldp
4.VRF空间
4.1.R2
b1空间,是给R1的使用的
[r2]ip vpn-instance b1
[r2-vpn-instance-b1]ipv4-family
[r2-vpn-instance-b1-af-ipv4]route-distinguisher 1:1
[r2-vpn-instance-b1-af-ipv4]vpn-target 1:1
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip binding vpn-instance b1
Info: All IPv4 related configurations on this interface are removed!
Info: All IPv6 related configurations on this interface are removed!
a1空间是给R6使用的
[r2]ip vpn-instance a1
[r2-vpn-instance-a1]ipv4-family
[r2-vpn-instance-a1-af-ipv4]route-distinguisher 2:2
[r2-vpn-instance-a1-af-ipv4]vpn-target 2:2
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip binding vpn-instance a1
Info: All IPv4 related configurations on this interface are removed!
Info: All IPv6 related configurations on this interface are removed!
配置完成之后可以给对应接口配置ip
可以配置一样的ip而不报错
[r2-GigabitEthernet0/0/0]ip add 192.168.2.2 24
[r2-GigabitEthernet0/0/1]ip add 192.168.2.2 24
4.2.R4
b2空间,是给R5的使用的,并且配置IP
[r4]ip vpn-instance b2
[r4-vpn-instance-b2]ipv4-family
[r4-vpn-instance-b2-af-ipv4]route-distinguisher 1:1
[r4-vpn-instance-b2-af-ipv4]vpn-target 1:1[r4]int g0/0/1
[r4-GigabitEthernet0/0/1]ip binding vpn-instance b2
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
a2空间是给R7使用的,并且配置IP
[r4]ip vpn-instance a2
[r4-vpn-instance-a2]ipv4-family
[r4-vpn-instance-a2-af-ipv4]route-distinguisher 2:2
[r4-vpn-instance-a2-af-ipv4]vpn-target 2:2[r4]int g4/0/0
[r4-GigabitEthernet4/0/0]ip binding vpn-instance a2
Info: All IPv4 related configurations on this interface are removed!
Info: All IPv6 related configurations on this interface are removed![r4-GigabitEthernet4/0/0]ip add 192.168.3.1 24
5.BGP配置
5.1.R2
[r2]bgp 1
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 4.4.4.4 as-number 1
[r2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r2-bgp]ipv4-family vpnv4
[r2-bgp-af-vpnv4]peer 4.4.4.4 enable
5.2.R4
[r4]bgp 1
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 2.2.2.2 as-number 1
[r4-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r4-bgp]ipv4-family vpnv4
[r4-bgp-af-vpnv4]peer 2.2.2.2 enable
配置完成之后配置R1 R7 R6 R5的环回和接口IP
6.配置RIP,OSPF和重交换
6.1.R6和R2 RIP
[r2]rip 1 vpn-instance a1
[r2-rip-1]ver 2
[r2-rip-1]network 192.168.2.0[r6]rip 1
[r6-rip-1]ver 2
[r6-rip-1]network 192.168.1.0
[r6-rip-1]network 192.168.2.0
6.2.R4和R7 OSPF
[r4]ospf 2 vpn-instance a2
[r4-ospf-2]area 0
[r4-ospf-2-area-0.0.0.0]network 192.168.3.1 0.0.0.0[r7]ospf 1 router-id 7.7.7.7
[r7-ospf-1]area 0
[r7-ospf-1-area-0.0.0.0]network 192.168.3.2 0.0.0.0
[r7-ospf-1-area-0.0.0.0]network 192.168.4.2 0.0.0.0
6.3.双向重发布
RIP和BGP进行双向重发布
[r2]rip 1 vpn-instance a1
[r2-rip-1]import-route bgp[r2]bgp 1
[r2-bgp]ipv4-family vpn-instance a1
[r2-bgp-a1]import-route rip 1
OSPF和BGP进行双向重发布
[r4-bgp]ipv4-family vpn-instance a2
[r4-bgp-a2]import-route ospf 2
[r4]ospf 2 vpn-instance a2
[r4-ospf-2]import-route bgp
R6学到了192.168.4.2等路由
并且可以通讯
7.静态配置
7.1.R1和R2
[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 b1 192.168.1.0 24 192.168.2.1
[r2]bgp 1
[r2-bgp]ipv4-family vpn-instance b1
[r2-bgp-b1]import-route static
[r2-bgp-b1]import-route direct
7.2.R4和R5
[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 b2 192.168.4.0 24 192.168.3.2
[r4]bgp 1
[r4-bgp]ipv4-family vpn-instance b2
[r4-bgp-b2]import-route static
[r4-bgp-b2]import-route direct
然后就能通了