目录
1、需求:
2、分析:
3、公网ip配置:
4、公网OSPF实现互通:
5、启动MPLS – LDP:
6、配置MPLS—VPN
1.PE与PE间建立MP-BPG邻居关系:
2.配置A公司MPLS—VPN(动态):
3.A公司CE端与PE端交互路由:
4.配置B公司MPLS—VPN(静态):
5.B公司CE端与PE端交互路由:
7、NAT:
8、测试:
1、需求:
2、分析:
根据图中要求进行MPLS-VPN配置;
A公司通过动态路由进行内部通信;B公司通过静态路由通信,B1和B2通过写缺省路由进入公网访问彼此。
R7可以访问公网用NAT
3、公网ip配置:
[r2]in l0
[r2-LoopBack0]ip add 2.2.2.2 32
[r2-LoopBack0]in g0/0/2
[r2-GigabitEthernet0/0/2]ip add 23.1.1.1 30
[r3]in l0
[r3-LoopBack0]ip add 3.3.3.3 32
[r3-LoopBack0]in g0/0/0
[r3-GigabitEthernet0/0/0]ip add 23.1.1.2 30
[r3-GigabitEthernet0/0/0]in g0/0/1
[r3-GigabitEthernet0/0/1]ip add 34.1.1.1 30
[r4]in l0
[r4-LoopBack0]ip add 4.4.4.4 32
[r4-LoopBack0]in g0/0/0
[r4-GigabitEthernet0/0/0]ip add 34.1.1.2 30
4、公网OSPF实现互通:
[r2]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 3.3.3.3 0.0.0.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
[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 0
[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
查看是否可达:
5、启动MPLS – LDP:
[r2]mpls lsr-id 2.2.2.2
#必须先定义mpls的router-id,要为本地设备的真实ip地址,且邻居可达,因为该地址将用于建立TCP会话,建议使用环回地址
[r2]mpls #再开启mpls协议
[r2-mpls]mpls ldp #再激活LDP协议
[r2-mpls-ldp]q
#之后需要在所有标签经过的接口上开启协议
[r2]interface GigabitEthernet 0/0/1
[r2-GigabitEthernet0/0/2]mpls #先开启MPLS
[r2-GigabitEthernet0/0/2]mpls ldp #再激活LDP协议
[r3]mpls lsr-id 3.3.3.3
[r3]mpls
[r3-mpls]mpls ldp
[r3-mpls-ldp]in g0/0/0
[r3-GigabitEthernet0/0/0]mpls
[r3-GigabitEthernet0/0/0]mpls ldp
[r3-GigabitEthernet0/0/0]in g0/0/0
[r3-GigabitEthernet0/0/1]mpls
[r3-GigabitEthernet0/0/1]mpls ldp
[r4]mpls lsr-id 4.4.4.4
[r4]mpls
[r4-mpls]mpls ldp
[r4-mpls-ldp]in g0/0/0
[r4-GigabitEthernet0/0/0]mpls
[r4-GigabitEthernet0/0/0]mpls ldp
查看tcp邻居关系:
查看邻居间基于TCP会话再建立邻居关系:
查看FIB表:
查看LIB表——装载本地和邻居为各条路由分配的标签号:
查看LFIB表:
6、配置MPLS—VPN
1.PE与PE间建立MP-BPG邻居关系:
#先和对端建立正常BGP邻居关系,可用于传递正常的公网路由
[r2]bgp 1
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 4.4.4.4 as-number 1
[r2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r2-bgp]peer 4.4.4.4 next-hop-local
[r2-bgp] #同时还需要再在IPV4的家族模式中,与对端建立一个VPNV4的关系,用于传递VPNV4路由
[r2-bgp]ipv4-family vpnv4
[r2-bgp-af-vpnv4]peer 4.4.4.4 enable
[r4]bgp 1
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 2.2.2.2 as-number 1
[r4-bgp]peer 2.2.2.2 con l 0
[r4-bgp]peer 2.2.2.2 next-hop-l
[r4-bgp]
[r4-bgp]ipv4-family vpnv4
[r4-bgp-af-vpnv4]peer 2.2.2.2 en
查看mp-bgp邻居关系:
2.配置A公司MPLS—VPN(动态):
[r2]ip vpn-instance a #创建名为a的vrf空间
[r2-vpn-instance-a]ipv4-family #进入IPV4的配置模式下
[r2-vpn-instance-a-af-ipv4]route-distinguisher 2:2 #RD值
[r2-vpn-instance-a-af-ipv4]vpn-target 2:2 #RT值 必须对端的PE端一致
[r2-vpn-instance-a-af-ipv4]in g0/0/1 #进入链接CE端的接口
[r2-GigabitEthernet0/0/1]ip binding vpn-instance a #关联到vrf空间
[r2-GigabitEthernet0/0/1]ip add 192.168.2.2 30 #配置私有ip地址
[r4]ip vpn-instance a
[r4-vpn-instance-a]ipv4-family
[r4-vpn-instance-a-af-ipv4]route-distinguisher 2:2
[r4-vpn-instance-a-af-ipv4]vpn-target 2:2
[r4-vpn-instance-a-af-ipv4]in g0/0/2
[r4-GigabitEthernet0/0/1]ip binding vpn-instance a
[r4-GigabitEthernet0/0/1]ip add 192.168.3.2 30
注:在关联到vrf空间前不能配置接口ip,否则该地址的直连路由将进入公有路由表
正常测试将在公有路由表中查询记录—该命令为基于VRF空间:
3.A公司CE端与PE端交互路由:
- CE端正常启动OSPF即可
- PE端,启动VPNV4专用的ospf协议
- 使用双向重发布,实现路由共享
A公司私网ip配置和路由(rip、ospf)
[a1]in l0
[a1-LoopBack0]ip add 192.168.1.1 24
[a1-LoopBack0]in g0/0/0
[a1-GigabitEthernet0/0/0]ip add 192.168.2.1 30
[a1]
[a1]rip 1
[a1-rip-1]version 2
[a1-rip-1]network 192.168.1.0
[a1-rip-1]network 192.168.2.0
[a2]in l0
[a2-LoopBack0]ip add 192.168.4.1 24
[a2-LoopBack0]in g0/0/0
[a2-GigabitEthernet0/0/0]ip add 192.168.3.1 30
[a2]
[a2]ospf 2 router-id 7.7.7.7
[a2-ospf-2]area 0
[a2-ospf-2-area-0.0.0.0]network 192.168.3.1 0.0.0.0
[a2-ospf-2-area-0.0.0.0]network 192.168.4.0 0.0.0.255
[r2]rip 1 vpn-instance a
[r2-rip-1]version 2
[r2-rip-1]network 192.168.2.0
[r4]ospf 2 vpn-instance a
[r4-ospf-2]area 0
[r4-ospf-2-area-0.0.0.0]network 192.168.3.2 0.0.0.0
使用双向重发布
[r2]rip 1 vpn-instance a
[r2-rip-1]import-route bgp
[r2]bgp 1
[r2-bgp]ipv4-family vpn-instance a
[r2-bgp-a]import-route rip 1
[r4]ospf 2 vpn-instance a
[r4-ospf-2]import-route bgp
[r4]bgp 1
[r4-bgp]ipv4-family vpn-instance a
[r4-bgp-a]import-route ospf 2
4.配置B公司MPLS—VPN(静态):
[r2]ip vpn-instance b
[r2-vpn-instance-b]ipv4-family
[r2-vpn-instance-b-af-ipv4]route-distinguisher 1:1
[r2-vpn-instance-b-af-ipv4]vpn-target 1:1
[r2-vpn-instance-b-af-ipv4]in g0/0/0
[r2-GigabitEthernet0/0/0]ip binding vpn-instance b
[r2-GigabitEthernet0/0/0]ip add 192.168.2.2 24
[r4]ip vpn-instance b
[r4-vpn-instance-b]ipv4-family
[r4-vpn-instance-b-af-ipv4]route-distinguisher 1:1
[r4-vpn-instance-b-af-ipv4]vpn-target 1:1
[r4-vpn-instance-b-af-ipv4]in g0/0/1
[r4-GigabitEthernet0/0/1]ip binding vpn-instance b
[r4-GigabitEthernet0/0/1]ip add 192.168.3.2 30
正常测试将在公有路由表中查询记录
5.B公司CE端与PE端交互路由:
- CE端直接编写静态路由即可(缺省指出去)
- PE端编写到VRF空间内的静态路由。
B公司私网ip配置和路由
[b1]in l0
[b1-LoopBack0]ip add 192.168.1.1 24
[b1-LoopBack0]in g0/0/0
[b1-GigabitEthernet0/0/0]ip add 192.168.2.1 30
[b2]in l0
[b2-LoopBack0]ip add 192.168.4.1 24
[b2-LoopBack0]in g0/0/0
[b2-GigabitEthernet0/0/0]ip add 192.168.3.1 30
[b1]ip route-static 0.0.0.0 0 192.168.2.2
[b2]ip route-static 0.0.0.0 0 192.168.3.2
重发布
[r2]ip route-static vpn-instance b 192.168.1.0 24 192.168.2.1
[r2]bgp 1
[r2-bgp]ipv4 vpn-instance b
[r2-bgp-b]import-route direct
[r2-bgp-b]import-route static
[r4]ip route-static vpn-instance b 192.168.4.0 24 192.168.3.1
[r4]bgp 1
[r4-bgp]ipv4 vpn-instance b
[r4-bgp-b]import-route direct
[r4-bgp-b]import-route static
查看双层标记的内层标签号
7、NAT:
[r4]in g4/0/0
[r4-GigabitEthernet4/0/0]ip add 47.1.1.1 30
[a2]in g0/0/1
[a2-GigabitEthernet0/0/1]ip add 47.1.1.2 30
[r4]ospf 1
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 47.1.1.0 0.0.0.3
[a2]acl 2023
[a2-acl-basic-2023]rule permit source 192.168.0.0 0.0.255.255
[a2-acl-basic-2023]in g0/0/1
[a2-GigabitEthernet0/0/1]nat outbound 2023
[a2]ip route-static 0.0.0.0 0 47.1.1.1
8、测试:
文章来源:https://www.toymoban.com/news/detail-477734.html
文章来源地址https://www.toymoban.com/news/detail-477734.html
到了这里,关于MPLS——VPN的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!