第十四天实验作业

在这里插入图片描述
1、配置ISP部分
先配置公网部分路由以AR2为例

[r2]int g0/0/1
[r2-GigabitEthernet0/0/1]ip address 23.1.1.1 255.255.255.0
[r2]int lo0
[r2-LoopBack0]ip address 2.2.2.2 255.255.255.0

[r4]int g4/0/0
[r4-GigabitEthernet4/0/0]ip address 47.1.1.1 255.255.255.0
2.配置igp路由
使用igp路由将ISP部分实现全网可达

[r2]ospf 1
[r2-ospf-1]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0.0.0.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

[r4]ospf 1
[r4-ospf-1]ospf 1 router-id 2 4.4.4.4
[r4-ospf-1]area 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 34.1.1.0 0.0.0.255
[r4-ospf-1-area-0.0.0.0] network 47.1.1.0 0.0.0.255
silent-interface GigabitEthernet0/0/2
因为0/0/2口不是公网,所以需要使用沉默接口防止发送hello包造成资源浪费

3.配置MPLS域
给ISP部分设置MPLS域,为后面BGP建立邻居防止路由黑洞。

[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/1]mpls
先开启MPLS
[r2-GigabitEthernet0/0/1]mpls ldp
再激活LDP协议

4.配置MPLS VPN
配置MPLS VPN空间用来区分A和B两个公司相同私有地址

[r2]ip vpn-instance a
创建名为a的vrf空间
[r2-vpn-instance-a]ipv4-family
进入IPV4的配置模式下
[r2-vpn-instance-a-af-ipv4]route-distinguisher 1:1
配置RD值
[r2-vpn-instance-a-af-ipv4]vpn-target 1:1
配置RT值 必须对端的PE端一致
[r2]interface GigabitEthernet 0/0/2
进入链接CE端的接口
[r2-GigabitEthernet0/0/2]ip binding vpn-instance a
关联到vrf空间
[r2-GigabitEthernet0/0/2]ip address 192.168.2.2 24
配置私有ip地址

[r2]ip vpn-instance b
创建名为a的vrf空间
[r2-vpn-instance-b]ipv4-family
进入IPV4的配置模式下
[r2-vpn-instance-b-af-ipv4]route-distinguisher 2:2
配置RD值
[r2-vpn-instance-a-af-ipv4]vpn-target 2:2
配置RT值 必须对端的PE端一致
[r2]interface GigabitEthernet 0/0/0
进入链接CE端的接口
[r2-GigabitEthernet0/0/0]ip binding vpn-instance b
关联到vrf空间
[r2-GigabitEthernet0/0/0]ip address 192.168.2.2 24
配置私有ip地址

注:在关联到vrf空间前不能配置接口ip,否则该地址的直连路由将进入公有路由表;

5.建立BGP邻居
在AR2与AR4两个PE间建立BGP邻居关系

[r2]bgp 2
[r2-bgp]router-id 2.2.2.2
先和对端建立正常BGP邻居关系,可用于传递正常的公网路由
[r2-bgp]pe 4.4.4.4 as-number 2
[r2-bgp]pe 4.4.4.4 connect-interface LoopBack 0
[r2-bgp]pe 4.4.4.4 next-hop-local
同时还需要再在IPV4的家族模式中,与对端建立一个VPNV4的关系,用于传递VPNV4路由
[r2-bgp]ipv4-family vpnv4
[r2-bgp-af-vpnv4]peer 4.4.4.4 enable
[r2-bgp]display bgp vpnv4 all peer 查看mp-bgp邻居关系

6.实现客户端相互通信
配置B公司
因为AR1只有1.0和2.0网段的路由,所以需要手写静态路由学习3.0与4.0网段路由。

[r1]ip route-static 192.168.3.0 255.255.255.0 192.168.2.2
[r1]ip route-static 192.168.4.0 255.255.255.0 192.168.2.2

在对PE端书写静态时,需要注意进入VPN空间书写,否则是使用路由器的物理接口建立静态,导致路由不可达。

[r2]ip route-static vpn-instance b 192.168.1.0 24 192.168.2.1

[r4]ip route-static vpn-instance b 192.168.4.0 255.255.255.0 192.168.3.1

将本地vrf空间内的静态和直连路由重发布到BGP协议传递到对端的PE

[r2]bgp 2
[r2-bgp]ipv4 vpn-instance b
[r2-bgp-a]import-route direct
[r2-bgp-a]import-route static

[r4]bgp 2
[r4-bgp]ipv4 vpn-instance b
[r4-bgp-a]import-route direct
[r4-bgp-a]import-route static

配置A公司

[r6]rip 1
[r6-rip-1]version 2
[r6-rip-1]un su
[r6-rip-1]network 192.168.1.0
[r6-rip-1]network 192.168.2.0

[r7]ospf 2 vpn-instance a
[r7-ospf-2]area 0
[r7-ospf-2-area-0.0.0.0]network 192.168.3.1 0.0.0.0
[r7-ospf-2-area-0.0.0.0]network 192.168.4.1 0.0.0.0

[r2]rip 1 vpn-instance a
[r2-rip-1]version 2
[r2-rip-1]un su
[r2-rip-1]network 192.168.1.0
[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.1 0.0.0.0

之后使用双向重发布,实现路由共享

[r2]bgp 2
[r2-bgp]ipv4-family vpn-instance a
[r2-bgp-a]import-route ospf 2

[r2]rip 1 vpn-instance a
[r2-rip-1]import-route bgp

[r4]bgp 2
[r4-bgp]ipv4-family vpn-instance a
[r4-bgp-a]import-route ospf 2

[r4]ospf 2 vpn-instance a
[r4-ospf-2]import-route bgp

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值