1.实验拓扑
实验要求
R1
//基础配置
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1
[R1]int l0
[R1-LoopBack0]ip add 192.168.1.1 24
[R1-LoopBack0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.2.1 24
//静态路由配置
[R1]ip route-static 0.0.0.0 0 192.168.2.2
R2
//基础配置
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R2
[R2]int g0/0/2
[R2-GigabitEthernet0/0/2]ip add 23.1.1.1 24
[R2-GigabitEthernet0/0/2]int l0
[R2-LoopBack0]ip add 2.2.2.2 24
//OSPF配置
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]network 23.1.1.1 0.0.0.0
//MPLS配置
[R2]mpls lsr-id 2.2.2.2
[R2]mpls
[R2-mpls]mpls ldp
[R2-mpls-ldp]int g0/0/2
[R2-GigabitEthernet0/0/2]mpls
[R2-GigabitEthernet0/0/2]mpls ldp
//MPLS VPN配置
[R2]ip vpn-instance A1
[R2-vpn-instance-A1]ipv4-family
[R2-vpn-instance-A1-af-ipv4]route-distinguisher 1:1
[R2-vpn-instance-A1-af-ipv4]vpn-target 1:1
[R2-vpn-instance-A1-af-ipv4]int g0/0/1
[R2-GigabitEthernet0/0/1]ip binding vpn-instance A1
[R2-GigabitEthernet0/0/1]ip add 192.168.2.2 24
[R2]ip vpn-instance B1
[R2-vpn-instance-B1]ipv4-family
[R2-vpn-instance-B1-af-ipv4]route-distinguisher 2:2
[R2-vpn-instance-B1-af-ipv4]vpn-target 2:2
[R2-vpn-instance-B1-af-ipv4]int g0/0/0
[R2-GigabitEthernet0/0/0]ip binding vpn-instance B1
[R2-GigabitEthernet0/0/0]ip add 192.168.2.2 24
//BGP配置
[R2]bgp 2
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 4.4.4.4 as-number 2
[R2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[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
//内网静态宣告
[R2]ip route-static vpn-instance B1 192.168.1.0 24 192.168.2.1
[R2]bgp 2
[R2-bgp]ipv4 vpn-instance B1
[R2-bgp-B1]import-route direct
[R2-bgp-B1]import-route static
//内网动态宣告
[R2]rip 1 vpn-instance A1
[R2-rip-1]ver 2
[R2-rip-1]network 192.168.2.0
[R2-rip-1]import-route bgp
[R2-rip-1]q
[R2]bgp 2
[R2-bgp]ipv4-family vpn-instance A1
[R2-bgp-A1]import-route rip 1
R3//基础配置
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R3
[R3]int l0
[R3-LoopBack0]ip add 3.3.3.3 24
[R3-LoopBack0]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 23.1.1.2 24
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 34.1.1.1 24
//OSPF配置
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 34.1.1.1 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 23.1.1.2 0.0.0.0
//MPLS配置
[R3]mpls lsr-id 3.3.3.3
[R3]mpls
[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
//基础配置
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R4
[R4]int l0
[R4-LoopBack0]ip add 4.4.4.4 24
[R4-LoopBack0]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 34.1.1.2 24
[R4-GigabitEthernet0/0/0]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 47.1.1.2 24
//OSPF配置
[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.4 0.0.0.0
[R4-ospf-1-area-0.0.0.0]network 47.1.1.2 0.0.0.0
[R4-ospf-1-area-0.0.0.0]network 34.1.1.2 0.0.0.0
//MPLS配置
[R4]mpls lsr-id 4.4.4.4
[R4]mpls
[R4-mpls]mpls ldp
[R4-mpls-ldp]int g0/0/0
[R4-GigabitEthernet0/0/0]mpls
[R4-GigabitEthernet0/0/0]mpls ldp
[R4-GigabitEthernet0/0/0]int g0/0/1
[R4-GigabitEthernet0/0/1]mpls
[R4-GigabitEthernet0/0/1]mpls ldp
//MPLS VPN配置
[R4]ip vpn-instance B2
[R4-vpn-instance-B2]ipv4-family
[R4-vpn-instance-B2-af-ipv4]route-distinguisher 2:2
[R4-vpn-instance-B2-af-ipv4]vpn-target 2:2
[R4-vpn-instance-B2-af-ipv4]int g4/0/0
[R4-GigabitEthernet4/0/0]ip binding vpn-instance B2
[R4-GigabitEthernet4/0/0]ip add 192.168.3.2 24
[R4]ip vpn-instance A2
[R4-vpn-instance-A2]ipv4-family
[R4-vpn-instance-A2-af-ipv4]route-distinguisher 1:1
[R4-vpn-instance-A2-af-ipv4]vpn-target 1:1
[R4-vpn-instance-A2-af-ipv4]int g0/0/2
[R4-GigabitEthernet0/0/2]ip binding vpn-instance A2
[R4-GigabitEthernet0/0/2]ip add 192.168.3.2 24
//BGP配置
[R4]bgp 2
[R4-bgp]router-id 4.4.4.4
[R4-bgp]peer 2.2.2.2 as-number 2
[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
//内网宣告
[R4]ip route-static vpn-instance B2 192.168.4.0 24 192.168.3.1
[R4]bgp 2
[R4-bgp]ipv4 vpn-instance B2
[R4-bgp-B2]import-route direct
[R4-bgp-B2]import-route static
//内网动态宣告
[R4]ospf 2 vpn-instance A2
[R4-ospf-2]area 0
[R4-ospf-2-area-0.0.0.0]network 192.168.3.2 0.0.0.0
[R4-ospf-2-area-0.0.0.0]q
[R4-ospf-2]import-route bgp
[R4-ospf-2]q
[R4]bgp 2
[R4-bgp]ipv4-family vpn-instance A2
[R4-bgp-A2]import-route ospf 2
R5
//基础配置
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R5
[R5]int l0
[R5-LoopBack0]ip add 192.168.4.1 24
[R5-LoopBack0]int g0/0/0
[R5-GigabitEthernet0/0/0]ip add 192.168.3.1 24
//静态路由配置
[R5]ip route-static 0.0.0.0 0 192.168.3.2
R6//基础配置
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R6
[R6]int l0
[R6-LoopBack0]ip add 192.168.1.1 24
[R6-LoopBack0]int g0/0/1
[R6-GigabitEthernet0/0/1]ip add 192.168.2.1 24
//RIP配置
[R6]rip 1
[R6-rip-1]ver 2
[R6-rip-1]network 192.168.2.0
[R6-rip-1]network 192.168.1.0
R7
//基础配置
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R7
[R7]int l0
[R7-LoopBack0]ip add 7.7.7.7 24
[R7-LoopBack0]int l1
[R7-LoopBack1]ip add 192.168.4.2 24
[R7-LoopBack0]int g0/0/1
[R7-GigabitEthernet0/0/1]ip add 192.168.3.1 24
[R7-GigabitEthernet0/0/1]int g0/0/0
[R7-GigabitEthernet0/0/0]ip add 47.1.1.1 24
//OSPF配置
[R7]ospf 1
[R7-ospf-1]area 0
[R7-ospf-1-area-0.0.0.0]network 192.168.4.2 0.0.0.0
[R7-ospf-1-area-0.0.0.0]network 192.168.3.1 0.0.0.0
//缺省路由配置
[R7]ip route-static 0.0.0.0 0 47.1.1.2
//NAT配置
[R7]acl 2000
[R7-acl-basic-2000]rule permit source 192.168.4.2 0.0.0.0
[R7-acl-basic-2000]int g0/0/0
[R7-GigabitEthernet0/0/0]nat outbound 2000
测试