配置IP地址与环回地址,实验ip与环回地址
ISP部分配置ospf公网互通,再起bgp
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.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
[R2]bgp 1
[R2-bgp]peer 4.4.4.4 as-number 1
[R2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[R4]bgp 1
[R4-bgp]peer 2.2.2.2 as-number 1
[R4-bgp]peer 2.2.2.2 connect-interface LoopBack 0
搭建mpls域
R2:
[R2]mpls lsr-id 2.2.2.2
[R2]mpls
[R2-mpls]mpls ldp
[R2-mpls-ldp]q
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]mpls
[R2-GigabitEthernet0/0/1]mpls ldp
R3:
[R3]mpls lsr-id 3.3.3.3
[R3]mpls
[R3-mpls]mpls ldp
[R3-mpls-ldp]q
[R3]interface g0/0/0
[R3-GigabitEthernet0/0/0]mpls
[R3-GigabitEthernet0/0/0]mpls ldp
[R3-GigabitEthernet0/0/0]q
[R3]interface g0/0/1
[R3-GigabitEthernet0/0/1]mpls ld
[R3-GigabitEthernet0/0/1]mpls ldp
R4:
[R4]mpls lsr-id 4.4.4.4
[R4]mpls
[R4-mpls]mpls ldp
[R4-mpls-ldp]q
[R4]interface g0/0/0
[R4-GigabitEthernet0/0/0]mpls
[R4-GigabitEthernet0/0/0]mpls ldp
在连接私网路由器上配置MPLS VPN
连接A两公司接口:
连接R1接口
[r2]ip -instance a
[r2--instance-a]ipv4-family
[r2--instance-a-af-ipv4]route-distinguisher 1:1
[r2--instance-a-af-ipv4]-target 1:1
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ip binding -instance a
[r2-GigabitEthernet0/0/0]ip address 192.168.2.2 24
1
2
3
4
5
6
7
8
连接R5接口
[R4]ip -instance a
[R4--instance-a]ipv4-family
[R4--instance-a-af-ipv4]route-distinguisher 1:1
[R4--instance-a-af-ipv4]-target 1:1
[R4--instance-a-af-ipv4]q
[R4--instance-a]q
[R4]interface g0/0/1
[R4-GigabitEthernet0/0/1]ip binding -instance a
[R4-GigabitEthernet0/0/1]ip address 192.168.3.2 24
连接B两接口:
连接R6接口:
[R2]ip -instance b
[R2--instance-b]ipv
[R2--instance-b]ipv4-family
[R2--instance-b-af-ipv4]route-distinguisher 2:2
[R2--instance-b-af-ipv4]-target 2:2
[R2--instance-b-af-ipv4]q
[R2--instance-b]q
[R2]interface GigabitEthernet 0/0/2
[R2-GigabitEthernet0/0/2]ip binding -instance b
[R2-GigabitEthernet0/0/2]ip address 192.168.2.2 24
连接R7接口
[R4]ip -instance b
[R4--instance-b]ipv4-family
[R4--instance-b-af-ipv4]route-distinguisher 2:2
[R4--instance-b-af-ipv4]-target 2:2
[R4--instance-b-af-ipv4]q
[R4--instance-b]q
[R4]interface g0/0/2
[R4-GigabitEthernet0/0/2]ip binding -instance b
[R4-GigabitEthernet0/0/2]ip address 192.168.3.1 24
PE与PE间建立MP-BPG邻居关系
[R2]bgp 1
[R2-bgp]router-id 2.2.2.2
[R2-bgp]pe 4.4.4.4 as-number 1
[R2-bgp]peer 4.4.4.4 next-hop-local
[R2-bgp]ipv4-family v4
[R2-bgp-af-v4]peer 4.4.4.4 enable
[R4]bgp 1
[R4-bgp]p
[R4-bgp]preference
[R4-bgp]pe2.2.2.2 as-number 1
[R4-bgp]peer 2.2.2.2 next-hop-local
[R4-bgp]ipv4-family v4
[R4-bgp-af-v4]peer 2.2.2.2 enable
CE端与PE端交互路由
A公司之间
R1与R2之间:
R1手写到分公司的路由,R2上要在空间里写静态 并在BGP里进行双向重发布,使R2学习到R1路由通过标签传递给R4的空间,实际传给了R5
[R2]ip route-static -instance a 192.168.1.0 24 192.168.2.1
[R2]ip route-static -instance a 192.168.2.0 24 192.168.2.1
[R2]bgp 1
[R2-bgp]ipv4 -instance a
[R2-bgp-a]import-route direct
[R2-bgp-a]import-route static
R4与R5之间,R5手写到分公司R1的静态:
[R5]ip route-static 192.168.1.0 24 192.168.3.2
[R5]ip route-static 192.168.2.0 24 192.168.3.2
[R4]ip route-static -instance a 192.168.3.0 24 192.168.3.1
[R4]ip route-static -instance a 192.168.4.0 24 192.168.3.1
[R4]bgp 1
[R4-bgp]ipv4 -instance a
[R4-bgp-a]import-route direct
[R4-bgp-a]import-route static
B公司之间R6与R2之间:
R6上使用rip宣告自己的环回和网段
[R6]rip 1
[R6-rip-1]version 2
[R6-rip-1]undo summary
[R6-rip-1]network 192.168.1.0
[R6-rip-1]network 192.168.2.0
R2上
[R2]rip
[R2]rip 1 -instance b 在VPN空间上起rip
[R2-rip-1]version 2
[R2-rip-1]undo summary
[R2-rip-1]network 192.168.2.0
进行双向重发布
[R2]rip 1 -instance b
[R2-rip-1]import-route bgp
[R2-rip-1]q
[R2]bgp 1
[R2-bgp]import-route rip 1
R7上
使用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.3.2 0.0.0.0
[r7-ospf-1-area-0.0.0.0]network 192.168.4.2 0.0.0.0
R4上
[R4]bgp 1
[R4-bgp]ipv4-family -instance b
[R4-bgp-b]import-route ospf 2
[R4-bgp-b]q
[R4-bgp]q
[R4]ospf 2
[R4]ospf 2 -instance b
[R4-ospf-2]import-route bgp
通过mpls 互通
A
B
在R7路由上配置缺省,使得能ping通R2R3R4环回
[r7]ip route-static 0.0.0.0 0 47.1.1.1
R4上宣告连接R7的另一个接口
[R4]ospf 1
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]net
[R4-ospf-1-area-0.0.0.0]network 47.1.1.1 0.0.0.0
[R4-ospf-1-area-0.0.0.0]q
[R4-ospf-1]q