第一步: ISP
一) 配置Ip
先配置公网三个路由的Ip
[r2]int loo0
[r2-LoopBack0]ip add 2.2.2.2 24
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 23.1.1.1 24
[r2-GigabitEthernet0/0/1]int g0/0/2
[r2-GigabitEthernet0/0/2]ip add 26.1.1.1 24
[r3]int lo0
[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
[r4]int lo0
[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 45.1.1.1 24
[r4-GigabitEthernet0/0/1]int g0/0/2
[r4-GigabitEthernet0/0/2]ip add 47.1.1.1 24
二) 联通公网
公网需要通过宣告ospf,来跑通网段
[r2-ospf-1]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
[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.2 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 3.3.3.3 0.0.0.0
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]net
[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 34.1.1.2 0.0.0.0
三) MPLS
接着启动MPLS协议,建立MPLS关系
[r2]mpls lsr-id 2.2.2.2
[r2]mpls
Info: Mpls starting, please wait... OK!
[r2-mpls]mpls ldp
[r2-mpls-ldp]q
[r2]int g0/0/1
[r2-GigabitEthernet0/0/1]mpls ldp
[r3]mpls lsr-id 3.3.3.3
[r3]mpls
Info: Mpls starting, please wait... OK!
[r3-mpls]mpls ldp
[r3-mpls-ldp]q
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]mpls
[r3-GigabitEthernet0/0/0]mpl
[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]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
配置vpn
[r2]ip vpn-instance a1
[r2-vpn-instance-a1]ipv4-fa
[r2-vpn-instance-a1]ipv4-family
[r2-vpn-instance-a1-af-ipv4]rout
[r2-vpn-instance-a1-af-ipv4]route-distinguisher 1:1
[r2-vpn-instance-a1-af-ipv4]vpn-tar
[r2-vpn-instance-a1-af-ipv4]vpn-target 1:1
IVT Assignment result:
Info: VPN-Target assignment is successful.
EVT Assignment result:
Info: VPN-Target assignment is successful.
五) 绑定接口再配置ip
[r2]int g0/0/1
[r2-GigabitEthernet0/0/1]ip binding vpn-in
[r2-GigabitEthernet0/0/1]ip binding vpn-instance a1
Aug 4 2022 19:18:51-08:00 r2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the DOWN state.
Info: All IPv4 related configurations on this interface are removed!
Info: All IPv6 related configurations on this interface are removed!
在接口g0/0/2上增加一个ip ,我们会发现,它就进入了空间a1
而此时r1上可以Ping通该路由;R2pingR1时注意要在a1中查路由表。
六) BGP plus建邻2 4
[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]ipv4-family vpnv4
[r2-bgp-af-vpnv4]peer 4.4.4.4 enable
[r4]ip vpn-instance a2
[r4-vpn-instance-a2]route-distinguisher 1:1
[r4-vpn-instance-a2-af-ipv4]vpn-target 1:1
IVT Assignment result:
Info: VPN-Target assignment is successful.
EVT Assignment result:
Info: VPN-Target assignment is successful.
[r4-vpn-instance-a2-af-ipv4]int g0/0/2
[r4-GigabitEthernet0/0/2]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!
Aug 4 2022 19:49:31-08:00 r4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the DOWN state.
[r4-GigabitEthernet0/0/2]ip add 47.1.1.1 24
Aug 4 2022 19:50:14-08:00 r4 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[r4-GigabitEthernet0/0/2]q
[r4]bgp 2
[r4-bgp]peer 2.2.2.2 as-number 2
[r4-bgp]ipv4-family vpnv4
[r4-bgp-af-vpnv4]peer 2.2.2.2 enable
R7配置ip后查看
第二步: 6 和 7 联通 + 重发布 {动态}
1)6 2 上的使用动态协议 rip
[r6]rip 1
[r6-rip-1]ver 2
[r6-rip-1]network 6.6.6.6
Error: The network address is invalid, and the specified address must be major-n
et address without any subnets.
[r6-rip-1]network 62.1.1.1
Error: The network address is invalid, and the specified address must be major-n
et address without any subnets.
[r6-rip-1]network 192.168.1.0
[r6-rip-1]network 192.168.2.0
[r2]rip 1 vpn-instance a1
[r2-rip-1]ver 2
[r2-rip-1]network 192.168.2.0
2)4 7 上使用动态协议ospf
[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.4.2 0.0.0.0
[r7-ospf-1-area-0.0.0.0]network 192.168.3.2 0.0.0.0
[r7-LoopBack0]ip add 192.168.4.2 24
[r7-LoopBack0]int g0/0/0
[r7-GigabitEthernet0/0/0]ip add 192.168.3.2 24
[r4]ospf 2 vpn-instance a2
[r4-ospf-2]area 0
[r4-ospf-2-area-0.0.0.0]network 192.168.4.1 0.0.0.0
[r4-ospf-2-area-0.0.0.0]network 192.168.3.1 0.0.0.0
[r4]display ip routing-table vpn-instance a2
[r4-GigabitEthernet0/0/2]ip add 192.168.3.1 24
2 4 重发布:
[r2-rip-1]import-route bgp
[r2-rip-1]bgp 2
[r2-bgp]ipv4-family vpn-instance a1
[r2-bgp-a1]import-route rip 1
[r4]ospf 2 vpn-instance a2
[r4-ospf-2]import-route bgp
[r4-ospf-2]bgp 2
[r4-bgp]ipv4-family vpn-instance a2
[r4-bgp-a2]import-route ospf 2
第三步: 1 和 5 联通 + 重发布 {静态}
[r2]bgp 2
[r2-bgp]ipv4-family vpn-instance b1
[r2-bgp-a1]import-route static
[r2-bgp-a1]import-route dir
[r2-bgp-a1]import-route direct
[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
IVT Assignment result:
Info: VPN-Target assignment is successful.
EVT Assignment result:
Info: VPN-Target assignment is successful.
[r2-vpn-instance-b1-af-ipv4]int g0/0/0
[r2-GigabitEthernet0/0/0]ip binding vpn-instance b1
[r2-GigabitEthernet0/0/0]q
[r2]bgp 2
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 4.4.4.4 as-number 2
Error: The peer already exists in AS 2.
[r2-bgp]ipv4-family vpnv4
[r2-bgp-af-vpnv4]peer 4.4.4.4 enable
[r2]bgp 2
[r2-bgp]ipv4-family vpn-instance b1
[r2-bgp-b1]import-route static
[r2-bgp-b1]import-route direct
[r2-LoopBack0]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 192.168.2.2 24
[r2]ip route-static vpn-instance b1 192.168.1.0 24 192.168.2.1
[r4]ip vpn
[r4]ip vpn-instance b2
[r4-vpn-instance-b2]route-distinguisher 2:2
[r4-vpn-instance-b2-af-ipv4]vpn-target 2:2
[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!
Aug 4 2022 21:04:47-08:00 r4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the DOWN state.
[r4]bgp 2
[r4-bgp]router-id 4.4.4.4
[r4-bgp]ipv4-family vpnv4
[r4-bgp-af-vpnv4]peer 2.2.2.2 enable
[r4-bgp]ipv4-family vpn-instance b2
[r4-bgp-b2]import-route static
[r4-bgp-b2]import-route direct
[r4]int g0/0/1
[r4-GigabitEthernet0/0/1]ip add 192.168.3.1 24
[r4]ip route-static 192.168.4.0 24 192.168.3.2