eNSP 配置MPLS 不同局域网互通

一、配置公网网络环境

如图配置R2/3/4的IP地址

再启动OSPF,需注意R4上需要宣告47.1.1.0/24,R7上在写一条缺省路由指向R4,以确保R7可以访问公网

[r4]ospf 1 ro 4.4.4.4
[r4-ospf-1]a 0
[r4-ospf-1-area-0.0.0.0]network 34.1.1.2 0.0.0.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 47.1.1.1 0.0.0.0

[r7]ip route-static 0.0.0.0 0 47.1.1.1

二、启用MPLS

在公网通讯解决后,需要在R2/3/4上启用MPLS

此处列举R3的配置

[r3]mpls lsr-id 3.3.3.3 
###必须先定义mpls的router-id,要为本地设备的真实ip地址,且邻居可达,
###因为该地址将用于建立TCP会话,建议使用环回地址
[r3]mpls
###再开启mpls协议
Info: Mpls starting, please wait... OK!
[r3-mpls]mpls ldp
###再激活LDP协议
[r3-mpls-ldp]q
###之后需要在所有标签经过的接口上开启协议
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]mpls
[r3-GigabitEthernet0/0/1]mpls ldp
[r3]int g0/0/1
[r3-GigabitEthernet0/0/1]mpls
[r3-GigabitEthernet0/0/1]mpls ldp

查看MPLS邻居关系

[r3]dis mpls ldp peer
 
 LDP Peer Information in Public network
 A '*' before a peer means the peer is being deleted.
 ------------------------------------------------------------------------------
 PeerID                 TransportAddress   DiscoverySource
 ------------------------------------------------------------------------------
 2.2.2.2:0              2.2.2.2            GigabitEthernet0/0/0
 4.4.4.4:0              4.4.4.4            GigabitEthernet0/0/1
 ------------------------------------------------------------------------------
 TOTAL: 2 Peer(s) Found.

三、配置MPLS 空间

此处列举R2配置b1和a1空间

[r2]ip vpn-instance b1
###创建名为b1的vrf空间
[r2-vpn-instance-b1]route-distinguisher 1:1
[r2-vpn-instance-b1-af-ipv4]vpn-target 1:1
###设置RD值和RT值,RT值必须对端的PE端一致
 IVT Assignment result: 
Info: VPN-Target assignment is successful.
 EVT Assignment result: 
Info: VPN-Target assignment is successful.
[r2-vpn-instance-b1-af-ipv4]q
[r2-vpn-instance-b1]q
[r2]ip vpn-instance a1
[r2-vpn-instance-a1]route-distinguisher 2:2
[r2-vpn-instance-a1-af-ipv4]vpn-target 2:2
 IVT Assignment result: 
Info: VPN-Target assignment is successful.
 EVT Assignment result: 
Info: VPN-Target assignment is successful.
[r2-vpn-instance-a1-af-ipv4]q
[r2-vpn-instance-a1]q


[r2]int g0/0/0
###进入链接CE端的接口
[r2-GigabitEthernet0/0/0]ip binding vpn-instance b1
###关联到vrf空间
Info: All IPv4 related configurations on this interface are removed!
Info: All IPv6 related configurations on this interface are removed!
[r2-GigabitEthernet0/0/0]ip ad 192.168.2.2 24
###配置私有ip地址
###注:在关联到vrf空间前不能配置接口ip,否则该地址的直连路由将进入公有路由表
Aug  6 2022 00:39:56-08:00 r2 %%01IFNET/4/LINK_STATE(l)[6]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state. 
[r2-GigabitEthernet0/0/0]q
[r2]int g0/0/2
[r2-GigabitEthernet0/0/2]ip binding vpn-instance a1
Info: All IPv4 related configurations on this interface are removed!
Info: All IPv6 related configurations on this interface are removed!
[r2-GigabitEthernet0/0/2]ip ad 192.168.2.2 24

再将R2与R4就行BGP建邻,用于传递VPN的路由

此处列举R2的配置

[r2-bgp]ro 2.2.2.2
[r2-bgp]peer 4.4.4.4 as 1
[r2-bgp]peer 4.4.4.4 con lo 0

###同时还需要再在IPV4的家族模式中,与对端建立一个VPNV4的关系,用于传递VPNV4路由
[r2-bgp]ipv4-family vpnv4
[r2-bgp-af-vpnv4]peer 4.4.4.4 enable 

查看建邻情况

[r4-bgp-b2]dis bgp vpnv4 all peer

 BGP local router ID : 4.4.4.4
 Local AS number : 1
 Total number of peers : 1                Peers in established state : 1

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  2.2.2.2         4           1       89       89     0 01:23:04 Established       0

四、传递私网路由

a1---a2

a1中启用RIP

[r6]rip 1
[r6-rip-1]ver 2
[r6-rip-1]network 192.168.1.0
[r6-rip-1]network 192.168.2.0



[r2]rip 1 vpn 
[r2]rip 1 vpn-instance a1
###在vpn空间a2中进行配置
[r2-rip-1]ver 2
[r2-rip-1]network 192.168.2.0

###进行双向重发布
[r2]rip vpn-instance a1
###在vpn空间a1中进行重发布
[r2-rip-1]import-route bgp
[r2-rip-1]q
[r2]bgp 1
[r2-bgp]ipv4-family vpn-instance a1
###在vpn空间a1中进行重发布
[r2-bgp-a1]import-route rip 1

a2中启用OSPF

[r7]ospf 1 ro 7.7.7.7
[r7-ospf-1]a 0
[r7-ospf-1-area-0.0.0.0]ne
[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]ospf 2 vpn-instance a2
###启用另一个进程号的ospf
[r4-ospf-2]a 0
[r4-ospf-2-area-0.0.0.0]network 192.168.3.1 0.0.0.0
[r4]bgp 1 
[r4-bgp]ipv4-family vpn-instance a2
###在vpn空间a2中进行重发布
[r4-bgp-a2]import-route ospf 2
[r4]ospf 2 vpn-instance a2
###在vpn空间a2中进行重发布
[r4-ospf-2]import-route bgp  

b1---b2

b1,b2环境使用的是静态路由

[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

[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

需要令R2学习到R1环回,以及b2空间中的两条路由

需要令R4学习到R5环回,以及b1空间中的两条路由

[r2]ip route-static vpn-instance b1 192.168.1.0 24 192.168.2.1
###在vpn空间中写上关于R1环回的静态路由
[r2]bgp 1
[r2-bgp]ipv4-family vpn-instance b1
[r2-bgp-b1]import-route direct 
[r2-bgp-b1]import-route static 
###再在bgp的vpn空间中导入它的直连和静态路由
###此时可以通过R2-R4的BGP的vpn邻居关系传递这两条路由

[r4]ip route-static vpn-instance b2 192.168.4.0 24 192.168.3.2
[r4]bgp 1
[r4-bgp]ipv4-family vpn-instance b2
[r4-bgp-b2]import-route direct 
[r4-bgp-b2]import-route static 

五、测试

a1--a2

b1--b2

R7访问公网

  • 2
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值