MPLS-VPN实验:本实验模拟ISP为企业用户提供MPLS-VPN的网络环境。R1/2/3为ISP设备,组成公网MPLS域。R4/6是客户A设备,R5/7是客户B设备。
配置需求:
确认客户A的172.16.1.1与172.16.2.1互通。确认客户B的172.16.1.1和172.16.2.1互通。
ISP设备R1/2/3都有环回口Lo 0;R1/3与客户互联接口,划分VRF后再配置IP地址。
配置R1/2/3,运行ISIS,进程号1,区域号49.0123,所有设备均为level-2路由器。
运行BGP协议,AS号100,手动设置RID为Loopback0地址。关闭BGP默认建立ipv4邻居功能 R1与R3使用Looback0建立vpnv4邻居。
运行MPLS协议,LSR-ID为Loopback0地址启用LDP,自动分发标签。
配置MPLS-VPN。R1创建VRF,名称4,RD 4:4,出方向RT4:6。R3创建VRF,名称6,RD 6:6,出方向RT6:4。R1/3配置合适的入方向RT,接收对端vpnv4路由。
R1/4,R3/6分别使用物理口建立EBGP邻居关系。R4/R6宣告172.16.1.0/24、172.16.2.0/24,配置允许接收同as路由。
R1创建VRF,名称5,RD5:5,出方向RT5:7;R3创建VRF,名称7,RD7:7,出方向RT7:5。R1/3配置合适的入方向RT,接收对端vpnv4路由。
R1/5,R3/7建立OSPF邻居关系,进程1,手动设置RID为回环口IP;OSPF需要划入对应VRF。使用network命令宣告,通配符0.0.0.0。最后bgp和ospf相互引入。
为了方便理解,以下部分称之为第一部分。第二部分开始前有文字提醒。
第一部分开始:
1、配IP就不需要过多展示了,一下是我的IP地址配置。
[R1]dis ip in br
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 12.1.1.1/24 up up
GigabitEthernet0/0/1 192.168.14.1/24 up up
GigabitEthernet0/0/2 192.168.15.1/24 up up
LoopBack0 1.1.1.1/32 up up(s)
NULL0 unassigned up up(s)
[R2]dis ip in br
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 12.1.1.2/24 up up
GigabitEthernet0/0/1 23.1.1.12/24 up up
GigabitEthernet0/0/2 unassigned down down
LoopBack0 2.2.2.2/32 up up(s)
NULL0 unassigned up up(s)
[R3]dis ip in br
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 23.1.1.3/24 up up
GigabitEthernet0/0/1 192.168.36.3/24 up up
GigabitEthernet0/0/2 192.168.37.3/24 up up
LoopBack0 3.3.3.3/32 up up(s)
NULL0 unassigned up up(s)
[R4]dis ip in br
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.14.4/24 up up
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 172.16.1.1/24 up up(s)
NULL0 unassigned up up(s)
[R5]dis ip in br
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.15.5/24 up up
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 172.16.1.1/24 up up(s)
NULL0 unassigned up up(s)
[R6]dis ip in br
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.36.6/24 up up
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 172.16.2.1/24 up up(s)
NULL0 unassigned up up(s)
[R7]dis ip in br
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.37.7/24 up up
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 172.16.2.1/24 up up(s)
NULL0 unassigned up up(s)
2、接着就是IGP配置了,这里选用IS-IS+BGP协议。IS-IS配置开始:
[R1]isis 1
[R1-isis-1]network-entity 49.0123.0000.0000.0001.00
[R1-isis-1]is-level level-2
[R2]isis 1
[R2-isis-1]network-entity 49.0123.0000.0000.0002.00
[R2-isis-1]is-level level-2
[R3]isis 1
[R3-isis-1]network-entity 49.0123.0000.0000.0003.00
[R3-isis-1]is-level level-2
[R1]int g 0/0/0
[R1-GigabitEthernet0/0/0]isis enable 1
[R1-GigabitEthernet0/0/0]int loo 0
[R1-LoopBack0]isis enable 1
[R2]int g 0/0/0
[R2-GigabitEthernet0/0/0]isis enable 1
[R2-GigabitEthernet0/0/0]int g 0/0/1
[R2-GigabitEthernet0/0/1]isis enable 1
[R2-GigabitEthernet0/0/1]int loo 0
[R2-LoopBack0]isis enable 1
[R3]int g 0/0/0
[R3-GigabitEthernet0/0/0]isis enable 1
[R3-GigabitEthernet0/0/0]int loo 0
[R3-LoopBack0]isis enable 1
3、BGP配置开始:R1-R3的AS号为100,R4和R6的AS号为65001。
[R1]bgp 100
[R1]router-id 1.1.1.1
[R1-bgp]undo default ipv4-unicast
[R1-bgp]peer 3.3.3.3 as 100
[R1-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[R1-bgp]ipv4-family vpnv4
[R1-bgp-af-vpnv4]peer 3.3.3.3 enable
[R3]bgp 100
[R3]router-id 3.3.3.3
[R3-bgp]undo default ipv4-unicast
[R3-bgp]peer 1.1.1.1 as 100
[R3-bgp]peer 1.1.1.1 connect-interface LoopBack 0
[R3-bgp]ipv4-family vpnv4
[R3-bgp-af-vpnv4]peer 1.1.1.1 enable
4、MPLS配置,配置完成别忘记看标签是否正确一致。
[R1]mpls lsr-id 1.1.1.1
[R1]mpls
[R1-mpls]mpls ldp
[R1-mpls-ldp]int g 0/0/0
[R1-GigabitEthernet0/0/0]mpls
[R1-GigabitEthernet0/0/0]mpls ldp
[R2]mpls lsr-id 2.2.2.2
[R2]mpls
[R2-mpls]mpls ldp
[R2-mpls-ldp]int g 0/0/0
[R2-GigabitEthernet0/0/0]mpls
[R2-GigabitEthernet0/0/0]mpls ldp
[R2-GigabitEthernet0/0/0]int g 0/0/1
[R2-GigabitEthernet0/0/1]mpls
[R2-GigabitEthernet0/0/1]mpls ldp
[R3]mpls lsr-id 3.3.3.3
[R3]mpls
[R3-mpls]mpls ldp
[R3-mpls-ldp]int g 0/0/0
[R3-GigabitEthernet0/0/0]mpls
[R3-GigabitEthernet0/0/0]mpls ldp
5、 vpn-instance配置:
[R1]ip vpn-instance 4
[R1-vpn-instance-4]route-distinguisher 4:4
[R1-vpn-instance-4-af-ipv4]vpn-target 4:6 export-extcommunity
[R1-vpn-instance-4-af-ipv4]vpn-target 6:4 import-extcommunity
[R1-vpn-instance-4-af-ipv4]int g 0/0/1
[R1-GigabitEthernet0/0/1]ip binding vpn-instance 4
[R1-GigabitEthernet0/0/1]ip address 192.168.14.1 24
[R3]ip vpn-instance 6
[R3-vpn-instance-6]route-distinguisher 6:6
[R3-vpn-instance-6-af-ipv4]vpn-target 6:4 export-extcommunity
[R3-vpn-instance-6-af-ipv4]vpn-target 4:6 import-extcommunity
[R3-vpn-instance-6-af-ipv4]int g 0/0/1
[R3-GigabitEthernet0/0/1]ip binding vpn-instance 6
[R3-GigabitEthernet0/0/1]ip address 192.168.36.3 24
6、建立EBGP邻居
[R1]bgp 100
[R1-bgp]ipv4-family vpn-instance 4
[R1-bgp-4]peer 192.168.14.4 as-number 65001
[R4]bgp 65001
[R4-bgp]peer 192.168.14.1 as 100
[R4-bgp]peer 192.168.14.1 allow-as-loop
[R4-bgp]network 172.16.1.0 24
[R3]bgp 100
[R3-bgp]ipv4-family vpn-instance 6
[R3-bgp-6]peer 192.168.36.6 as 65001
[R6]bgp 65001
[R6-bgp]peer 192.168.36.3 as 100
[R6-bgp]peer 192.168.36.3 allow-as-loop
[R6-bgp]network 172.16.2.0 24
第一部分测试结果
[R4]ping -a 172.16.1.1 172.16.2.1
PING 172.16.2.1: 56 data bytes, press CTRL_C to break
Reply from 172.16.2.1: bytes=56 Sequence=1 ttl=252 time=40 ms
Reply from 172.16.2.1: bytes=56 Sequence=2 ttl=252 time=30 ms
Reply from 172.16.2.1: bytes=56 Sequence=3 ttl=252 time=40 ms
Reply from 172.16.2.1: bytes=56 Sequence=4 ttl=252 time=30 ms
Reply from 172.16.2.1: bytes=56 Sequence=5 ttl=252 time=40 ms
--------- 172.16.2.1 ping statistics ---------
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/36/40 ms
此部分为第一部分,截至此以上客户A的172.16.1.1与172.16.2.1互通完成。下面开始配置第二部分,使客户B的172.16.1.1与172.16.2.1互通
第二部分开始
1、vpn-instance配置
[R1]ip vpn-instance 5
[R1-vpn-instance-5]route-distinguisher 5:5
[R1-vpn-instance-5-af-ipv4]vpn-target 5:7 export-extcommunity
[R1-vpn-instance-5-af-ipv4]vpn-target 7:5 import-extcommunity
[R1-vpn-instance-5-af-ipv4]int g 0/0/02
[R1-GigabitEthernet0/0/2]ip binding vpn-instance 5
[R1-GigabitEthernet0/0/2]ip address 192.168.15.1 24
[R3]ip vpn-instance 7
[R3-vpn-instance-7]route-distinguisher 7:7
[R3-vpn-instance-7-af-ipv4]vpn-target 7:5 export-extcommunity
[R3-vpn-instance-7-af-ipv4]vpn-target 5:7 import-extcommunity
[R3-vpn-instance-7-af-ipv4]int g 0/0/2
[R3-GigabitEthernet0/0/2]ip binding vpn-instance 7
[R3-GigabitEthernet0/0/2]ip address 192.168.37.3 24
2、OSPF配置
[R1]ospf 1 router-id 1.1.1.1 vpn-instance 5
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 192.168.15.1 0.0.0.0
[R5]ospf 1 rou 5.5.5.5
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]network 192.168.15.5 0.0.0.0
[R5-ospf-1-area-0.0.0.0]network 172.16.1.1 0.0.0.0
[R3]ospf 1 router-id 3.3.3.3 vpn-instance 7
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 192.168.37.3 0.0.0.0
[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.37.7 0.0.0.0
[R7-ospf-1-area-0.0.0.0]network 172.16.2.1 0.0.0.0
3、BGP引入OSPF、OSPF引入BGP
[R1]bg 100
[R1-bgp]ipv4-family vpn-instance 5
[R1-bgp-5]import-route ospf 1
[R3]bg 100
[R3-bgp]ipv4-family vpn-instance 7
[R3-bgp-7]import-route ospf 1
[R1]ospf 1
[R1-ospf-1]import-route bgp
[R3]ospf 1
[R3-ospf-1]import-route bgp
4、第二部分测试结果
[R5]ping -a 172.16.1.1 172.16.2.1
PING 172.16.2.1: 56 data bytes, press CTRL_C to break
Reply from 172.16.2.1: bytes=56 Sequence=1 ttl=252 time=40 ms
Reply from 172.16.2.1: bytes=56 Sequence=2 ttl=252 time=40 ms
Reply from 172.16.2.1: bytes=56 Sequence=3 ttl=252 time=40 ms
Reply from 172.16.2.1: bytes=56 Sequence=4 ttl=252 time=40 ms
Reply from 172.16.2.1: bytes=56 Sequence=5 ttl=252 time=40 ms
— 172.16.2.1 ping statistics —
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/40/40 ms
Last
第二部分完成,至此实验结束。这个练习说简单也有些小细节需要处理,比如R1和R3上的BGP实例需要划入对应的实例中配置,笔者做第二部分OSPF经常忘记在BGP中划入相对应的实例。说难也没那么难,所谓孰能生巧,多练几次就能掌握。诸位理性观看,如有错误,欢迎指正~