目录
6.在CE和PE设备上通过静态路由进行配置(R1,R2,R4,R5)
7.在CE和PE设备上通过动态路由进行配置(R5,R2,R4,R7)
IP地址划分
- [r2]int g0/0/2
- [r2-GigabitEthernet0/0/2]ip add 23.1.1.1 24
- [r2]int lo0
- [r2-LoopBack0]ip add 2.2.2.2 24
- [r3]int g0/0/0
- [r3-GigabitEthernet0/0/0]ip add 23.1.1.2 24
- [r3]int g0/0/1
- [r3-GigabitEthernet0/0/1]ip add 34.1.1.1 24
- [r3]int lo0
- [r3-LoopBack0]ip add 3.3.3.3 24
- [r4]int g0/0/0
- [r4-GigabitEthernet0/0/0]ip add 34.1.1.2 24
- [r4]int lo0
- [r4-LoopBack0]ip add 4.4.4.4 24
由于实验要求R7单独的一根网线可以访问公网,所以我们在这里把R7的g0/0/1接口和R4的g4/0/0接口宣告在公网网段
- [r4]int g4/0/0
- [r4-GigabitEthernet4/0/0]ip add 47.1.1.1 24
- [r7]int g0/0/1
- [r7-GigabitEthernet0/0/1]ip add 47.1.1.2 24
- [r2]ospf 1 router-id 2.2.2.2
- [r2-ospf-1]a 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.0 0.0.0.255
- [r3]ospf 1 router-id 3.3.3.3
- [r3-ospf-1]a 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 3.3.3.3 0.0.0.0
- [r3-ospf-1-area-0.0.0.0]network 34.1.1.0 0.0.0.255
- [r4]ospf 1 router-id 4.4.4.4
- [r4-ospf-1]a 0
- [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 4.4.4.4 0.0.0.0
- [r4-ospf-1-area-0.0.0.0]network 47.1.1.1 0.0.0.0
在此处我们需要将R4的g4/0/0接口也宣告到OSPF中,这是为了保证R2和R3能访问R7,宣告R4的g4/0/0接口不是为了让R7运行OSPF协议。R7是客户站点,不能配置OSPF,所以要将R4的g4/0/0接口沉默。
[r4-ospf-1]silent-interface GigabitEthernet 4/0/0
而将接口沉默的效果是只收不发hello包,为了保证不接受hello包,我们也需要加个认证。
- [r4]int g4/0/0
- [r4-GigabitEthernet4/0/0]ospf authentication-mode md5 1 cipher 123456
为了让R7访问公网环回网段,需要配置静态路由
[r7]ip route-static 0.0.0.0 0 47.1.1.1
- [r2]mpls lsr-id 2.2.2.2
- [r2]mpls
- [r2-mpls]q
- [r2]mpls ldp
- [r2-mpls-ldp]q
- [r2]int g0/0/2
- [r2-GigabitEthernet0/0/2]mpls
- [r2-GigabitEthernet0/0/2]mpls ldp
- [r3]mpls lsr-id 3.3.3.3
- [r3]mpls
- [r3-mpls]q
- [r3]mpls ldp
- [r3-mpls-ldp]q
- [r3]int g0/0/0
- [r3-GigabitEthernet0/0/0]mpls
- [r3-GigabitEthernet0/0/0]mpls ldp
- [r3]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
- [r4-mpls]q
- [r4]mpls ldp
- [r4-mpls-ldp]q
- [r4]int g0/0/0
- [r4-GigabitEthernet0/0/0]mpls
- [r4-GigabitEthernet0/0/0]mpls ldp
- [r2]ip vpn-instance a1---VRF空间在命名时,大小写敏感
- [r2-vpn-instance-a1]route-distinguisher 100:1---配置RD值,不同VRF空间的RD值不能相同
- [r2-vpn-instance-a1-af-ipv4]vpn-target 100:1 export-extcommunity---配置出站RD值
- [r2-vpn-instance-a1-af-ipv4]vpn-target 100:2 import-extcommunity---配置入站RD值
- [r2]ip vpn-instance b1
- [r2-vpn-instance-b1]route-distinguisher 200:1
- [r2-vpn-instance-b1-af-ipv4]vpn-target 200:1 export-extcommunity
- [r2-vpn-instance-b1-af-ipv4]vpn-target 200:2 import-extcommunity
- [r4]ip vpn-instance a2
- [r4-vpn-instance-a2]route-distinguisher 100:1
- [r4-vpn-instance-a2-af-ipv4]vpn-target 100:1 import-extcommunity
- [r4-vpn-instance-a2-af-ipv4]vpn-target 100:2 export-extcommunity
- [r4]ip vpn-instance b2
- [r4-vpn-instance-b2]route-distinguisher 200:1
- [r4-vpn-instance-b2-af-ipv4]vpn-target 200:1 import-extcommunity
- [r4-vpn-instance-b2-af-ipv4]vpn-target 200:2 export-extcommunity
- [r2]int g0/0/0
- [r2-GigabitEthernet0/0/0]ip binding vpn-instance a1
- [r2]int g0/0/1
- [r2-GigabitEthernet0/0/1]ip binding vpn-instance b1
- [r4]int g0/0/1
- [r4-GigabitEthernet0/0/1]ip binding vpn-instance a2
- [r4]int g0/0/2
- [r4-GigabitEthernet0/0/2]ip binding vpn-instance b2
(PS:未绑定VRF关系前配置IP地址,绑定后配置的IP地址将会被移出,所以只能在绑定VRF关系后才能配置该接口的IP地址)
- [r1]int lo0
- [r1-LoopBack0]ip add 192.168.1.1 24
- [r1]int g0/0/0
- [r1-GigabitEthernet0/0/0]ip add 192.168.2.1 24
- [r2]int g0/0/0
- [r2-GigabitEthernet0/0/0]ip add 192.168.2.2 24
- [r4]int g0/0/1
- [r4-GigabitEthernet0/0/1]ip add 192.168.3.1 24
- [r5]int g0/0/0
- [r5-GigabitEthernet0/0/0]ip add 192.168.3.2 24
- [r5]int lo0
- [r5-LoopBack0]ip add 192.168.4.1 24
- [r6]int lo0
- [r6-LoopBack0]ip add 192.168.5.1 24
- [r6]int g0/0/0
- [r6-GigabitEthernet0/0/0]ip add 192.168.6.1 24
- [r2]int g0/0/1
- [r2-GigabitEthernet0/0/1]ip add 192.168.6.2 24
- [r4]int g0/0/2
- [r4-GigabitEthernet0/0/2]ip add 192.168.7.1 24
- [r7]int g0/0/0
- [r7-GigabitEthernet0/0/0]ip add 192.168.7.2 24
- [r7]int lo0
- [r7-LoopBack0]ip add 192.168.8.1 24
查看
测试
- [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 a1 192.168.1.0 24 192.168.2.1
- [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 a2 192.168.4.0 24 192.168.3.2
- [r2]bgp 1
- [r2-bgp]router-id 2.2.2.2
- [r2-bgp]peer 4.4.4.4 as 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
- ---PE设备之间传递的不是IPV4的路由信息,而是VPNV4的路由信息,
- 所以在普通的BGPV4邻居关系建立的基础上,需要在VPNV4的地址族中激活邻居关系。
- [r4]bgp 1
- [r4-bgp]router-id 4.4.4.4
- [r4-bgp]peer 2.2.2.2 as 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
- [r2-bgp]ipv4-family vpn-instance a1
- [r2-bgp-a1]network 192.168.1.0 24
- [r2-bgp-a1]network 192.168.2.0 24
- [r4-bgp]ipv4-family vpn-instance a2
- [r4-bgp-a2]network 192.168.3.0 24
- [r4-bgp-a2]network 192.168.4.0 24
查看路由发布情况
- [r6]rip 1
- [r6-rip-1]v 2
- [r6-rip-1]network 192.168.5.0
- [r6-rip-1]network 192.168.6.0
- [r2]rip 1 vpn-instance b1---在VRF空间中启动RIP进程
- [r2-rip-1]v 2
- [r2-rip-1]network 192.168.6.0
- [r2-rip-1]network 192.168.5.0
- [r7]ospf 1 router-id 7.7.7.7
- [r7-ospf-1]a 0
- [r7-ospf-1-area-0.0.0.0]network 192.168.7.0 0.0.0.255
- [r7-ospf-1-area-0.0.0.0]network 192.168.8.0 0.0.0.255
- [r4]ospf 2 vpn-instance b2 router-id 4.4.4.4---在VRF空间中启动OSPF进程
- [r4-ospf-2]a 0
- [r4-ospf-2-area-0.0.0.0]network 192.168.7.0 0.0.0.255
- [r2]bgp 1
- [r2-bgp]ipv4-family vpn-instance b1
- [r2-bgp-b1]import-route rip 1
- [r2]rip
- [r2-rip-1]import-route bgp
- [r4]bgp 1
- [r4-bgp]ipv4-family vpn-instance b2
- [r4-bgp-b2]import-route ospf 2
- [r4]ospf 2
- [r4-ospf-2]import-route bgp