春风十里不如你 —— Taozi - 组网 2023-05-22T19:07:26+08:00 Typecho https://www.xiongan.host/index.php/feed/atom/tag/%E7%BB%84%E7%BD%91/ <![CDATA[【ENSP】GRE协议基础配置]]> https://www.xiongan.host/index.php/archives/210/ 2023-05-22T19:07:26+08:00 2023-05-22T19:07:26+08:00 admin https://www.xiongan.host GRE协议基础配置

本实验模拟企业网络场景,R1为企业总部的网关设备,并且内部有一台服务器,R3连接着企业分公司网关设备,R2为公网ISP设备。一般情况下,运营商只会维护自身的公网路由信息,而不会维护企业内部私网的路由信息,即运营商设备上的路由表中不会出现任何企业内部私网的路由条目。通过配置GRE实现公司总部和分部间私网路由信息的透传及数据通信。

拓扑实验

1684725003897

1684724964839

实验步骤

配置接口端口地址,根据上图信息进行配置

检测R1、R3直连链路的连通性

1684725679943

1684725739113

配置R1、R3默认路由

[R1]ip route-static 0.0.0.0 0.0.0.0 10.1.12.2
[R3]ip route-static 0.0.0.0 0.0.0.0 10.1.23.2

测试PC1和Server1的连通性

1684726077765

可以观察到,跨越了互联网的两个私网网段之间默认是无法直接通信的。此时可以通过GRE协议来实现跨越了互联网的两个私网网段之间的通信。

配置GRE Tunnel

配置R1、R3的GRE tunnel

在路由器R1、R3上配置GRE Tunnel,使用命令interface tunnel创建隧道接口,指定隧道模式为GRE。配置R1、R3 Tunnel接口的源地址为其S 1/0/0接口IP地址,目的地址为R1/R3的S 1/0/0接口IP地址。还要使用命令ip address配置Tunnel接口的IP地址,注意要在同一网段。

1684726463543

1684726570311

测试R1与目的地址的连通性

1684726676501

检查R1、R3隧道接口状态

1684726763561

1684726845074

检查R1、R3路由表

1684726889733

1684726908531

配置基于GRE接口的动态路由协议

测试PC1与Server1的连通性,发现还不能联通

1684727035010

配置R1、R3 RIPv2协议

1684727119110

1684727171142

检查R1、R3的RIP邻居

1684727223382

1684727242742

检查R1、R3路由表

1684727283255

1684727309531

测试PC1和Server1的连通性,可以看到已经联通

1684727349281

查看R2的路由表

1684727393881

]]>
<![CDATA[【ENSP】RSTP和MSTP基础配置]]> https://www.xiongan.host/index.php/archives/209/ 2023-05-22T19:00:23+08:00 2023-05-22T19:00:23+08:00 admin https://www.xiongan.host RSTP、MSTP基础配置

实验组网

1684719281673

任务步骤

设备开启STP,并将STP模式切换为RSTP

[S1]stp enable
[S1]stp mode rstp
[S2]stp enable
[S2]stp mode rstp
[S3]stp enable
[S3]stp mode rstp
[S4]stp enable
[S4]stp mode rstp

1684720282267

查看STP的状态和统计信息摘要

1684720489701

1684720513926

1684720543670

1684720568088

在S1上查看STP的状态和统计信息(S1为根桥交换机)

1684720917704

根桥选举控制

配置S1为主根桥,S2为备份根桥

[S1]stp priority 4096
[S2]stp priority 8192

在另外两台交换机保持默认桥优先级(32768)的情况下,S1拥有最小的桥优先级,S2次之。

再次查看S1上的状态信息(此时S1的桥优先级为4096,并且此时仍然是根桥)

1684721119496

取消S1、S2上手动调整桥优先级的配置,使用stp root命令指定根桥和备份根桥

[S1]undo stp priority
[S1]stp root primary
[S2]undo stp priority
[S2]stp root secondary

查看S1和S2的stp状态信息

1684721311217

1684721329737

S1的桥优先级为0,而S2的桥优先级为4096,此时S1为根桥,S2为备份根桥。

修改接口开销控制根端口选举

在S4上查看stp状态和统计信息

1684721474502

S4上0/0/2拥有更小的RPC(根路径开销),从而成为根端口

查看S4的0/0/2的STP状态和统计信息

1684721623276

此时路径开销计算方法为Dotlt,接口的STP cost的值为20000

修改S4的0/0/2的STP cost值为40001

[S4]interface g0/0/2
[S4-GigabitEthernet0/0/2]stp cost 40001
[S4-GigabitEthernet0/0/2]

查看s4的STP状态信息

1684721879063

此时0/0/1的RPC为40000,小鱼0/0/2的RPC 40001 S4的0/0/1接口成为根端口

修改接口优先级控制根端口选举

查看S2的STP状态信息

1684722038120

S2上GE0/0/10、GE0/0/11接口收到的BPDU拥有相同的RPC、网桥ID、接口优先级,此时将会比较接收到的BPDU接口ID中的接口编号。

在S1、S2上开启LLDP,查看接口的互联关系

[S1]lldp enable
[S2]lldp enable
[S2]display lldp neighbor brief

1684722179609

S2的GE0/0/10接口对端为S1的GE0/0/10接口,S2的GE0/0/11接口对端为S1的GE0/0/11接口,S2的GE0/0/10接口接收到的BPDU拥有更小的接口编号,这是GE0/0/10成为根端口的原因

在S1上修改GE0/0/11的STP接口优先级,使其发送的BPDU优于 GE0/0/10发送的BPDU

[S1]interface GigabitEthernet 0/0/11
[S1-GigabitEthernet0/0/11] stp port priority 64

STP接口优先级为128,数值越小越优。

再次查看S2的stp状态信息

1684722305430

此时S2的GE0/0/10接口成为根端口。

MSTP基础配置

在所有交换机上创建VLAN10、20、30、40、50、60、70、80,配置MSTP域hcip,并创建两个新的实例:Instance 1、Instance 2,将VLAN10、30、50、70映射到Instance 1,将VLAN20、40、60、80映射到Instance 2,同时将SW1规划为MSTI1的主根桥、MSTI2的备份根桥,将SW2规划为MSTI2的主根桥、MSTI1的备份根桥。

[S1]vlan batch 10 20 30 40 50 60 70 80
[S2]vlan batch 10 20 30 40 50 60 70 80
[S3]vlan batch 10 20 30 40 50 60 70 80
[S4]vlan batch 10 20 30 40 50 60 70 80

将所有的互联接口(S1、S2、S3、S4)配置为Trunk接口,放通所有的(接口端口)Vlan

interface GigabitEthernet0/0/10
 port link-type trunk
 port trunk allow-pass vlan 10 20 30 40 50 60 70 80
#
interface GigabitEthernet0/0/11
 port link-type trunk
 port trunk allow-pass vlan 10 20 30 40 50 60 70 80
 stp instance 0 port priority 64
#
interface GigabitEthernet0/0/12
 port link-type trunk
 port trunk allow-pass vlan 10 20 30 40 50 60 70 80
#
interface GigabitEthernet0/0/13
 port link-type trunk
 port trunk allow-pass vlan 10 20 30 40 50 60 70 80

修改STP模式为MSTP

[S1]stp mode mstp
[S2]stp mode mstp
[S3]stp mode mstp
[S4]stp mode mstp

配置MSTP

[S1]stp region-configuration
[S1-mst-region] region-name hcip
[S1-mst-region] revision-level 1
[S1-mst-region] instance 1 vlan 10 30 50 70
[S1-mst-region] instance 2 vlan 20 40 60 80
[S1-mst-region] active region-configuration
Info: This operation may take a few seconds. Please wait for a moment...done.
[S1-mst-region] quit
/
[S2]stp region-configuration
[S2-mst-region] region-name hcip
[S2-mst-region] revision-level 1
[S2-mst-region] instance 1 vlan 10 30 50 70
[S2-mst-region] instance 2 vlan 20 40 60 80
[S2-mst-region] active region-configuration
Info: This operation may take a few seconds. Please wait for a moment...done.
[S2-mst-region] quit
/
[S3]stp region-configuration
[S3-mst-region] region-name hcip
[S3-mst-region] revision-level 1
[S3-mst-region] instance 1 vlan 10 30 50 70
[S3-mst-region] instance 2 vlan 20 40 60 80
[S3-mst-region] active region-configuration
Info: This operation may take a few seconds. Please wait for a moment...done.
[S3-mst-region] quit
/
[S4]stp region-configuration
[S4-mst-region] region-name hcip
[S4-mst-region] revision-level 1
[S4-mst-region] instance 1 vlan 10 30 50 70
[S4-mst-region] instance 2 vlan 20 40 60 80
[S4-mst-region] active region-configuration
Info: This operation may take a few seconds. Please wait for a moment...done.
[S4-mst-region] quit

在S1上检查MSTP实例和Vlan的映射关系

1684722873417

//配置SW1为MSTI1的根桥、MSTI2的备份根桥
[S1]stp instance 1 root primary 
[S1]stp instance 2 root secondary
//配置SW2为MSTI2的根桥、MSTI1的备份根桥
[S2]stp instance 1 root secondary 
[S2]stp instance 2 root primary

在S1上查看MST1状态信息

1684724119504

S1上所有接口都是指定接口,S1为MSTI1的根桥

1684724164486

S2上所有接口都是指定接口,S2为MSTI2的根桥。

]]>
<![CDATA[【HCIP】路由策略与路由控制]]> https://www.xiongan.host/index.php/archives/203/ 2023-05-06T20:24:50+08:00 2023-05-06T20:24:50+08:00 admin https://www.xiongan.host 路由策略与路由控制

实验组网

1682218215575

每台设备都创建了Loopback0,地址为10.123.x.x/32(x为设备号)

在R2、R4上测试ip连通性

1682218707426

1682218720689

配置OSPF、IS-IS

R1、R2、R3使用Loopback0接口地址作为Router ID,在互联接口、Loopback0接口上激活OSPF。

//R1
[R1]ospf 1 router-id 10.123.1.1
[R1-ospf-1] area 0
[R1-ospf-1-area-0.0.0.0] network 10.123.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0] network 10.123.12.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0] quit
[R1-ospf-1] quit

1682219138575

//R2
[R2]ospf 1 router-id 10.123.2.2
[R2-ospf-1] area 0.0.0.0
[R2-ospf-1-area-0.0.0.0] network 10.123.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0] network 10.123.12.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0] network 10.123.23.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0] quit
[R2-ospf-1] quit

1682219234462

//R3
[R3]ospf 1 router-id 10.123.3.3
[R3-ospf-1] area 0.0.0.0
[R3-ospf-1-area-0.0.0.0] network 10.123.3.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0] network 10.123.23.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0] quit
[R3-ospf-1] quit

1682219275126

在R2上检查OSPF邻居概要信息

1682219311591

R3、R4上配置IS-IS,区域为49.0001,系统ID采用0000.0000.000x格式(x为设备编号),两台设备都为Level-1路由器,在互联接口、R4的Loopback0接口上激活IS-IS。

//R3
[R3]isis 1
[R3-isis-1] is-level level-1
[R3-isis-1] network-entity 49.0001.0000.0000.0003.00
[R3-isis-1] quit
[R3]interface GigabitEthernet0/0/1
[R3-GigabitEthernet0/0/1] isis enable 1
[R3-GigabitEthernet0/0/1] quit

1682219708071

//R4
[R4]isis 1
[R4-isis-1] is-level level-1
[R4-isis-1] network-entity 49.0001.0000.0000.0004.00
[R4-isis-1] quit
[R4]interface GigabitEthernet0/0/0
[R4-GigabitEthernet0/0/0] isis enable 1
[R4-GigabitEthernet0/0/0] quit
[R4]interface LoopBack 0
[R4-LoopBack0] isis enable 1
[R4-LoopBack0] quit

1682219778719

在R3上检查IS-IS邻居状态

1682219823838

在R1上引入直连路由

创建IP前缀列表1,匹配Loopback1接口路由(A业务网段)

[R1]ip ip-prefix 1 index 10 permit 172.16.1.0 24 greater-equal 24 less-equal 24

创建IP前缀列表2,匹配Loopback2接口路由(B业务网段)

[R1]ip ip-prefix 2 index 10 permit 172.16.2.0 24 greater-equal 24 less-equal 24

1682220874885

创建Route-Policy hcip,并创建节点10、20,分别调用IP前缀列表1、2,打上路由标记

[R1]route-policy hcip permit node 10
[R1-route-policy] if-match ip-prefix 1
[R1-route-policy] apply tag 10
[R1-route-policy] quit
[R1]route-policy hcip permit node 20
[R1-route-policy] if-match ip-prefix 2
[R1-route-policy] apply tag 20 
[R1-route-policy] quit

1682220900637

在R1的OSPF中引入直连路由,调用Route-Policy hcip

[R1]ospf 1
[R1-ospf-1] import-route direct route-policy hcip

1682220936669

在R1上查看OSPF LSDB

1682220968693

Loopback1、2接口路由已经被成功引入OSPF中

在R1上查看OSPF LSDB中AS-external LSA 172.16.1.0、172.16.2.0的相关信息

1682221042318

在R2上配置过滤策略

在R2上配置Filter-Policy对接收的OSPF路由进行过滤,只接收B业务网段的路由。

查看配置Filter-Policy前的OSPF路由表

1682221201853

查看配置Filter-Policy前的IP路由表中的OSPF路由

1682221298477

配置基础ACL

[R2]acl number 2000
[R2-acl-basic-2000] rule 5 deny source 172.16.1.0 0.0.0.255
[R2-acl-basic-2000] rule 10 permit

1682221695477

在OSPF中部署入方向的Filter-Policy,调用ACL 2000

[R2]ospf 1
[R2-ospf-1] filter-policy 2000 import

1682221843867

查看配置Filter-Policy后的OSPF路由表

1682221875196

查看配置Filter-Policy后的IP路由表中的OSPF路由

1682222005316

在IP路由表中路由172.16.2.0/24已经不存在,但是在OSPF路由表中依旧存在。这验证了对于OSPF,Filter-Policy只是限制路由加入IP路由表,不影响本地的LSDB以及LSA的传递。

在R3上查看IP路由表中的OSPF路由

1682222044354

R3的IP路由表中OSPF外部路由172.16.1.0/24、172.16.2.0/24依旧存在

在R3上将OSPF路由引入到IS-IS

在R3上将OSPF路由引入到IS-IS中,通过Route-Policy匹配路由标记,只引入A业务网段的OSPF外部路由。

创建Route-Policy hcip

[R3]route-policy hcip permit node 10
[R3-route-policy] if-match tag 10
[R3-route-policy] quit

1682222232010

在IS-IS中引入OSPF路由,调用Route-Policy hcip只引入A业务网段的OSPF外部路由

[R3]isis 1
[R3-isis-1] import-route ospf 1 level-1 route-policy hcip

1682222248020

查看R3的IS-IS路由表

1682222273164

Level-1的路由重分发表中只有172.16.1.0/24。

]]>