目录
题目
1、R1与R5使用MPLS-VPN互通,其中CE到PE端使用静态路由;
2、R6与R7使用MPLS-VPN互通,其中CE到PE端使用动态路由;
3、R7可以访问R2 R3 R4的环回;
4、R2和R4使用BGP,IGP使用OSPF互通。
实验步骤
第一步、IP地址规划
R2-R3:23.1.1.0/24
R2环回:2.2.2.2/24
R3-R4:34.1.1.0/24
R3环回:3.3.3.0/24
R4环回:4.4.4.0/24
R4-R7:47.1.1.0/24
R1环回:192.168.1.0/24
R1-R2:192.168.2.0/24
R6环回:192.168.1.0/24
R6-R2:192.168.2.0/24
R5环回:192.168.4.1/24
R5-R4:192.168.3.0/24
R7环回:192.168.4.2/24
R7-R4:192.168.3.0/24
第二步、配置接口IP地址
R1
php
<Huawei>system-view
[Huawei]sysname R1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.2.1 24
[R1-GigabitEthernet0/0/0]int lo0
[R1-LoopBack0]ip address 192.168.1.1 24
R2
php
<Huawei>system-view
[Huawei]sysname R2
[R2]int g0/0/2
[R2-GigabitEthernet0/0/2]ip address 23.1.1.2 24
[R2-GigabitEthernet0/0/2]int lo0
[R2-LoopBack0]ip address 2.2.2.2 24
R3
php
<Huawei>system-view
[Huawei]sysname R3
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip address 23.1.1.3 24
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip address 34.1.1.3 24
[R3-GigabitEthernet0/0/1]int lo0
[R3-LoopBack0]ip address 3.3.3.3 24
R4
php
<Huawei>system-view
[Huawei]sysname R4
[R4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip address 34.1.1.4 24
[R4-GigabitEthernet0/0/0]int lo0
[R4-LoopBack0]ip address 4.4.4.4 24
[R4-LoopBack0]int g0/0/2
[R4-GigabitEthernet0/0/2]ip address 47.1.1.4 24
R5
php
<Huawei>system-view
[Huawei]sysname R5
[R5]int g0/0/0
[R5-GigabitEthernet0/0/0]ip address 192.168.3.5 24
[R5-GigabitEthernet0/0/0]int lo0
[R5-LoopBack0]ip address 192.168.4.1 24
R6
php
<Huawei>system-view
[Huawei]sysname R6
[R6]int g0/0/0
[R6-GigabitEthernet0/0/0]ip address 192.168.2.6 24
[R6-GigabitEthernet0/0/0]int lo0
[R6-LoopBack0]ip address 192.168.1.1 24
R7
php
<Huawei>system-view
[Huawei]sysname R7
[R7]int g0/0/0
[R7-GigabitEthernet0/0/0]ip address 47.1.1.7 24
[R7-GigabitEthernet0/0/0]int g0/0/1
[R7-GigabitEthernet0/0/1]ip address 192.168.3.7 24
[R7-GigabitEthernet0/0/1]int lo0
[R7-LoopBack0]ip address 192.168.4.2 24
第三步、IGP配置OSPF
R2
php
[R2]ospf 1 router-id 2.2.2.2
[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.0 0.0.0.255
R3
php
[R3]ospf 1 router-id 3.3.3.3
[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 34.1.1.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 3.3.3.0 0.0.0.255
R4
php
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 4.4.4.0 0.0.0.255
[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 47.1.1.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]q
[R4-ospf-1]silent-interface GigabitEthernet 0/0/2 #沉默掉用户接口
R7
R7上配置一条缺省指向公网,实现R7可以访问R2 R3 R4的环回;
php
[R7]ip route-static 0.0.0.0 0 47.1.1.4
这步实现公网内部可以互通
R7去访问R2 R3 R4
第五步、公网配置MPLS
R2
php
[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
R3
php
[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/0
[R3-GigabitEthernet0/0/0]mpls
[R3-GigabitEthernet0/0/0]mpls ldp
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]mpls
[R3-GigabitEthernet0/0/1]mpls ldp
R4
php
[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
第五步、使用MPLS-VPN
R2-R1
php
[R2]ip vpn-instance b
[R2-vpn-instance-b]route-distinguisher 1:1
[R2-vpn-instance-b-af-ipv4]vpn-target 1:1
[R2-vpn-instance-b-af-ipv4]q
[R2-vpn-instance-b]q
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip binding vpn-instance b
[R2-GigabitEthernet0/0/0]ip address 192.168.2.2 24
R4-R5
php
[R4]ip vpn-instance b
[R4-vpn-instance-b]route-distinguisher 1:1
[R4-vpn-instance-b-af-ipv4]vpn-target 1:1
[R4-vpn-instance-b-af-ipv4]q
[R4-vpn-instance-b]q
[R4]int g0/0/1
[R4-GigabitEthernet0/0/1]ip binding vpn-instance b
[R4-GigabitEthernet0/0/1]ip address 192.168.3.4 24
R2-R6
php
[R2]ip vpn-instance a
[R2-vpn-instance-a]route-distinguisher 2:2
[R2-vpn-instance-a-af-ipv4]vpn-target 2:2
[R2-vpn-instance-a-af-ipv4]q
[R2-vpn-instance-a]q
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip binding vpn-instance a
[R2-GigabitEthernet0/0/1]ip address 192.168.2.2 24
R4-R7
php
[R4]ip vpn-instance a
[R4-vpn-instance-a]route-distinguisher 2:2
[R4-vpn-instance-a-af-ipv4]vpn-target 2:2
[R4-vpn-instance-a-af-ipv4]q
[R4-vpn-instance-a]q
[R4]int g1/0/0
[R4-GigabitEthernet1/0/0]ip binding vpn-instance a
[R4-GigabitEthernet1/0/0]ip address 192.168.3.4 24
第六步、R2-R4使用BGP建邻并实现VPN建邻
R2
php
[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 lo0
[R2-bgp]peer 4.4.4.4 next-hop-local
[R2-bgp]ipv4-family vpnv4
[R2-bgp-af-vpnv4]peer 4.4.4.4 enable
R4
php
[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]peer 2.2.2.2 next-hop-local
[R4-bgp]ipv4-family vpnv4
[R4-bgp-af-vpnv4]peer 2.2.2.2 enable
第六步、配置B静态路由
R1
php
[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
php
[R2]ip route-static vpn-instance b 192.168.1.0 24 192.168.2.1
R4
php
[R4]ip route-static vpn-instance b 192.168.4.0 24 192.168.3.5
R5
php
[R5]ip route-static 192.168.1.0 24 192.168.3.4
[R5]ip route-static 192.168.2.0 24 192.168.3.4
第七步、配置B动态路由
R6
php
[R6]rip 1
[R6-rip-1]version 2
[R6-rip-1]network 192.168.1.0
[R6-rip-1]network 192.168.2.0
R2
php
[R2]rip 1 vpn-instance a
[R2-rip-1]version 2
[R2-rip-1]network 192.168.2.0
R4
php
[R4]ospf 2 vpn-instance a
[R4-ospf-2]area 0
[R4-ospf-2-area-0.0.0.0]network 192.168.3.4 0.0.0.0
R7
php
[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.7 0.0.0.0
[R7-ospf-1-area-0.0.0.0]network 192.168.4.2 0.0.0.0
第八步、重发布
R2
先重发布B的静态路由和直连路由
php
[R2]bgp 1
[R2-bgp]ipv4-family vpn-instance b
[R2-bgp-b]import-route direct
[R2-bgp-b]import-route static
再双向重发布A的动态路由
php
[R2]bgp 1
[R2-bgp]ipv4-family vpn-instance a
[R2-bgp-a]import-route rip 1
[R2-bgp-a]q
[R2-bgp]q
[R2]rip 1 vpn-instance a
[R2-rip-1]import-route bgp
R4
先重发布B的静态路由和直连路由
php
[R4]bgp 1
[R4-bgp]ipv4-family vpn-instance b
[R4-bgp-b]import-route direct
[R4-bgp-b]import-route static
再双向重发布A的动态路由
php
[R4]ospf 2 vpn-instance a
[R4-ospf-2]import-route bgp
[R4-ospf-2]q
[R4]bgp 1
[R4-bgp]ipv4-famil vpn-instance a
[R4-bgp-a]import-route ospf 2
第九步、测试
R1访问R5
R6访问R7
R5访问192.168.1.1路径
R7访问192.168.1.1路径
R5、R7访问的同一个地址,但是他们走的路径不一样,说明只要不同的空间,可以配置相同的IP地址,他们只会访问同一个空间里面的设备。