一.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:
interface LoopBack0
ip address 192.168.1.1 24
interface GigabitEthernet0/0/0
ip address 192.168.2.1 24
r2:
interface LoopBack0
ip address 2.2.2.2 24
interface GigabitEthernet0/0/2
ip address 23.1.1.2 24
r3:
interface LoopBack0
ip address 3.3.3.3 24
interface GigabitEthernet0/0/0
ip address 23.1.1.3 24
interface GigabitEthernet0/0/1
ip address 34.1.1.3 24
r4:
interface LoopBack0
ip address 4.4.4.4 24
interface GigabitEthernet0/0/0
ip address 34.1.1.4 24
r5:
interface LoopBack0
ip address 192.168.4.1 24
interface GigabitEthernet0/0/0
ip address 192.168.3.2 24
r6:
interface LoopBack0
ip address 192.168.1.1 24
interface GigabitEthernet0/0/0
ip address 192.168.2.1 24
r7:
interface GigabitEthernet0/0/0
ip address 192.168.3.2 24
interface GigabitEthernet0/0/1
ip address 47.1.1.7 24
interface GigabitEthernet0/0/2
interface LoopBack0
ip address 192.168.4.2 24
三.公网配置(IGP使用OSPF)
r2:
ospf 1 router-id 2.2.2.2
area 0
network 2.2.2.2 0.0.0.0
network 23.1.1.2 0.0.0.0
r3:
ospf 1 router-id 3.3.3.3
area 0
network 0.0.0.0 255.255.255.255
r4:
ospf 1 router-id 4.4.4.4
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 34.1.1.4 0.0.0.0
四.公网配置MPLS
r2:
mpls lsr-id 2.2.2.2 先定义mpls的router-id,要本地真实ip地址,该地址用于建立TCP会话
mpls 开启mpls协议
mpls ldp 再激活LDP协议
之后需要在所有标签经过的接口上开启协议
interface GigabitEthernet0/0/2
mpls
mpls ldp
r3:
mpls lsr-id 3.3.3.3
mpls
mpls ldp
interface GigabitEthernet0/0/0
mpls
mpls ldp
interface GigabitEthernet0/0/1
mpls
mpls ldp
r4:
mpls lsr-id 4.4.4.4
mpls
mpls ldp
interface GigabitEthernet0/0/0
mpls
mpls ldp
五.公网配置MPLS-VPN
r2:
ip vpn-instance a 创建名为a的vrf空间
ipv4-family 进入ipv4的配置模式下
route-distinguisher 1:1 RD值
vpn-target 1:1 RT值 必须对端的PE端一致
interface GigabitEthernet0/0/1 进入链接CE端的接口
ip binding vpn-instance a 关联到vrf空间
ip address 192.168.2.2 24 配置私有ip地址
ip vpn-instance b
ipv4-family
route-distinguisher 2:2
vpn-target 2:2
vpn-target 2:2
interface GigabitEthernet0/0/0
ip binding vpn-instance b
ip address 192.168.2.2 24
r4:
ip vpn-instance a
ipv4-family
route-distinguisher 1:1
vpn-target 1:1
interface GigabitEthernet0/0/2
ip binding vpn-instance a
ip address 192.168.3.1 24
ip vpn-instance b
ipv4-family
route-distinguisher 2:2
vpn-target 2:2
interface GigabitEthernet0/0/1
ip binding vpn-instance b
ip address 192.168.3.1 24
六.r2-r4使用BGP建邻并实现VPN建邻
r2:
bgp 1
router-id 2.2.2.2
peer 4.4.4.4 as-number 1
peer 4.4.4.4 connect-interface LoopBack0
peer 4.4.4.4 next-hop-local
ipv4-family vpnv4
peer 4.4.4.4 enable
r4:
bgp 1
router-id 4.4.4.4
peer 2.2.2.2 as-number 1
peer 2.2.2.2 connect-interface LoopBack0
peer 2.2.2.2 next-hop-local
ipv4-family vpnv4
peer 2.2.2.2 enable
七:配置空间a的动态协议(r2-r6,r4-r7)
r6:(CE)
rip 1
version 2
network 192.168.1.0
network 192.168.2.0
r2:(PE)
rip 1 vpn-instance a PE端启动vpnv4专用的rip协议
version 2
network 192.168.2.0
r7:(CE)
ospf 1 router-id 7.7.7.7
area 0
network 192.168.3.2 0.0.0.0
network 192.168.4.2 0.0.0.0
r4:(PE) PE端启动vpnv4专用的ospf协议
ospf 2 vpn-instance a
area 0
network 192.168.3.1 0.0.0.0
八:配置空间b的静态协议(r1-r2,r4-r5)
r1:(CE)
ip route-static 192.168.3.0 24 192.168.2.2
ip route-static 192.168.4.0 24 192.168.2.2
r2: (PE)
ip route-static vpn-instance b 192.168.1.0 24 192.168.2.1 PE端编写到vrf空间内的静态路由
r5:(CE)
ip route-static 192.168.1.0 24 192.168.3.1
ip route-static 192.168.2.0 24 192.168.3.1
r4:(PE)
ip route-static vpn-instance b 192.168.4.0 24 192.168.3.2 PE端编写到vrf空间内的静态路由
九.重发布
1.vrf空间a
r2:
rip 1 vpn-instance a 进入ipv4 vpn空间重发布
version 2
import-route bgp
bgp 1
ipv4-family vpn-instance a 进入ipv4 vpn空间重发布
import-route rip 1
r4:
ospf 2 vpn-instance a 进入ipv4 vpn空间重发布
import-route bgp
bgp 1
ipv4-family vpn-instance a 进入ipv4 vpn空间重发布
import-route ospf 2
2.vrf空间b
r2:
bgp 1
import-route direct
import-route static
r4:
bgp 1
import-route direct
import-route static
十.私网r7搭建专线访问公网
r7:
ip route-static 0.0.0.0 0.0.0.0 47.1.1.4
r4:
[r4]ospf 1
[r4-ospf-1]a 0
[r4-ospf-1-area-0.0.0.0]net 47.1.1.4 0.0.0.0
[r4-ospf-1]silent-interface g1/0/0 与PE端为沉默接口,只接受不发送,将不占用带宽(hello包)
十一.测试