2023年3月

路由交换-作业7-4.2.8-CCNA 7 配置单臂路由-2

当前进度 1.0

更新地址:https://blog.dayi.ink/?p=8

更新地址:https://type.dayiyi.top/index.php/archives/161/

【dayi的大键盘】新的博客:https://blog.dayi.ink ,欢迎来体验新的阅读。

有阅读模式,可能会更好的阅读体验。

更新中修改的内容

在试错过程中发现并修改的内容:

目前没有

0x00 准备文件

  • 好像没有pka文件
  • 下载地址:https://p.dabbit.net/blog/pic_bed/2023/03/2cf6e31ed0fea3a6_202303272123640.7z
  • 如果你感觉不知道要做什么,你可以先看看pdf 或者word,然后不会的地方再对照文章,这样你就会啦!
  • 尽可能的多手打一点指令,加深自己的熟练度哦
  • 本文尝试了分步骤保存文件,在文章末尾可以下载到分步骤分章节的文件哦。

0x01 基础信息

网络拓扑图:

也就是等会要搭建的

image-20230327212701842

地址分配表

设备接口IP 地址子网掩码默认网关
R1G0/0/1.3192.168.3.1255.255.255.0不适用
R1G0/0/1.4192.168.4.1255.255.255.0不适用
R1G0/0/1.8不适用不适用不适用
S1VLAN 3192.168.3.11255.255.255.0192.168.3.1
S2VLAN 3192.168.3.12255.255.255.0192.168.3.1
PC-ANIC192.168.3.3255.255.255.0192.168.3.1
PC-BNIC192.168.4.3255.255.255.0192.168.4.1

VLAN 应该是这个样子

VLANNameInterface Assigned
3ManagementS1: VLAN 3
3ManagementS2: VLAN 3
3ManagementS1: F0/6
4OperationsS2: F0/18
7ParkingLotS1: F0/2-4, F0/7-24, G0/1-2
7ParkingLotS2: F0/2-17, F0/19-24, G0/1-2
8NativeN/A

目标

1 部分:构建网络并配置设备的基本设置

2 部分:创建 VLAN 并分配交换机端口

3 部分:在交换机之间配置一条 802.1Q 干道

4 部分:在路由器上配置 VLAN 间路由

5 部分:验证 VLAN 间路由是否正常工作

背景/场景

现代的交换机会使用虚拟局域网 (VLAN) 提供传统上由路由器在 LAN 配置中提供的网络分段服务。VLAN 解决 了可扩展性、安全性和网络管理问题。通常,利用 VLAN 可更加轻松地设计网络以支持组织的目标。VLAN 之 间的通信需要一台工作在 OSI 模型第 3 层的设备。 VLAN 拓扑中的路由器会提供额外的安全性和流量管理。

VLAN 干道用于跨越多台设备传输 VLAN。干道可以让来自多个 VLAN 的流量通过一条链路,同时使 VLAN 标 识和网段保持完整。有一种特殊类型的 VLAN 间路由方式,称为 “单臂路由器”,这种方式会使用路由器与交换 机之间的干道, 让所有 VLAN 都能向路由器传输流量。

在这个实验中, 您需要在拓扑中的两台交换机上创建多个 VLAN,给这些 VLAN 分配交换机接入端口,验证 VLAN 的工作是否正常,在两台交换机之间、以及 S1 和 R1 之间创建 VLAN 干道,然后配置 VLAN 间路由, 让 不同 VLAN 中的主机可以相互通信, 无论这些主机处于哪个子网之中。

注意:CCNA 动手实验所用的路由器是采用 Cisco IOS XE 16.9.4 (universalk9 镜像)的 Cisco 4221。实验中 所用的交换机是采用 Cisco IOS Release 15.2(2) (lanbasek9 镜像)的 Cisco Catalyst 2960 系列。也可使用其 他路由器、交换机以及其他思科 IOS 版本。根据型号以及 Cisco IOS 版本的不同,可用命令和产生的输出可能 与本实验显示的不一样。请参阅本实验末尾的“路由器接口汇总表”了解正确的接口标识符。

注意:要确保路由器和交换机的配置已清除,并且没有启动配置。如果不确定,请联系教师。

所需资源

. 1 台路由器(采用思科 IOS XE 16.9.4 版通用镜像的思科 4221 或同类路由器)
. 2 台交换机(采用思科 IOS 版本 15.2(2) lanbasek9 镜像的思科 2960 或同类交换机)
. 2 台 PC (采用 Windows 系统且支持终端仿真程序,比如 Tera Term)
. 控制台电缆,用以通过控制台端口配置 Cisco IOS 设备
. 以太网线电缆如拓扑结构所示

0x10 第 1 部分: 建立网络并配置设备的基本设置

在第 1 部分中,您将设置网络拓扑并配置 PC 主机和交换机上的基本设置。

0x11 步骤 1: 建立如拓扑图所示的网络。

按照拓扑图所示连接设备和线缆。
  1. 如何显示端口?

    image-20230327214125776

说实在,我没找到4221,我拿了个4321,应该差不多,看了看固件信息:

isr4300-universalk9.03.16.05.S.155-3.S5-ext.SPA.bin

应该问题也不大

image-20230327213700630

连接示意gif:

连接最后的结果

image-20230327214820145

0x12 步骤 2: 配置路由器的基本设置。

a. 通过控制台连接到路由器并进入特权模式。
b. 进入配置模式。
c. 为路由器分配一个设备名称。
d. 要防止路由器尝试将错误输入的命令视为主机名,则禁用 DNS 查找。
e. 指定 class 作为特权EXEC 加密密码。
f. 指定 cisco 作为控制台密码并启用登录。
g. 指定 cisco 作为 VTY 密码并启用登录。
h. 加密明文密码。
i. 创建一个向访问设备者发出警告的标语:未经授权,禁止访问。
j. 将运行配置保存到启动配置文件中。
k. 设置路由器上的时钟。
注意:使用问号 (?) 可以确定这行这条命令所需参数的正确顺序。

其实这些步骤之前都已经做过啦,这里就直接放命令啦

Would you like to enter the initial configuration dialog? [yes/no]: no

#a进入enable
Router>enable

#b 进入config模式
Router#configure terminal

#更新hostname
Router(config)#hostname R1

#d禁用DNS查找
R1(config)#no ip domain-lookup

#e设置enable密码:
R1(config)#enable secret class

#f设置console密码:
R1(config)#line console 0
R1(config-line)#password cisco
R1(config-line)#login

#g设置VTY密码:
R1(config-line)#line vty 0 4
R1(config-line)#password cisco
R1(config-line)#login
R1(config-line)#exit

#h加密明文密码
R1(config)#service password-encryption

#i警告标语
R1(config)#banner motd $ Unauthorized access is prohibited!$
R1(config)#end

#j配置保存到启动文件
R1#copy running-config startup-config
    Destination filename [startup-config]?
    Building configuration...
    [OK]

#k设置时间
R1#clock set 22:00:00 27 March 2023

0x13 步骤 3: 配置每台交换机的基本设置。

a. 通过控制台连接到交换机并启用特权模式。
b. 进入配置模式。
c. 给交换机分配一个设备名称。
d. 要防止路由器尝试将错误输入的命令视为主机名,则禁用 DNS 查找。
e. 指定 class 作为特权EXEC 加密密码。
f. 指定 cisco 作为控制台密码并启用登录。
g. 指定 cisco 作为 vty 密码并启用登录。
h. 加密明文密码。
i. 创建一个向访问设备者发出警告的标语:未经授权,禁止访问。
j. 设置交换机上的时钟。
注意:使用问号 (?) 可以确定这行这条命令所需参数的正确顺序。
k. 将运行配置复制到启动配置中。

也是,都是之前的作业,直接放命令啦
S1交换机:

#输入命令进入enable模式
Switch>enable

#进入配置模式
Switch#config terminal
    Enter configuration commands, one per line.  End with CNTL/Z.

#更新主机名
Switch(config)#hostname S1

#禁用DNS查找
S1(config)#no ip domain-lookup

#设置enable密码
S1(config)#enable secret class

#配置console密码
S1(config)#line console 0
S1(config-line)#password cisco
S1(config-line)#login

#配置VTY密码
S1(config-line)#line vty 0 15
S1(config-line)#password cisco
S1(config-line)#login

#加密明文密码
S1(config-line)#service password-encryption

#设置登录提示标语
S1(config)#banner motd $ Unauthorized access is prohibited!$
S1(config)#end

#设置时间
S1#clock set 22:05:00 27 March 2023

#将配置保存到启动配置文件中
S1#copy running-config startup-config
    Destination filename [startup-config]? 
    Building configuration...
    [OK]
S1#

S2交换机,同理啦,这里就注释命令啦

Switch>enable
Switch#config terminal
Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#hostname S2
S2(config)#no ip domain-lookup
S2(config)#enable secret class

S2(config)#line console 0
S2(config-line)#password cisco
S2(config-line)#login

S2(config-line)#line vty 0 15
S2(config-line)#password cisco
S2(config-line)#login

S2(config-line)#service password-encryption

S2(config)#banner motd $ Unauthorized access is prohibited!$
S2(config)#end
S2#clock set 22:11:00 27 March 2023
S2#copy running-config startup-config
    Destination filename [startup-config]? 
    Building configuration...
    [OK]
S2#

0x14 步骤 4: 配置 PC 主机。

有关 PC 主机地址信息,请参阅地址分配表。
设备接口IP 地址子网掩码默认网关
PC-ANIC192.168.3.3255.255.255.0192.168.3.1
PC-BNIC192.168.4.3255.255.255.0192.168.4.1

image-20230327221400867

image-20230327221450026

0x20 第 2 部分: 创建 VLAN 并分配交换机端口

在第2 部分中,您需要根据上表中表示的信息,在两台交换机上创建VLAN。然后将 VLAN 分配到相应的接口。show vlan 命令用于验证您的配置设置。在各台交换机上完成下面的任务。

0x21 第 2 部分:步骤 1: 在两台交换机上创建VLAN。

a. 按照上表的内容,在每台交换机上创建并命名VLAN。
b. 使用地址分配表中包含的 IP 地址信息配置管理接口和默认网关。
c. 把交换机上所有未使用的端口都划分到 ParkingLot VLAN,将其配置为access 模式,并从管理上关闭这些端口。
注意: interface range 命令可以帮助我们用尽可能少的命令来完成这个任务。

VLAN 表:

VLANNameInterface Assigned
3ManagementS1: VLAN 3
3ManagementS2: VLAN 3
3ManagementS1: F0/6
4OperationsS2: F0/18
7ParkingLotS1: F0/2-4, F0/7-24, G0/1-2
7ParkingLotS2: F0/2-17, F0/19-24, G0/1-2
8NativeN/A

对于S1交换机

Password: 【cisco】
S1>
S1>enable
Password: 【class】
S1#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    
#创建VLAN
S1(config)#vlan 3
S1(config-vlan)#name Management
S1(config-vlan)#vlan 4
S1(config-vlan)#name Operations
S1(config-vlan)#vlan 7
S1(config-vlan)#name ParkingLot
S1(config-vlan)#vlan 8
S1(config-vlan)#name Native


#配置VLAN3的管理接口IP
S1(config-vlan)#interface vlan 3
S1(config-if)#ip address 192.168.3.11 255.255.255.0
    %LINK-5-CHANGED: Interface Vlan3, changed state to up
S1(config-if)#no shutdown
S1(config-if)#exit

#配置网关
S1(config)#ip default-gateway 192.168.3.1

#把交换机上所有未使用的端口都划分到 ParkingLot VLAN,将其配置为access 模式,并从管理上关闭这些端口。
S1(config)#interface range fa0/2-4,fa0/7-24,g0/1-2
S1(config-if-range)#switchport mode access
S1(config-if-range)#switchport access vlan 7
S1(config-if-range)#shutdown
%LINK-5-CHANGED: Interface FastEthernet0/2, changed state to administratively down
...
%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to administratively down
S1(config-if-range)#end

对于S2交换机

Password: 【cisco】

S2>enable
Password:【class】

S2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
#创建VLAN
S2(config)#vlan 3
S2(config-vlan)#name Management
S2(config-vlan)#vlan 4
S2(config-vlan)#name Operations
S2(config-vlan)#vlan 7
S2(config-vlan)#name ParkingLot
S2(config-vlan)#vlan 8
S2(config-vlan)#name Native

#配置管理IP,网关
S2(config-vlan)#interface vlan 3
    %LINK-5-CHANGED: Interface Vlan3, changed state to up
S2(config-if)#ip address 192.168.3.12 255.255.255.0
S2(config-if)#no shutdown
S2(config-if)#exit
S2(config)# ip default-gateway 192.168.3.1

#关闭不要的接口,并改为access模式
S2(config)#interface range fa0/2-17,fa0/19-24,g0/1 - 2
S2(config-if-range)#switchport mode access
S2(config-if-range)#switchport access vlan 7
S2(config-if-range)#shutdown
%LINK-5-CHANGED: Interface FastEthernet0/2, changed state to administratively down
...
%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to administratively down
S2(config-if-range)#

0x22 第 2 部分:步骤 2: 将 VLAN 分配到正确的交换机接口。

a. 把使用的端口分配给相应的 VLAN(见上面的 VLAN 表)中,并将其配置为静态接入模式。一定要在两台交换机上都执行这项操作
b. 输入 show vlan brief 命令,验证 VLAN 是否已分配给了正确的接口。

VLAN 表:

VLANNameInterface Assigned
3ManagementS1: VLAN 3
3ManagementS2: VLAN 3
3ManagementS1: F0/6
4OperationsS2: F0/18
7ParkingLotS1: F0/2-4,F0/7-24, G0/1-2
7ParkingLotS2: F0/2-17,F0/19-24, G0/1-2
8NativeN/A

先配S1的:

  • VLAN 3 Management 有 F0/6
  • VLAN 7 的接口 ParkingLot 的已经配完啦

也就是只需要配置F0/6的命令

S1#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
S1(config)#interface f0/6
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 3
S1(config-if)#end

然后配S2的:

  • VLAN 4 Operations S2: F0/18
  • VLAN 7 的接口 ParkingLot 的也已经配完啦

配一下接口18就可以啦

S2(config-if-range)#end  这行可能没用

S2#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
S2(config)#interface f0/18
S2(config-if)#switchport mode access
S2(config-if)#switchport access vlan 4
S2(config-if)#end

然后显示两个交换机的vlan信息:

S1#show vlan brief 

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/5
3    Management                       active    Fa0/6
4    Operations                       active    
7    ParkingLot                       active    Fa0/2, Fa0/3, Fa0/4, Fa0/7
                                                Fa0/8, Fa0/9, Fa0/10, Fa0/11
                                                Fa0/12, Fa0/13, Fa0/14, Fa0/15
                                                Fa0/16, Fa0/17, Fa0/18, Fa0/19
                                                Fa0/20, Fa0/21, Fa0/22, Fa0/23
                                                Fa0/24, Gig0/1, Gig0/2
8    Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active

-----------------------------------------------------------------------------------

S2#show vlan brief 
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1
3    Management                       active    
4    Operations                       active    Fa0/18
7    ParkingLot                       active    Fa0/2, Fa0/3, Fa0/4, Fa0/5
                                                Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15, Fa0/16, Fa0/17
                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22
                                                Fa0/23, Fa0/24, Gig0/1, Gig0/2
8    Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active  

放两张图吧

image-20230327224041125

image-20230327224018350

0x30 第 3 部分: 在交换机之间配置 802.1Q 中继

在第 3 部分中,您需要手动把接口 F0/1 配置为一个中继接口。

0x31 第 3 部分:步骤 1: 手动配置中继接口 F0/1。

a. 更改接口 F0/1 上的交换机端口模式以强制中继。确保在两个交换机上执行此操作。
b. 在配置干道时,把两个交换机上的本征 VLAN 设置为 8。当两个接口使用不同的本征VLAN 时,您可能会看到一些临时出现的错误消息。
c. 在配置干道时,只允许VLAN 3、4 和8 可以穿越这条干道。
d. 使用 show interfaces trunk 命令来验证中继端口、本征 VLAN 和干道上允许传输的VLAN。

对于交换机S1:

#a.更改接口 F0/1 上的交换机端口模式以强制中继。
S1#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
S1(config)#interface f0/1
S1(config-if)#switchport mode trunk

#b.在配置干道时,把两个交换机上的本征 VLAN 设置为 8。
S1(config-if)#switchport trunk native vlan 8

#c.只允许VLAN 3、4 和8 可以穿越这条干道。
S1(config-if)#switchport trunk allowed vlan 3,4,8
S1(config-if)#end

对于交换机S2:

S2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
S2(config)#interface f0/1
S2(config-if)#switchport mode trunk
S2(config-if)#switchport trunk native vlan 8
S2(config-if)#switchport trunk allowed vlan 3,4,8
S2(config-if)#end

显示中继信息:

S1#show interfaces trunk
Port        Mode         Encapsulation  Status        Native vlan
Fa0/1       on           802.1q         trunking      8

Port        Vlans allowed on trunk
Fa0/1       3-4,8

Port        Vlans allowed and active in management domain
Fa0/1       3,4,8

Port        Vlans in spanning tree forwarding state and not pruned
Fa0/1       3,4,8


S2#show interfaces trunk
Port        Mode         Encapsulation  Status        Native vlan
Fa0/1       on           802.1q         trunking      8

Port        Vlans allowed on trunk
Fa0/1       3-4,8

Port        Vlans allowed and active in management domain
Fa0/1       3,4,8

Port        Vlans in spanning tree forwarding state and not pruned
Fa0/1       3,4,8

0x32 第 3 部分:步骤 2: 手动配置S1 上的中继接口F0/5。

a. 在 S1 上给 F0/5 配置和 F0/1 相同的干道参数。这是连接路由器的干道。
b. 在 S1 和 S2 上将运行配置保存到启动配置文件中。
c. 我们可以使用 show interfaces trunk 命令来验证中继配置。

S1交换机:

#进入配置模式
S1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.

#进入
S1(config)#int fa0/5
S1(config-if)#sw mode trunk 
S1(config-if)#sw trunk native vlan 8
S1(config-if)#sw trunk allowed vlan 3,4,8


#保存配置
S1#copy running-config startup-config
Destination filename [startup-config]? 
Building configuration...

S2交换机:

#保存配置
S2#copy running-config startup-config
Destination filename [startup-config]? 
Building configuration...
[OK]

验证:

S1#show interfaces trunk
Port        Mode         Encapsulation  Status        Native vlan
Fa0/1       on           802.1q         trunking      8

Port        Vlans allowed on trunk
Fa0/1       3-4,8

Port        Vlans allowed and active in management domain
Fa0/1       3,4,8

Port        Vlans in spanning tree forwarding state and not pruned
Fa0/1       3,4,8

--------------------------------------------
S2#show interfaces trunk
Port        Mode         Encapsulation  Status        Native vlan
Fa0/1       on           802.1q         trunking      8

Port        Vlans allowed on trunk
Fa0/1       3-4,8

Port        Vlans allowed and active in management domain
Fa0/1       3,4,8

Port        Vlans in spanning tree forwarding state and not pruned
Fa0/1       3,4,8

Q.0x32 为什么 F0/5 没有出现在干道列表中?

因为路由器的 G0/0/1接口被管理员性关闭掉了,所以没有连接起来诶,也就没有Trunk


0x40 第 4 部分: 在路由器上配置 VLAN 间路由。

a. 激活路由器上的G0/0/1 接口。
b. 按照 IP 地址分配表给每个 VLAN 配置子接口。所有子接口都要使用802.1Q 封装。确保本征VLAN 对应的子接口没有分配IP 地址。给每个子接口添加一段描述信息。
c. 我们可以使用 show ip interface brief 命令来验证子接口是否已启用。

进入路由器

Password:[cisco]
R1>enable
Password:[class]
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#

a.激活端口:

R1(config)# interface g0/0/1
R1(config-if)# no shutdown
R1(config-if)# exit

b.分配VLAN

#第1个子端口 VLAN 3
R1(config)# interface g0/0/1.3
R1(config-subif)# description Management
R1(config-subif)# encapsulation dot1q 3
R1(config-subif)# ip address 192.168.3.1 255.255.255.0

#第2个子端口 VLAN 4
R1(config-subif)# interface g0/0/1.4
R1(config-subif)# description Operations
R1(config-subif)# encapsulation dot1q 4
R1(config-subif)# ip address 192.168.4.1 255.255.255.0

#第3个子端口 VLAN 8
R1(config-subif)# interface g0/0/1.8
R1(config-subif)# description Native VLAN
R1(config-subif)# encapsulation dot1q 8 native

R1(config-subif)#end

c.验证:

R1#show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol 
GigabitEthernet0/0/0   unassigned      YES unset  administratively down down 
GigabitEthernet0/0/1   unassigned      YES unset  up                    up 
GigabitEthernet0/0/1.3 192.168.3.1     YES manual up                    up 
GigabitEthernet0/0/1.4 192.168.4.1     YES manual up                    up 
GigabitEthernet0/0/1.8 unassigned      YES unset  up                    up 
Vlan1                  unassigned      YES unset  administratively down down
R1#

0x50 第 5 部分: 验证VLAN 间路由是否正常工作

0x51 步骤 1: 从PC-A 发起下列的测试。这些测试都应该成功。

注意:您可能需要禁用PC 上的防火墙,ping 测试才能成功。
a. 从 PC-A 对默认网关执行 ping 操作。
b. 从 PC-A 对 PC-B 执行 ping 操作
c. 从 PC-A 向 S2 发起 Ping 测试。

a. 从 PC-A 对默认网关执行 ping 操作。

ping 192.168.3.1

image-20230327232615575

b. 从 PC-A 对 PC-B 执行 ping 操作

ping 192.168.4.3

结果:

C:\>ping 192.168.4.3
Pinging 192.168.4.3 with 32 bytes of data:=
Request timed out.
Reply from 192.168.4.3: bytes=32 time<1ms TTL=127
Reply from 192.168.4.3: bytes=32 time<1ms TTL=127
Reply from 192.168.4.3: bytes=32 time<1ms TTL=127

image-20230327232758087

c. 从 PC-A 向 S2 发起 Ping 测试。

ping 192.168.3.12
C:\>ping 192.168.3.12

Pinging 192.168.3.12 with 32 bytes of data:

Request timed out.
Reply from 192.168.3.12: bytes=32 time<1ms TTL=255
Reply from 192.168.3.12: bytes=32 time=13ms TTL=255
Reply from 192.168.3.12: bytes=32 time<1ms TTL=255

image-20230327232923910

0x52 步骤 2: 从PC-B 发起下列的测试。

从 PC-B 上的命令提示符,向 PC-A 的地址执行 tracert 命令。
tracert 192.168.3.3
C:\>tracert 192.168.3.3

Tracing route to 192.168.3.3 over a maximum of 30 hops: 

  1   0 ms      0 ms      0 ms      192.168.4.1
  2   0 ms      0 ms      0 ms      192.168.3.3

Trace complete.

image-20230327233048975


Q.0x52 结果中会显示哪些中间IP 地址?

节点1的IP地址是192.168.4.1,表示该节点是本地网络的网关,也是R1的G0/0/1.4
节点2的IP地址是192.168.3.3,表示目标主机的IP地址

0x60 文件下载:

分了步骤啦:

image-20230327233540882

https://p.dabbit.net/blog/pic_bed/2023/03/011537484bc73cf3_202303272334452.zip

路由交换-作业6-4.2.7-CCNA 7 配置单臂路由-1

当前进度 1.01

更新地址: https://blog.dayi.ink/?p=6
更新地址: type.dayiyi.top/index.php/archives/159/

【dayi的大键盘】新的博客:https://blog.dayi.ink ,欢迎来体验新的阅读。

另外,本文的开头:

image-20230402190226168

有阅读模式,可能会更好的阅读体验。

更新中修改的内容

在试错过程中发现并修改的内容:

2023年4月2日19:09:04 Q.0x32.a G0/1 分配到哪个 VLAN?VLAN1 default

0x00 准备文件

  • 4.2.7-packet-tracer---configure-router-on-a-stick-inter-vlan-routing_zh-CN.docx
  • 4.2.7-packet-tracer---configure-router-on-a-stick-inter-vlan-routing_zh-CN.pka
  • 文件下载:https://p.dabbit.net/blog/pic_bed/2023/03/2ed5ab7b999d7d0a_202303271935474.zip
  • 如果你感觉不知道要做什么,你可以先看看pdf 或者word,然后不会的地方再对照文章,这样你就会啦!
  • 尽可能的多手打一点指令,加深自己的熟练度哦

0x01 题目前提

地址分配表

设备接口IPv4 地址子网掩码默认网关
R1G0/0.10172.17.10.1255.255.255.0不适用
R1G0/0.30172.17.30.1255.255.255.0不适用
PC1NIC172.17.10.10255.255.255.0172.17.10.1
PC2NIC172.17.30.10255.255.255.0172.17.30.1

目标

1 部分:为交换机添加 VLAN

2 部分:配置子接口

3 部分:测试使用 VLAN 间路由时的连通性

场景

在这个练习中, 您需要配置 VLAN 和 VLAN 间路由。接下来,您需要启用中继接口,并且验证 VLAN 之间的连 通性。

0x10 第 1 部分:在交换机上添加 VLAN

1 部分: 为交换机添加 VLAN

0x11 第 1 部分:步骤 1 : 在 S1 上创建 VLAN

S1 上创建 VLAN 10 和 VLAN 30。
  1. 打开S1的CLI
  2. 输入命令

    #进入使能模式
    S1>enable 
    #进入配置模式
    S1#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    #创建vlan10
    S1(config)#vlan 10
    #创建vlan30
    S1(config-vlan)#vlan 30
    S1(config-vlan)#end
    S1#

image-20230327194556073

0x12 第 1 部分:步骤 2 : 为端口指定 VLAN

a. 把接口 F0/6 个 F0/11 配置为接入端口并为它们划分 VLAN。

  • 把连接到 PC1 的端口划分 到 VLAN 10。
  • 把连接到 PC3 的端口划分 到 VLAN 30。

b. 输入 show vlan brief 命令来验证 VLAN 的配置。

S1# show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active     Fa0/1, Fa0/2, Fa0/3, Fa0/4
                    Fa0/5, Fa0/7, Fa0/8,Fa0/9
                    Fa0/10, Fa0/12, Fa0/13,Fa0/14
                    Fa0/15, Fa0/16, Fa0/17, Fa0/18
                    Fa0/19, Fa0/20, Fa0/21, Fa0/22
                    Fa0/23, Fa0/24, Gig0/1, Gig0/2
10 VLAN0010 active Fa0/11
30 VLAN0030 active Fa0/6
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
  1. 继续执行:
#切换到端口 f0/11
S1(config)#int f0/11 
#设置模式到access
S1(config-if)#switchport mode access 
S1(config-if)#switchport access vlan 10

#切换到端口 int f0/6
S1(config-if)#int f0/6
S1(config-if)#switchport mode access 
S1(config-if)#switchport access vlan 30
S1(config-if)#end
S1#
  1. 显示当前的配置信息:

    S1#show vlan brief 
    
    VLAN Name                             Status    Ports
    ---- -------------------------------- --------- -------------------------------
    1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                    Fa0/5, Fa0/7, Fa0/8, Fa0/9
                                                    Fa0/10, Fa0/12, Fa0/13, Fa0/14
                                                    Fa0/15, Fa0/16, Fa0/17, Fa0/18
                                                    Fa0/19, Fa0/20, Fa0/21, Fa0/22
                                                    Fa0/23, Fa0/24, Gig0/1, Gig0/2
    10   VLAN0010                         active    Fa0/11
    30   VLAN0030                         active    Fa0/6
    1002 fddi-default                     active    
    1003 token-ring-default               active    
    1004 fddinet-default                  active    
    1005 trnet-default                    active    

0x13 第 1 部分:步骤 3:测试 PC1 和 PC3 之间的连通性。

从 PC1 ping PC3。

image-20230327200127385

问题:

Q.0x13 ping 操作是否成功?你为什么会得到这个结果

PC1 在 VLAN10

PC3 在 VLAN 30

并且PC1 和 PC3在两个不通的网络中

  • PC-1 在 172.17.10.0/24
  • PC-3 在 172.17.30.0/24

在不同的冲突域中。

主要原因:不在一个网络中,并且之间没有正常工作的三层交换机或者路由器来转发包,因此,不可能ping通。

第 2 部分:配置子接口

0x21 第 2 部分:步骤 1:在 R1 上使用 802.1Q 封装配置子接口 。

a. 创建子接口 G0/0.10。

  • 给这个接口的封装类型设置为 802.1Q 并且划分到 VLAN 10 中 。
  • 参考 地址分配表 并且为子接口分配正确的 IP 地址。

    R1(config)# int g0/0.10
    R1(config-subif)# encapsulation dot1Q 10
    R1(config-subif)# ip address 172.17.10.1 255.255.255.0

b. 在 G0/0.30 子接口上重复上述操作。

在R1上的CLI执行:

R1>enable 
R1#conf t
    [Enter configuration commands, one per line.  End with CNTL/Z.]

#这个子端口你可以把它理解为虚拟的,一个接口分出多个虚拟的接口
R1(config)#int g0/0.10
R1(config-subif)#encapsulation dot1Q 10
R1(config-subif)#ip address 172.17.10.1 255.255.255.0

R1(config-subif)#int g0/0.30
R1(config-subif)#encapsulation dot1Q 30
R1(config-subif)#ip address 172.17.30.1 255.255.255.0
R1(config-subif)#exit

#开启端口
R1(config)#int g0/0
R1(config-if)#no shutdown
R1(config-if)#end

0x22 第 2 部分:步骤 2:验证连通性。

a. 使用show ip interface brief命令验证子接口的 配置。两个子接口都关闭。子接口是关联物理接口的虚拟 接口。因此,为了 启用子接口,您必须 启用与它们关联的物理接口。

b. 启用 G0/0 接口。验证子接口现在是否处于活动状态。

诶,这里的b的步骤在上一步已经做过一次啦。

R1#show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol 
GigabitEthernet0/0     unassigned      YES unset  up                    up 
GigabitEthernet0/0.10  172.17.10.1     YES manual up                    up 
GigabitEthernet0/0.30  172.17.30.1     YES manual up                    up 
GigabitEthernet0/1     unassigned      YES unset  administratively down down 
Vlan1                  unassigned      YES unset  administratively down down
R1#

#b步骤
R1(config)#int g0/0
R1(config-if)#no shutdown

第 3 部分:测试 VLAN 间路由的连通性

0x31 第 3 部分:步骤 1:在 PC1 和 PC3 之间执行 Ping。

ping 172.17.30.10

还是失败

image-20230327202839947


Q.0x31 从 PC1 ping PC3。 Ping 仍然会失败。说明原因。

交换机需要配置一个中继端口,才可以让PC1和PC3的通信,这样才可以允许两个VLAN的流量通过并到达路由器滴。

如果没有中继端口,交换机将不能在两个VLAN之间转发流量。


0x32 第 3 部分:步骤 2:启用中继。

0x32.a 第 3 部分:步骤 2.a

步骤 2:启用中继。
打开配置窗口
a.     在 S1上, 输入 show vlan 命令。
S1#show vlan
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/12, Fa0/13, Fa0/14
                                                Fa0/15, Fa0/16, Fa0/17, Fa0/18
                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22
                                                Fa0/23, Fa0/24, Gig0/1, Gig0/2
10   VLAN0010                         active    Fa0/11
30   VLAN0030                         active    Fa0/6
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        0      0
10   enet  100010     1500  -      -      -        -    -        0      0
30   enet  100030     1500  -      -      -        -    -        0      0
1002 fddi  101002     1500  -      -      -        -    -        0      0   
1003 tr    101003     1500  -      -      -        -    -        0      0   
1004 fdnet 101004     1500  -      -      -        ieee -        0      0   
1005 trnet 101005     1500  -      -      -        ibm  -        0      0   

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------

Remote SPAN VLANs
------------------------------------------------------------------------------

Primary Secondary Type              Ports
------- --------- ----------------- ------------------------------------------

Q.0x32.a G0/1 分配到哪个 VLAN?

由:

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/23, Fa0/24, [Gig0/1], Gig0/2
                                                

可知道,分配到了VLAN1,default

0x32b 第 3 部分:步骤 2.b

b. 由于路由器已经配置了多个分配到不同 VLAN 的子接口 ,因此连接到路由器的交换机端口必须配置 为中继。在接口 G0/1 上启用中继。
S1(config)#int g0/1
S1(config-if)#switchport mode trunk
S1(config-if)#end

Q.0x32.b 如何使用show vlan命令来确定 接口为中继端口?

S1#show vlan 

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/12, Fa0/13, Fa0/14
                                                Fa0/15, Fa0/16, Fa0/17, Fa0/18
                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22
                                                Fa0/23, Fa0/24, Gig0/2
10   VLAN0010                         active    Fa0/11
30   VLAN0030                         active    Fa0/6
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        0      0
10   enet  100010     1500  -      -      -        -    -        0      0
30   enet  100030     1500  -      -      -        -    -        0      0
1002 fddi  101002     1500  -      -      -        -    -        0      0   
1003 tr    101003     1500  -      -      -        -    -        0      0   
1004 fdnet 101004     1500  -      -      -        ieee -        0      0   
1005 trnet 101005     1500  -      -      -        ibm  -        0      0   

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------

Remote SPAN VLANs
------------------------------------------------------------------------------

Primary Secondary Type              Ports
------- --------- ----------------- ------------------------------------------

根据输出结果,GigabitEthernet 0/1没有分配到任何VLAN,因为在“Ports”列中没有看到它。

GigabitEthernet 0/2是分配到VLAN 1中的,它在“Ports”列中显示了“Fa0/23, Fa0/24, Gig0/2”。

也可以用show interfaces switchport来查看

Name: Gig0/1
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk encapsulation: dot1q
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk private VLANs: none
Operational private-vlan: none
Trunking VLANs Enabled: All
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL
Protected: false
Unknown unicast blocked: disabled
Unknown multicast blocked: disabled
Appliance trust: none

检查“Administrative Mode”和“Operational Mode”行。如果这两行都显示“trunk”,则该端口是中继端口。

0x32c 第 3 部分:步骤 2.c

c. 输入show interface trunk命令来验证这个 接口已经配置为了一个中继端口。
S1#show interface trunk
Port        Mode         Encapsulation  Status        Native vlan
Gig0/1      on           802.1q         trunking      1

Port        Vlans allowed on trunk
Gig0/1      1-1005

Port        Vlans allowed and active in management domain
Gig0/1      1,10,30

Port        Vlans in spanning tree forwarding state and not pruned
Gig0/1      1,10,30

S1#

可以看到已经变成了trunking

关闭配置窗口

0x33 第 3 部分:步骤 3:测试连通性。

如果配置正确,PC1 和 PC3 应该能够 ping 通它们的默认网关,也能够相互 ping 通。

PC-1

C:\>ping 172.17.30.10
Pinging 172.17.30.10 with 32 bytes of data:
Request timed out.
Reply from 172.17.30.10: bytes=32 time<1ms TTL=127
Reply from 172.17.30.10: bytes=32 time<1ms TTL=127
Reply from 172.17.30.10: bytes=32 time<1ms TTL=127
Ping statistics for 172.17.30.10:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
    
C:\>ping 172.17.30.1
Pinging 172.17.30.1 with 32 bytes of data:
Reply from 172.17.30.1: bytes=32 time<1ms TTL=255
Reply from 172.17.30.1: bytes=32 time<1ms TTL=255
Ping statistics for 172.17.30.1:
    Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
C:\>ping 172.17.10.1
Pinging 172.17.10.1 with 32 bytes of data:
Reply from 172.17.10.1: bytes=32 time<1ms TTL=255

PC-3

C:\>ping 172.17.10.10

Pinging 172.17.10.10 with 32 bytes of data:

Reply from 172.17.10.10: bytes=32 time<1ms TTL=127
Reply from 172.17.10.10: bytes=32 time<1ms TTL=127


C:\>ping 172.17.30.1
Pinging 172.17.30.1 with 32 bytes of data:
Reply from 172.17.30.1: bytes=32 time<1ms TTL=255
Reply from 172.17.30.1: bytes=32 time<1ms TTL=255

Ping statistics for 172.17.30.1:
    Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

image-20230327205827449

问题:

Q.0x33 PC1 和 PC3 会使用哪些地址 作为它们的默认网关地址?

IP地址是它们所连接的路由器的接口IP地址。

如果PC1和PC3都直接连接到路由器,则它们的默认网关IP地址将是路由器接口的IP地址。

也就是子接口作为默认网关

GigabitEthernet0/0.10  172.17.10.1     YES manual up                    up 
GigabitEthernet0/0.30  172.17.30.1     YES manual up                    up 

0x40 文件下载

image-20230327210153707

https://p.dabbit.net/blog/pic_bed/2023/03/53d43c273151f544_202303272102430.zip

路由交换-作业5-配置DTP

当前进度 1.00

更新地址:

博客正在准备装修,临时可能打开速度有点慢

更新中修改的内容

在试错过程中发现并修改的内容:

目前没有

0x00 准备

如果遇到无法登录的问题,下载新版的软件,在登录服务器选择的时候选择:Ch_na

文件下载:

https://p.dabbit.net/blog/pic_bed/2023/03/04ef5b53261668b5_202303232015005.zip

image-20230323201919679

看上去不是很多的样子诶

0x01 题目描述

地址分配表

设备接口IP 地址子网掩码
PC1NIC192.168.10.1255.255.255.0
PC2NIC192.168.20.1255.255.255.0
PC3NIC192.168.30.1255.255.255.0
PC4NIC192.168.30.2255.255.255.0
PC5NIC192.168.20.2255.255.255.0
PC6NIC192.168.10.2255.255.255.0
S1VLAN 99192.168.99.1255.255.255.0
S2VLAN 99192.168.99.2255.255.255.0
S3VLAN 99192.168.99.3255.255.255.0

目标

. 配置静态中继

. 配置并验证 DTP

背景/场景

随着网络中的交换机数量增加,管理 VLAN 和中继所需执行的管理工作可能越来越具有挑战性。为了简化一些 VLAN 和中继的配置, 网络设备之间的中继协商由动态中继协议 (DTP) 进行管理,并在 Catalyst 2960 和 Catalyst 3560 交换机上自动启用。

在此练习中,您将配置交换机之间的中继链路。您需要把端口划分到 VLAN 当中, 然后验证同一个 VLAN 当中 各个主机之间的连通性。您需要配置交换机之间的干道链路,并且把 VLAN 999 配置为本征 VLAN。

0x10 指导

验证交换机上配置的 VLAN。

0x10ab 指导.ab

a. 在 S1 上,进入特权 EXEC 模式,并且输入show vlan brief 命令来验证当前的一些 VLAN。

打开配置窗口

S1# show vlan brief
#输出
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7,Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/14, Fa0/15,Fa0/16
Fa0/17, Fa0/18, Fa0/19,Fa0/20
Fa0/21, Fa0/22, Fa0/23,Fa0/24
Gig0/1, Gig0/2
99 Management active
999 Native active
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active

b. 在 S2 和 S3 上重复步骤 1a。

S1交换机:

image-20230323202735849

执行:

S1>enable
S1#show vlan brief 

三个交换机都这样执行:

S2>enable
S2#show vlan brief

S3>enable
S3#show vlan brief 

[Tab可以补全命令]
sh[按下tab] =show
show vl[按下tab] = show vlan
show vlan bri[按下tab] = show vlan brief

输出内容:

S1#show vlan brief 

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/6, Fa0/7, Fa0/8
                                                Fa0/9, Fa0/10, Fa0/11, Fa0/12
                                                Fa0/13, Fa0/14, Fa0/15, Fa0/16
                                                Fa0/17, Fa0/18, Fa0/19, Fa0/20
                                                Fa0/21, Fa0/22, Fa0/23, Fa0/24
                                                Gig0/1, Gig0/2
99   Management                       active    
999  Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    


S2>enable
S2#show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/6, Fa0/7, Fa0/8
                                                Fa0/9, Fa0/10, Fa0/11, Fa0/12
                                                Fa0/13, Fa0/14, Fa0/15, Fa0/16
                                                Fa0/17, Fa0/18, Fa0/19, Fa0/20
                                                Fa0/21, Fa0/22, Fa0/23, Fa0/24
                                                Gig0/1, Gig0/2
99   Management                       active    
999  Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    



S3>enable
S3#show vlan brief
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/6, Fa0/7, Fa0/8
                                                Fa0/9, Fa0/10, Fa0/11, Fa0/12
                                                Fa0/13, Fa0/14, Fa0/15, Fa0/16
                                                Fa0/17, Fa0/18, Fa0/19, Fa0/20
                                                Fa0/21, Fa0/22, Fa0/23, Fa0/24
                                                Gig0/1, Gig0/2
99   Management                       active    
999  Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    

Q.0x10.b 交换机上配置了哪些 VLAN?

该交换机上配置了以下 VLAN:

  • VLAN 1(默认 VLAN):所有端口都在此 VLAN 中,且该 VLAN 处于激活状态。
  • VLAN 99:名称为 Management 的 VLAN,处于激活状态。
  • VLAN 999:Native VLAN,处于激活状态。
  • VLAN 1002:fddi-default VLAN,处于激活状态。
  • VLAN 1003:token-ring-default VLAN,处于激活状态。
  • VLAN 1004:fddinet-default VLAN,处于激活状态。
  • VLAN 1005:trnet-default VLAN,处于激活状态。

0x20 第 2 部分: 在 S2S3 上创建其他 VLAN

0x20abc

a. 在 S2 上, 创建 VLAN 10,并且把它命名为 Red。

S2(config)# vlan 10

S2(config-vlan)# name Red

b. 根据下表创建 VLAN 20 和 30。

VLAN 编号VLAN 名称
10Red
20Blue
30Yellow

c. 验证新添加的 VLAN 。在特权 EXEC 模式下输入 show vlan brief

在S2上输入以下命令:

S2>enable
S2#conf t

#a部分
S2(config)#vlan 10
S2(config-vlan)#name Red

#b部分
#这里可以直接输入vlan 20  从config-vlan 切换到config-vlan
S2(config-vlan)#vlan 20
S2(config-vlan)#name Blue

S2(config-vlan)#vlan 30
S2(config-vlan)#name Yellow

#c部分
S2(config-vlan)#end
S2#show vlan  brief 

c部分输出:


VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/6, Fa0/7, Fa0/8
                                                Fa0/9, Fa0/10, Fa0/11, Fa0/12
                                                Fa0/13, Fa0/14, Fa0/15, Fa0/16
                                                Fa0/17, Fa0/18, Fa0/19, Fa0/20
                                                Fa0/21, Fa0/22, Fa0/23, Fa0/24
                                                Gig0/1, Gig0/2
10   Red                              active    
20   Blue                             active    
30   Yellow                           active    
99   Management                       active    
999  Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active   

Q.0x20c 除了默认 VLAN 之外, S2 上还配置了哪些 VLAN?

VLAN 10   Red                             
VLAN 20   Blue                               
VLAN 30   Yellow                          
VLAN 99   Management                          
VLAN 999  Native                           

0x20d

d. 在 S3 上重复前面的步骤,创建其他 VLAN。

在S3上重复上面的步骤

S3>enable
S3#conf t
    [Enter configuration commands, one per line.  End with CNTL/Z.]
S3(config)#vlan 10
S3(config-vlan)#name Red

S3(config-vlan)#vlan 20
S3(config-vlan)#name Blue

S3(config-vlan)#vlan 30
S3(config-vlan)#name Yellow

S3(config-vlan)#end
S3#

0x30 第 3 部分:为端口分配 VLAN

使用 switchport mode access 命令对每条接入链路设置接入模式。使用 switchport access vlan vlan-id 命 令把一个 VLAN 分配给一个接入端口。

端口分配网络
S2 F0/1 – 8 S3 F0/1 – 8VLAN 10 (Red)192.168.10.0 /24
S2 F0/9 – 16 S3 F0/9 – 16VLAN 20 (Blue)192.168.20.0 /24
S2 F0/17 – 24 S3 F0/17 – 24VLAN 30 (Yellow)192.168.30.0 /24

0x30a 第三部分.a

a. 使用上表中的分配,将 VLAN 分配给 S2 上的端口。

S2(config-if)# interface range f0/1 - 8    
S2(config-if-range)# switchport mode access
S2(config-if-range)# switchport access vlan 10
S2(config-if-range)# interface range f0/9 -16
S2(config-if-range)# switchport mode access
S2(config-if-range)# switchport access vlan 20
S2(config-if-range)# interface range f0/17 - 24
S2(config-if-range)# switchport mode access
S2(config-if-range)# switchport access vlan 30

在S2交换机上,执行这些语句就可以啦:

#步骤a
S2#conf t
    [Enter configuration commands, one per line.  End with CNTL/Z.]
S2(config)#

S2(config-if)# interface range f0/1 - 8    
S2(config-if-range)# switchport mode access
S2(config-if-range)# switchport access vlan 10
S2(config-if-range)# interface range f0/9 - 16
S2(config-if-range)# switchport mode access
S2(config-if-range)# switchport access vlan 20
S2(config-if-range)# interface range f0/17 - 24
S2(config-if-range)# switchport mode access
S2(config-if-range)# switchport access vlan 30

0x30b 第三部分.b

b. 按照上表的分配方式, 把 S3 上面的端口划分到 VLAN 当中。

​ 在把端口划分到 VLAN 中之后,尝试从 PC1PC6 执行 ping 操作。

在S3交换机上执行一样的命令:

#步骤b

S3#conf t
    [Enter configuration commands, one per line.  End with CNTL/Z.]
S3(config)# interface range f0/1 - 8   
S3(config-if-range)#switchport mode access
S3(config-if-range)#switchport access vlan 10
S3(config-if-range)#interface range f0/9 - 16
S3(config-if-range)#switchport mode access
S3(config-if-range)#switchport access vlan 20
S3(config-if-range)#interface range f0/17 - 24
S3(config-if-range)#switchport mode access
S3(config-if-range)#switchport access vlan 30
S3(config-if-range)#end

尝试ping

这里的PC1-6好像都已经配好IP啦,只需要执行就可以啦。

  • PC-1 : 192.168.10.1
  • PC-6 : 192.168.10.2

PC1 CMD执行:

ping 192.168.10.2

Q.0x30b ping 操作是否成功?说明原因。

失败,因为

  • 交换机之间的端口在 VLAN 1
  • PC1、PC6 的端口在VLAN 10

要让它们相互通信,需要进行跨 VLAN 通信。

0x40 第 4 部分: 在 S1S2S3 上配置中继。

动态中继协议 (DTP) 管理思科交换机之间的中继链路。目前,所有交换机端口都处于默认中继协商模式, 即 “dynamic auto (动态自动) ”模式。在此步骤中,您将为交换机 S1 与 S2 之间的链路将中继协商模式改为“动态 期望”模式。交换机 S1 与 S3 之间的链路需要为静态中继模式。在此拓扑中, 使用 VLAN 999 作为本征 VLAN。

0x40a 第4部分.a

在交换机 S1 上, 在接口 GigabitEthernet 0/1 上把中继协商模式配置为 dynamic desirable 。S1 的配置如下 所示。

S1(config)# interface g0/1
S1(config-if)# switchport mode dynamic desirable
S1>enable
S1#conf t
    [Enter configuration commands, one per line.  End with CNTL/Z.]
S1(config)#interface g0/1
S1(config-if)#switchport mode dynamic desirable

S1(config-if)#
    [%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up]

    [%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to down]

    [%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up]

    [%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan99, changed state to up]

S1(config-if)#end
S1#

Q.0x40a S1 与 S2 之间中继协商的结果是什么?

交换机 S1 和 S2 之间,

  • S1 接口 GigabitEthernet 0/1 的中继协商模式被配置为 dynamic desirable
  • S2 接口 GigabitEthernet 0/1 的中继协商模式默认为 dynamic auto
  • S2 接口 GigabitEthernet 0/1 会自动变为动态可接受模式 dynamic desirable
  • S1 和 S2 之间的链路将使用动态中继协议 (DTP) 进行中继。

S1 与 S2 建立了中继链路

0x40b 第4部分.b

b. 在交换机 S2 上, 输入 show interfaces trunk 命令验证中继是否已经协商。 GigabitEthernet 0/1 接口应出 现在输出信息当中。
S2>enable
S2#show interfaces trunk
Port        Mode         Encapsulation  Status        Native vlan
Gig0/1      auto         n-802.1q       trunking      1

Port        Vlans allowed on trunk
Gig0/1      1-1005

Port        Vlans allowed and active in management domain
Gig0/1      1,10,20,30,99,999

Port        Vlans in spanning tree forwarding state and not pruned
Gig0/1      1,10,20,30,99,999

S2#

Q.0x40b 这个端口的模式和状态是什么

  • 模式为:auto
  • 状态为:turunking

已经建立连接

S2 的 GigabitEthernet 0/1 接口处于 trunking

支持的 VLAN ID 为 1-1005

激活的 VLAN ID 包括 1,10,20,30,99,999。

S1 和 S2 之间已经成功协商为 trunk 模式,允许传送的 VLAN 包括了本拓扑中所有的 VLAN。

0x40cde 第4部分.cde

c. 对于 S1 和 S3 之间的中继链路,需要在 S1 上把接口 GigabitEthernet 0/2 配置为静态中继。此外,需要在 S1 的 G0/2 接口上禁用 DTP 协商。

S1(config)# interface g0/2
S1(config-if)# switchport mode trunk
S1(config-if)# switchport nonegotiate

d. 使用 show dtp 命令验证 DTP 的状态

S1# show dtp
Global DTP information
Sending DTP Hello packets every 30 seconds
Dynamic Trunk timeout is 300 seconds
1 interfaces using DTP

e. 使用 show interfaces trunk 命令验证所有交换机是否均已启用中继。

S1# show interfaces trunk
Port Mode Encapsulation Status Native vlan
Gig0/1 desirable n-802.1q trunking 1
Gig0/2 on 802.1q trunking 1

Port Vlans allowed on trunk
Gig0/1 1-1005
Gig0/2 1-1005

Port Vlans allowed and active in management domain
Gig0/1 1,99,999
Gig0/2 1,99,999

Port Vlans in spanning tree forwarding state and not pruned
Gig0/1 1,99,999
Gig0/2 1,99,999
#c 对于 S1 和 S3 之间的中继链路,需要在 S1 上把接口 GigabitEthernet 0/2 配置为静态中继。此外,需要在 S1 的 G0/2 接口上禁用 DTP 协商。

S1>enable
S1#conf t
    [Enter configuration commands, one per line.  End with CNTL/Z.]
S1(config)#interface g0/2
S1(config-if)#switchport mode trunk 
S1(config-if)#switchport nonegotiate 

S1(config-if)#end

#d  使用 **show** **dtp** 命令验证 DTP 的状态
S1#show dtp
Global DTP information
    Sending DTP Hello packets every 30 seconds
    Dynamic Trunk timeout is 300 seconds
    1 interfaces using DTP
    

    
    
#e 使用 **show** **interfaces** **trunk** 命令验证所有交换机是否均已启用中继。
S1#show interfaces trunk
Port        Mode         Encapsulation  Status        Native vlan
Gig0/1      desirable    n-802.1q       trunking      1
Gig0/2      on           802.1q         trunking      1

Port        Vlans allowed on trunk
Gig0/1      1-1005
Gig0/2      1-1005

Port        Vlans allowed and active in management domain
Gig0/1      1,99,999
Gig0/2      1,99,999

Port        Vlans in spanning tree forwarding state and not pruned
Gig0/1      1,99,999
Gig0/2      1,99,999

来自ciscoPDF:

switchport nonegotiate: 严格的说,这不算是种接口模式,它的作用只 是阻止交换机接口发出DTP 数据包,它必须与switchport mode trunk 或者 switchport mode access 一起使用。

来自cisco社区:

当链路的一端设置为配置为trunk加nonegotiate(switchport mode trunk 加switchport nonegotiate ),另外一端设置为dynamic auto或者dynamic desirable时,配置为trunk的一端成为TRUNK模式,而另外一端最终处于Access模式(因为协商失败)。这是一种错误的配置方法。
switchport nonegotiate命令不能单独使用,一定与switchport mode trunk命令配合使用。两者合起来的含义为:本端口工作模式一定是TRUNK并且不协商。因此一端如此配置后,要求对端必须也配置成trunk模式(switchport mode trunk)。

来自cdsn:

DTP
• 它的前身是DISL — Dynamic ISL
• 它们都是思科私有的协议,用于协商Trunk链路(类型为0X2004的组播
MAC:01-00-0C-CC-CC-CC,每间隔一秒发送一次,形成干道之后间隔30秒发送)
• Trunk
– ON 默认发送DTP( switchport mode trunk )
– OFF 用命令“ switchport nonegotiate ”关掉DTP
• Dynamic
– Auto 默认不发送DTP,但是收到DTP后可以回复,被动协商[switchport mode dynamic auto]
– Desirable 默认主动发送DTP,主动协商[switchport mode dynamic desirable]
• Access 不发送DTP,不协商Trunk

Sw1(config-if)#switchport mode dynamic desirable(默认模式)
Sw1(config-if)#switchport mode dynamic auto (被动模式)
Sw1(config-if)#switchport nonegotiate (nonegotiate只能和trunk联用)

原文链接:https://blog.csdn.net/qq_40170955/article/details/107552478

Q.0x40e 目前这些中继的本征 VLAN 是什么?

本征VLAN 也叫 Native VLAN,是在一个 802.1Q 标记帧中没有被打上 VLAN 标记的默认 VLAN。

交换机之间进行 VLAN 中继时,如果两端的本征 VLAN 不同,可能会出现一些安全问题。

在中继链路上设置尽可能相同的本征 VLAN。

Q.0x40e 答案:

  • S1 与 S2 之间的中继本征 VLAN 为 VLAN 1。
  • S1 与 S3 之间的中继本征 VLAN 为 VLAN 1。

这些中继的本征 VLAN 都为 VLAN 1

0x40f 第4部分.f

f. 将 VLAN 999 配置为 S1 上的中继链路的本征 VLAN。

S1(config)# interface range g0/1-2
S1(config-if-range)# switchport trunk native vlan 999

switchport nonegotiate 命令用于禁止交换机接口之间的动态协议交换(DTP)。当两个接口都配置为 trunk 模式时,默认情况下它们会通过 DTP 协商确认是否需要建立一个 trunk 连接。使用 switchport nonegotiate 命令可以禁用 DTP 协商,从而强制接口成为 trunk 连接

S1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
S1(config)#interface range g0/1-2
S1(config-if-range)#switchport trunk native vlan 999

信息:
%SPANTREE-2-RECV_PVID_ERR: Received BPDU with inconsistent peer vlan id 1 on GigabitEthernet0/1 VLAN999.

%SPANTREE-2-BLOCK_PVID_LOCAL: Blocking GigabitEthernet0/1 on VLAN0999. Inconsistent local vlan.

%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on GigabitEthernet0/1 (999), with S2 GigabitEthernet0/1 (1).

Q. 0x40f 您在 S1 上收到什么消息?您将如何纠正?

信息:
%SPANTREE-2-RECV_PVID_ERR: Received BPDU with inconsistent peer vlan id 1 on GigabitEthernet0/1 VLAN999.

%SPANTREE-2-BLOCK_PVID_LOCAL: Blocking GigabitEthernet0/1 on VLAN0999. Inconsistent local vlan.

%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on GigabitEthernet0/1 (999), with S2 GigabitEthernet0/1 (1).

本征(native) VLAN 不匹配,需要在S2 S3上将VLAN999 配置为默认的VLAN。

0x40.ghi

g. 在 S2 和 S3 上,将 VLAN 999 配置为本征 VLAN。

S2执行:

S2>enable
S2#conf t
    [Enter configuration commands, one per line.  End with CNTL/Z.]

S2(config)#interface g0/1

    可能弹出的报错,正常:[%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on GigabitEthernet0/1 (1), with S1 GigabitEthernet0/1 (999).]

S2(config-if)#switchport mode trunk
S2(config-if)#switchport trunk native vlan 999

S3执行:

S3>enable
S3#conf t
S3(config)#interface g0/2
S3(config-if)#switchport mode trunk
S3(config-if)#switchport trunk native vlan 999
S3(config-if)#end

输入的过程可能会弹出报错,正常现象。

image-20230323222143259

0x40.h 第4部分.h

h. 验证是否已在所有交换机上成功配置中继。您应该能够使用 SVI 上配置的 IP 地址从拓扑中的其他交换机对 一台交换机执行 ping 操作。

别忘了这个:

设备接口IP 地址
S1VLAN 99192.168.99.1
S2VLAN 99192.168.99.2
S23VLAN 99192.168.99.3

在S1上执行:

#
S1>ping 192.168.99.3

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.99.3, timeout is 2 seconds:
..!!!
Success rate is 60 percent (3/5), round-trip min/avg/max = 0/0/0 ms


S1>ping 192.168.99.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.99.2, timeout is 2 seconds:
..!!!
Success rate is 60 percent (3/5), round-trip min/avg/max = 0/0/0 ms

0x40.i 第4部分.i

i. 尝试从 PC1 Ping PC6。

在PC1上的CMD里面:

失败了:

C:\>ping 192.168.10.2

Pinging 192.168.10.2 with 32 bytes of data:

Request timed out.

Q.0x40.i Ping 是否不成功?(提示: 在这 3 台交换机上查看命令‘show vlan brief’的输出信息。与所有交换机上使 用‘show interface trunk’命令的输出信息进行比较)

show vlan brief

S1#show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/6, Fa0/7, Fa0/8
                                                Fa0/9, Fa0/10, Fa0/11, Fa0/12
                                                Fa0/13, Fa0/14, Fa0/15, Fa0/16
                                                Fa0/17, Fa0/18, Fa0/19, Fa0/20
                                                Fa0/21, Fa0/22, Fa0/23, Fa0/24
99   Management                       active    
999  Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    


S2# show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Gig0/2
10   Red                              active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/6, Fa0/7, Fa0/8
20   Blue                             active    Fa0/9, Fa0/10, Fa0/11, Fa0/12
                                                Fa0/13, Fa0/14, Fa0/15, Fa0/16
30   Yellow                           active    Fa0/17, Fa0/18, Fa0/19, Fa0/20
                                                Fa0/21, Fa0/22, Fa0/23, Fa0/24
99   Management                       active    
999  Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    


S3#show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Gig0/1
10   Red                              active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/6, Fa0/7, Fa0/8
20   Blue                             active    Fa0/9, Fa0/10, Fa0/11, Fa0/12
                                                Fa0/13, Fa0/14, Fa0/15, Fa0/16
30   Yellow                           active    Fa0/17, Fa0/18, Fa0/19, Fa0/20
                                                Fa0/21, Fa0/22, Fa0/23, Fa0/24
99   Management                       active    
999  Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active   

发现S1 的VLAN设置不正确。

0x40.j 第4部分.j

j. 如果需要,对配置进行更正。

在S1上执行:

S1#conf t
S1(config)#vlan 10
S1(config-vlan)#name Red
S1(config-vlan)#vlan 20
S1(config-vlan)#name Blue
S1(config-vlan)#vlan 30
S1(config-vlan)#name Yellow

再次测试

ping 192.168.10.2

通啦:

image-20230323223359384

0x50 第 5 部分: 重新在 S3 上配置干道。

a. 在 S3 上输入‘show interface trunk’命令。
S3#show interface trunk
Port        Mode         Encapsulation  Status        Native vlan
Gig0/2      on           802.1q         trunking      999

Port        Vlans allowed on trunk
Gig0/2      1-1005

Port        Vlans allowed and active in management domain
Gig0/2      1,10,20,30,99,999

Port        Vlans in spanning tree forwarding state and not pruned
Gig0/2      1,10,20,30,99,999

Q.0x50.a G0/2 上的模式和封装是什么?

  • 接口Gig0/2 模式:on
  • 此端口配置为静态访问或静态特定于 VLAN 的接口。
  • 接口Gig0/2 封装:802.1q
  • 使用IEEE 802.1Q VLAN封装格式在该端口上传输VLAN信息。

0x50b

b. 配置 G0/2 来匹配 S1 上的 G0/2
S3(config)#interface g0/2
S3(config-if)#switchport nonegotiate

Q.0x50.b 更改之后, G0/2 的模式和封装是什么?

  • 接口Gig0/2 模式:on
  • 端口配置为静态访问或静态特定于 VLAN 的接口。
  • 接口Gig0/2 封装:802.1q
  • 使用IEEE 802.1Q VLAN封装格式在该端口上传输VLAN信息。

0x50c

c. 在交换机 S3 上输入命令‘show interface G0/2 switchport’。

Q.0x50c 交换机显示的‘Negotiation of Trunking’状态是什么?

S3#
%SYS-5-CONFIG_I: Configured from console by console
show interface G0/2 switchpor
Name: Gig0/2
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q


Negotiation of Trunking: Off


Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 999 (Native)
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk encapsulation: dot1q
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk private VLANs: none
Operational private-vlan: none
Trunking VLANs Enabled: All
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL
Protected: false
Unknown unicast blocked: disabled
Unknown multicast blocked: disabled
Appliance trust: none

Negotiation of Trunking: Off

OFF

0x60 第 6 部分: 验证端到端连接。

a. 从 PC1 ping PC6。

PC-1执行:

ping 192.168.10.2

image-20230323224145339

b. 从 PC2 ping PC5。

PC-2执行

ping 192.168.20.2

image-20230323224226673

c. 从 PC3 ping PC4。

PC-3执行

ping 192.168.30.2

image-20230323224244748

都是通的。

0x70 文件下载

2小时23分

image-20230323224322280

image-20230323224347690

链接:

https://p.dabbit.net/blog/pic_bed/2023/03/35d4f8994ee3fd13_202303232244150.zip

路由交换-作业4-3.4.6_配置 VLAN 和中继

当前进度 1.001

更新地址:https://type.dayiyi.top/index.php/archives/150/

更新中修改的内容

在试错过程中发现并修改的内容:

目前没有
这个内容有点多
发现问题请跟咱说,我会第一时间修改,蟹蟹!

2023年3月26日16:51:45 0x012bcdefgh 章节 S2 hostname 

0x00 准备文件

https://p.dabbit.net/blog/pic_bed/2023/03/6e76c3ce1d3a5d94_202303201950655.7z

0x1 第一部分

连接的时候注意这个接口不要接错了哦

PC-A <-> F0/6 (S1)
(S1) F0/1 <-> F0/1 (S2)
(S2) F0/18 <-> PC-2

image-20230320163025131

image-20230320162826668

设备接口IP 地址子网掩码默认网关
S1VLAN 1192.168.1.11255.255.255.0不适用
S2VLAN 1192.168.1.12255.255.255.0不适用
PC-ANIC192.168.10.3255.255.255.0192.168.10.1
PC-BNIC192.168.10.4255.255.255.0192.168.10.1

0x11 第一部分.步骤1

  • a. 单击并将交换机 S1 和 S2 都拖拽到 机架上。
    注意:由于交换机端口全部关闭,本练习一开始的完成度为 37%。将交换机安装在机架中时,端口将自动激活。大约一分钟后,分数将下降至 1%。在本练习的稍后阶段,您将关闭未使用的端口。
  • b. 单击 PC-A 和 PC-B 并将其拖拽到 表(这里表应该是机翻table桌子) 中,然后使用电源按钮将其打开。
  • c. 如拓扑所示,通过连接 铜直通 电缆来提供网络连接。
  • d. 将 控制台电缆 从设备 PC-A 连接到 S1 ,然后从设备 PC-B 连接到 S2。

连4根线,然后到后面去连console线,注意接口呀呀呀,不要连错了。image-20230320163511639

console线:

image-20230320163713401

最后大概这个样子:

0x12 第一部分.步骤2

步骤 2: 配置每台交换机的基本设置。

要怎么分段才好看呀。

0x012a. 在每台 PC 的 桌面选项卡 中,使用 终端 控制到每台交换机并启用特权 EXEC 模式

记得先开机呀

打开配置窗口

0x012bcdefgh 配置命令

b. 进入配置模式
c. 为每台交换机配置一个设备名称。
d. 指定 class 作为特权 EXEC 加密密码。
e. 指定 cisco 作为控制台密码并启用登录。
f. 指定 cisco 作为 vty 密码并启用登录。
g. 加密明文密码。
h. 创建一个向访问设备者发出警告的标语:未经授权,禁止访问。 (中文输入失败,翻译一遍要。)
i. 为交换机上的 VLAN 1 配置地址分配表中列出的 IP 地址。注意:VLAN 1 地址没有评分,因为您将在本练习稍后将其删除。但是,您需要 VLAN 1 来测试本部分后面的连通性。
j. 关闭所有不使用的接口。
k. 设置交换机上的时钟。注意:Packet Tracer 不会对时钟设置进行评分。
l. 将运行配置保存到启动配置文件中。

PC-1 连接的交换机是S1,也就是你打开黑色的窗口之后是连接S1的终端。

PC-2 连接的交换机是S2,也就是你打开黑色的窗口之后是连接S2的终端。

注意区分呀。

PC-1 连接的交换机:S1

#b.进入配置模式
Switch>enable
Switch#conf t

#c.为每台交换机配置一个设备名称。
Switch(config)#hostname S1  #交换机S1

#d.设置class作为使能密码
S1(config)#enable secret class  

#e.指定 cisco 作为控制台密码并启用登录。
S1(config)#line console 0
S1(config-line)#password cisco
S1(config-line)#login
S1(config-line)#exit

#f.指定 cisco 作为 vty 密码并启用登录。
S1(config)#line vty 0 4
S1(config-line)#password cisco
S1(config-line)#login
S1(config-line)#exit

#g.加密明文密码。
S1(config)#service password-encryption

#h.创建一个向访问设备者发出警告的标语:未经授权,禁止访问。(中文好像写不进去,就英文就行)
S1(config)#banner motd $Unauthorized access is prohibited.$  

#i 为交换机上的 VLAN 1 配置地址分配表中列出的 IP 地址
S1(config)#interface vlan 1
S1(config-if)#ip address 192.168.1.11 255.255.255.0
S1(config-if)#no shutdown
S1(config-if)# 回车后可能会提示端口重启之类的
S1(config-if)#exit

#j.关闭所有不使用的接口。
S1(config)#interface range f0/2-5, f0/7-24, g0/1-2
S1(config-if-range)#shutdown
S1(config-if-range)# 回车后可能会提示端口重启之类的
S1(config-if-range)#exit
S1(config)#exit

#k.设置交换机上的时钟。 设置为:2023年3月20日 16:46:00
S1#clock set 16:46:00 20 March 2023

#l.将运行配置保存到启动配置文件中。
S1#copy running-config startup-config

Destination filename [startup-config]? [回车]
Building configuration...
[OK]

同理

PC-2 连接的交换机:S2

#b.进入配置模式
Switch>enable
Switch#conf t

#c.为每台交换机配置一个设备名称。
Switch(config)#hostname S2  #交换机S2

#d.设置class作为使能密码
S2(config)#enable secret class

#e.指定 cisco 作为控制台密码并启用登录。
S2(config)#line console 0
S2(config-line)#password cisco
S2(config-line)#login
S2(config-line)#exit
S2(config)#

#f.指定 cisco 作为 vty 密码并启用登录。
S2(config)#line vty 0 4
S2(config-line)#password cisco
S2(config-line)#login
S2(config-line)#exit

#g.加密明文密码。
S2(config)#service password-encryption

#h.创建一个向访问设备者发出警告的标语:未经授权,禁止访问。(中文好像写不进去,就英文就行)
S2(config)#banner motd $Unauthorized access is prohibited.$  

#i 为交换机上的 VLAN 1 配置地址分配表中列出的 IP 地址
S2(config)#interface vlan 1
S2(config-if)#ip address 192.168.1.12 255.255.255.0
S2(config-if)#no shutdown 
S2(config-if)# 回车后可能会提示端口重启之类的
S2(config-if)#exit

#j.关闭所有不使用的接口。
S2(config-if)#interface range f0/2-17, f0/19-24, g0/1-2
S2(config-if-range)#shutdown
S2(config-if-range)# 回车后可能会提示端口重启之类的
S2(config-if-range)#exit
S2(config)#exit

#k.设置交换机上的时钟。 设置为:2023年3月20日 16:53:00
S2#clock set 16:53:00 20 March 2023

#l.将运行配置保存到启动配置文件中。
S2#copy running-config startup-config

Destination filename [startup-config]? [回车]
Building configuration...
[OK]

大概完成之后百分之32左右

image-20230320165427443

关闭配置窗口

0x13 第一部分.步骤3

步骤 3: 配置 PC 主机。
在每台 PC 的 桌面选项卡中,单击 IP 配置,然后输入地址表中显示的地址信息。

如图啦,老步骤。

image-20230320170000280

0x14 第一部分.步骤 4: 测试连通性

通过尝试在每个连接缆线的设备之间 ping 来测试网络连通性。


Q.1.4.1 PC-A 是否能 ping 通 PC-B?

如何打开CMD?

image-20230320170557913

可以

image-20230320170249786

Q.1.4.2 PC-A 是否能 ping 通 S1?

否,不可以。

image-20230320170312865

S1 和 S2 设备的 IP 地址都在 192.168.1.0/24 子网中。

PC-A 和 PC-B 设备的 IP 地址都在 192.168.10.0/24 子网中。

PC-A 和 PC-B 需要通过默认网关 192.168.10.1 来访问 S1 和 S2。

Q.1.4.3 PC-B 是否能 ping 通 S2?

否,不可以。

image-20230320170412918

S1 和 S2 设备的 IP 地址都在 192.168.1.0/24 子网中。

PC-A 和 PC-B 设备的 IP 地址都在 192.168.10.0/24 子网中。

PC-A 和 PC-B 需要通过默认网关 192.168.10.1 来访问 S1 和 S2。

Q.1.4.4 S1是否能 ping 通 S2?

连接交换机S1,在普通模式下ping即可。

可以。

image-20230320170521796


0x2 第二部分 创建 VLAN 并分配交换机端口

在第 2 部分, 您将在两台交换机上创建 ManagementOperationsParking_LotNative VLAN。然后将 VLAN 分配到相应的接口。 show vlan 命令用于验证您的配置设置。

0x21 第二部分.步骤 1 : 在交换机上创建 VLAN

在每台 PC 的 桌面选项卡中,使用终端继续配置两台网络交换机。

这些直接告诉啦,直接执行就可以滴。

如果提示登录密码:cisco(登录密码) 和class(enable模式密码)

从enable进入配置模式输入conf t

image-20230320172408175

0x021ab 第二部分.步骤1.ab

a. 在 S1 上创建 VLAN。

S1(config)# vlan 10
S1(config-vlan)# name Operations
S1(config-vlan)# vlan 20
S1(config-vlan)# name Parking_Lot
S1(config-vlan)# vlan 99
S1(config-vlan)# name Management
S1(config-vlan)# vlan 1000
S1(config-vlan)# name Native
S1(config-vlan)# end

image-20230320173437077

b. 在 S2 上创建相同的 VLAN。

image-20230320173635500

S2(config)#vlan 10
S2(config-vlan)#name Operations
S2(config-vlan)#vlan 20
S2(config-vlan)#name Parking_Lot
S2(config-vlan)#vlan 99
S2(config-vlan)#name Management
S2(config-vlan)#vlan 1000
S2(config-vlan)#name Native
S2(config-vlan)#end

image-20230320173710748

0x021c 第二部分 步骤1.c

c. 输入show vlan brief命令来查看 S1 上 VLAN 的列表。
S1#show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/6, Fa0/7, Fa0/8
                                                Fa0/9, Fa0/10, Fa0/11, Fa0/12
                                                Fa0/13, Fa0/14, Fa0/15, Fa0/16
                                                Fa0/17, Fa0/18, Fa0/19, Fa0/20
                                                Fa0/21, Fa0/22, Fa0/23, Fa0/24
                                                Gig0/1, Gig0/2
10   Operations                       active    
20   Parking_Lot                      active    
99   Management                       active    
1000 Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
S1#

image-20230320173855275


Q.2.1.c.1 默认 VLAN 是哪个?

VLAN 1

Q.2.1.c.1 为默认 VLAN 分配了哪些端口?

Fa0/1, Fa0/2, Fa0/3, Fa0/4

Fa0/5, Fa0/6, Fa0/7, Fa0/8

Fa0/9, Fa0/10, Fa0/11, Fa0/12

Fa0/13, Fa0/14, Fa0/15, Fa0/16

Fa0/17, Fa0/18, Fa0/19, Fa0/20

Fa0/21, Fa0/22, Fa0/23, Fa0/24

Gig0/1, Gig0/2


0x22 第二部分 步骤2 将 VLAN 分配到正确的交换机接口

0x22a 第二部分.步骤2.a

a. 将 VLAN 分配到 S1 上的接口。

1) 将 PC-A 分配到 Student VLAN。

S1(config)# interface f0/6

S1(config-if)# switchport mode access

S1(config-if)# switchport access vlan 10

2) 从 VLAN 1 中,删除管理 IP 地址,然后在 VLAN 99 上进行配置。

S1(config)# interface vlan 1

S1(config-if)# no ip address

S1(config-if)# interface vlan 99

S1(config-if)# ip address 192.168.1.11 255.255.255.0

S1(config-if)# end

跟着上面执行就可以啦。大致是这样:

S1>enable
Password: [输入密码:class]
S1#conf t
S1(config)#
  [Enter configuration commands, one per line.  End with CNTL/Z.]
S1(config)#interface f0/6
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 10
S1(config-if)#interface vlan 1
S1(config-if)#no ip address
S1(config-if)#interface vlan 99
S1(config-if)#
  [%LINK-5-CHANGED: Interface Vlan99, changed state to up]
S1(config-if)# ip address 192.168.1.11 255.255.255.0
S1(config-if)#end

0x22bc 第二部分.步骤2.bc

b. 我们可以使用 show vlan brief 命令来验证 VLAN 是否已分配给了正确的接口。

c. 输入 show ip interface brief 命令。

步骤b,c 显示输出:

这里是S1的输出

S1#show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15, Fa0/16, Fa0/17
                                                Fa0/18, Fa0/19, Fa0/20, Fa0/21
                                                Fa0/22, Fa0/23, Fa0/24, Gig0/1
                                                Gig0/2
10   Operations                       active    Fa0/6
20   Parking_Lot                      active    
99   Management                       active    
1000 Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
S1#


S1#show ip interface brief 
Interface              IP-Address      OK? Method Status                Protocol 
FastEthernet0/1        unassigned      YES manual up                    up 
FastEthernet0/2        unassigned      YES manual administratively down down 
...
FastEthernet0/5        unassigned      YES manual administratively down down 
FastEthernet0/6        unassigned      YES manual up                    up 
FastEthernet0/7        unassigned      YES manual administratively down down 
...
FastEthernet0/23       unassigned      YES manual administratively down down 
FastEthernet0/24       unassigned      YES manual administratively down down 
GigabitEthernet0/1     unassigned      YES manual administratively down down 
GigabitEthernet0/2     unassigned      YES manual administratively down down 
Vlan1                  unassigned      YES manual up                    up 
Vlan99                 192.168.1.11    YES manual up                    down
S1#

Q.2.2.c.1 VLAN 99 的状态是什么?说明原因

VLAN 99 的状态为“active”,协议状态为“down”,即该 VLAN 在该接口上没有启动协议。

可能是 VLAN 99 还没有被任何一个设备或主机激活,或者该 VLAN 已经被删除,但该接口上的 VLAN 配置信息还没有被更新。


0x22def 第二部分.步骤2.def

d. 将 PC-B 分配到 S2 上的 Operations VLAN。
e. 从 VLAN 1 中删除管理 IP 地址,然后根据地址表在 VLAN 99 上进行配置。
f. 使用 show vlan brief 命令验证 VLAN 是否已分配到正确的接口。

记得在PC-B的终端进行操作哦


## d.将 PC-B 分配到 S2 上的 Operations VLAN。
S2#conf t
S2(config)# interface f0/18
S2(config-if)# switchport mode access
S2(config-if)# switchport access vlan 10
S2(config-if)# exit

## e.从 VLAN 1 中删除管理 IP 地址,然后根据地址表在 VLAN 99 上进行配置。
S2(config)# interface vlan 1
S2(config-if)# no ip address
S2(config-if)# interface vlan 99
S2(config-if)# ip address 192.168.1.12 255.255.255.0
S2(config-if)#exit
S2(config)#exit

## f.使用 show vlan brief 命令验证 VLAN 是否已分配到正确的接口。
S2# show vlan brief

步骤f输出内容:

这里是S2的输出

S2#show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/6, Fa0/7, Fa0/8
                                                Fa0/9, Fa0/10, Fa0/11, Fa0/12
                                                Fa0/13, Fa0/14, Fa0/15, Fa0/16
                                                Fa0/17, Fa0/19, Fa0/20, Fa0/21
                                                Fa0/22, Fa0/23, Fa0/24, Gig0/1
                                                Gig0/2
10   Operations                       active    Fa0/18
20   Parking_Lot                      active    
99   Management                       active    
1000 Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
S2#

image-20230320181129431


Q.2.2.1 S1 是否可以 ping 通 S2?说明原因

不可以,目前交换机S2的IP地址(192.168.1.12)在VLAN99 中,交换机S1的IP(192.168.1.11)在VLAN99 中,但是两个交换机在VLAN99之间没有可以交互的接口,因此也就不能ping通。

因此S1不可以S1在VLAN99的的IP地址来ping通S2。

image-20230320181917043

Q.2.2.2 PC-A 是否可以 ping 通 PC-B?说明原因

不可以,PC-A在 S1 的VLAN 10里,但是可以转发的接口F0/1 不在VLAN10里,也就不可以把ICMP、ARP包发过去,因此不可以ping通PC-B。

image-20230320182150198


0x3 第3部分: 维护 VLAN 的端口分配和 VLAN 数据库

在第 3 部分,您将更改端口的 VLAN 分配,并从 VLAN 数据库中删除 VLAN。

0x31 第3部分 步骤 1: 将一个 VLAN 分配到多个接口

在每台 PC 的 桌面选项卡中,使用 终端 继续配置两台网络交换机。
打开配置窗口
a. 在 S1 上,将接口 F0/11 – 24 分配给 VLAN99。

S1(config)# interface range f0/11-24
S1(config-if-range)# switchport mode access
S1(config-if-range)# switchport access vlan 99
S1(config-if-range)# end

b. 使用 show vlan brief 命令以验证 VLAN 分配。
c. 将 F0/11 和 F0/21 重新划分到 VLAN 10。
d. 验证 VLAN 分配是否正确。

在S1上操作

Password: [cisco]
S1>enable
Password: [class]
S1#
S1#conf t

## a.在 S1 上,将接口 F0/11 – 24 分配给 VLAN99。
S1(config)#interface range f0/11-24
S1(config-if-range)#switchport mode access
S1(config-if-range)#switchport access vlan 99
S1(config-if-range)#end

## b.使用 show vlan brief 命令以验证 VLAN 分配。
S1#show vlan brief
<----输出---->
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Gig0/1, Gig0/2
10   Operations                       active    Fa0/6
20   Parking_Lot                      active    
99   Management                       active    Fa0/11, Fa0/12, Fa0/13, Fa0/14
                                                Fa0/15, Fa0/16, Fa0/17, Fa0/18
                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22
                                                Fa0/23, Fa0/24
1000 Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
S1#
<----输出---->

## c.重新分配端口,给VLAN10  (又重新分一次)
S1#conf t
S1(config)#interface range f0/11, f0/21
S1(config-if-range)#switchport access vlan 10
S1(config-if-range)#end

## d. 验证 VLAN 分配是否正确。
S1#show vlan brief
<----输出---->
S1#
%SYS-5-CONFIG_I: Configured from console by console
show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Gig0/1, Gig0/2
10   Operations                       active    Fa0/6, Fa0/11, Fa0/21
20   Parking_Lot                      active    
99   Management                       active    Fa0/12, Fa0/13, Fa0/14, Fa0/15
                                                Fa0/16, Fa0/17, Fa0/18, Fa0/19
                                                Fa0/20, Fa0/22, Fa0/23, Fa0/24
1000 Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
<----输出---->

image-20230320183125893

0x32 第3部分 步骤 2: 从接口中删除 VLAN 分配

a. 使用 no switchport access vlan 命令删除分配给端口 F0/24 的VLAN 99。


S1(config)# interface f0/24
S1(config-if)# no switchport access vlan
S1(config-if)# end

b. 验证 VLAN 是否已更改。

#a.使用 no switchport access vlan 命令删除分配给端口 F0/24 的VLAN 99。
S1#conf t
S1(config)#interface f0/24
S1(config-if)#no switchport access vlan
S1(config-if)#end
S1#

## 彳亍

#b. 验证 VLAN 是否已更改。
S1#show vlan brief 

b的过程输出

S1#show vlan brief 
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/24, Gig0/1, Gig0/2
10   Operations                       active    Fa0/6, Fa0/11, Fa0/21
20   Parking_Lot                      active    
99   Management                       active    Fa0/12, Fa0/13, Fa0/14, Fa0/15
                                                Fa0/16, Fa0/17, Fa0/18, Fa0/19
                                                Fa0/20, Fa0/22, Fa0/23
1000 Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
S1#

Q.3.2.b F0/24 现在与哪个 VLAN 关联?

VLAN1 -> default


0x33 第3部分.步骤 3: 从 VLAN 数据库中删除 VLAN ID

0x33ab 第3部分.步骤 3.ab

a. 直接把接口 F0/24 划分到 VLAN 30 中,不要使用全局配置模式下VLAN 创建命令。

S1(config)# interface f0/24
S1(config-if)# switchport access vlan 30
% Access VLAN does not exist. Creating vlan 30

注:当前交换机技术不再需要发出 vlan 命令便可将 VLAN 添加到数据库。在把一个未知的VLAN分配给端口时,这个VLAN就会被创建出来并且添加到VLAN数据库中。
b. 验证在 VLAN 表中是否显示了新的 VLAN。

#a.直接把接口 F0/24 划分到 VLAN 30 中,不要使用全局配置模式下VLAN 创建命令。
S1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
S1(config)#interface f0/24
S1(config-if)#switchport access vlan 30
 [% Access VLAN does not exist. Creating vlan 30]
S1(config-if)#exit
S1(config)#exit

#b.验证在 VLAN 表中是否显示了新的 VLAN。
S1#show vlan brief 

步骤b输出

S1#show vlan brief 

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Gig0/1, Gig0/2
10   Operations                       active    Fa0/6, Fa0/11, Fa0/21
20   Parking_Lot                      active    
30   VLAN0030                         active    Fa0/24
99   Management                       active    Fa0/12, Fa0/13, Fa0/14, Fa0/15
                                                Fa0/16, Fa0/17, Fa0/18, Fa0/19
                                                Fa0/20, Fa0/22, Fa0/23
1000 Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
S1#

Q.3.3.b VLAN 30 的默认名称是什么?

30   VLAN0030                         active    Fa0/24

VLAN0030


0x33cd 第3部分.步骤 3.cd

c. 使用 no vlan 30 命令从 VLAN 数据库中删除 VLAN 30。


S1(config)# no vlan 30
S1(config)# end

d. 执行 show vlan brief 命令。F0/24 已分配到 VLAN 30。

## c.使用 no vlan 30 命令从 VLAN 数据库中删除 VLAN 30。
S1#conf t
  [Enter configuration commands, one per line.  End with CNTL/Z.]
S1(config)#no vlan 30
S1(config)#end
S1#
  [%SYS-5-CONFIG_I: Configured from console by console]

#d. 执行 show vlan brief 命令。F0/24 已分配到 VLAN 30。
S1#show vlan brief

步骤d输出

S1#show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Gig0/1, Gig0/2
10   Operations                       active    Fa0/6, Fa0/11, Fa0/21
20   Parking_Lot                      active    
99   Management                       active    Fa0/12, Fa0/13, Fa0/14, Fa0/15
                                                Fa0/16, Fa0/17, Fa0/18, Fa0/19
                                                Fa0/20, Fa0/22, Fa0/23
1000 Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default  

Q.3.3.d.1 从 VLAN 数据库中删除 VLAN 30 后,为什么 F0/24 不再显示在 show vlan brief 命令的输出中?

删除 VLAN 30 后,F0/24 不再显示在 show vlan brief 命令的输出中,因为该端口不再分配给任何 VLAN。

VLAN30 不在任何VLAN数据集中。

Q.3.3.d.2 端口 F0/24 现在分配给哪个 VLAN?

不再分配给任何 VLAN

Q.3.3.d.3 发往连接到 F0/24 的主机的流量会发生什么情况?

流量将无法通过 F0/24 发送和接收,因为该端口不再与任何 VLAN 关联。


0x33ef 第3部分.步骤 3.ef

e. 在 F0/24 接口上发出 no switchport access vlan 命令。

f. 发出 show vlan brief 命令以确定 F0/24 的 VLAN 分配。

# e.在 F0/24 接口上发出 no switchport access vlan 命令。
S1#conf t
S1(config)#interface f0/24
S1(config-if)#no switchport access vlan
S1(config-if)#end
S1#

# f.发出 show vlan brief 命令以确定 F0/24 的 VLAN 分配。
S1#show vlan brief

输出:

S1#show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/24, Gig0/1, Gig0/2
10   Operations                       active    Fa0/6, Fa0/11, Fa0/21
20   Parking_Lot                      active    
99   Management                       active    Fa0/12, Fa0/13, Fa0/14, Fa0/15
                                                Fa0/16, Fa0/17, Fa0/18, Fa0/19
                                                Fa0/20, Fa0/22, Fa0/23
1000 Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
S1#

Q.3.3.f.1 F0/24 分配给哪个 VLAN?

注意:在从数据库中删除VLAN之前,建议重新分配已经分配到这个VLAN中的所有端口。

VLAN 1 default

Q.3.3.f.2 为何应该先将端口重新分配给另一个 VLAN,然后才能从 VLAN 数据库中删除该 VLAN?

会导致端口无法正常工作,并且无法展示在show vlan brief,有些时候,甚至可能会增加了排除故障的难度。

  • 删除 VLAN 之前,应先将所有分配给该 VLAN 的端口重新分配给另一个 VLAN,确保网络中的所有流量都能够正常传输。
  • 在重新分配端口之前删除 VLAN,则可能会导致网络中的流量出现问题,这将导致网络中断或无法正常工作。

0x4 第 4部分: 在交换机之间配置 802.1Q 中继

在第 4 部分,您将把接口 F0/1 配置为使用动态中继协议 (DTP),以允许它协商中继模式。在完成并验证此配置后,您将在接口 F0/1 上禁用 DTP,并将它手动配置为中继。

0x41 第4部分 步骤 1: 使用 DTP 在 F0/1 上发起中继

2960 交换机端口的默认 DTP 模式为动态自动响应。这就允许该接口在相邻接口设为中继或动态主动协商模式时将链路转> 换为中继。
打开配置窗口

0x41a 第4部分 步骤 1.a

a.在 S1上,设置 F0/1为协商中继模式。

S1(config)# interface f0/1
S1(config-if)# switchport mode dynamic desirable
Sep 19 02:51:47.257: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to > up
Sep 19 02:51:47.291: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan99, changed state to up
您在 S2 上也应该收到链路状态消息。
S2#
Sep 19 02:42:19.424: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
Sep 19 02:42:21.454: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan99, changed state to up
Sep 19 02:42:22.419: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to > up

从这里开始,我建议把两个窗口并排起来,像图片中的一样,并且都登录后,进入enable模式

S1#conf t
S1(config)#interface f0/1
S1(config-if)#switchport mode dynamic desirable

回车的时候两边会一起出来这个信息。

image-20230320190313362

0x41b 第4部分 步骤 1.b

b. 在 S1 和S2上,执行 show vlan brief 命令。接口 F0/1 不再分配到 VLAN 1。中继的接口未在 VLAN 表中列> 出。

两边分别执行:

S1#show vlan brief

image-20230320190541349

0x41c 第4部分 步骤 1.c

c. 发出 show interfaces trunk 命令以查看中继的接口。注意 S1 上的模式设置为 desirable,S2 上的模式设置> 为 auto。

S1# show interfaces trunk

S2# show interfaces trunk

注:默认情况下,中继上允许所有 VLAN。switchport trunk 命令允许您控制哪些 VLAN 可以接入该中继。对于本练习,> 请保留默认设置。这允许所有 VLAN 穿越 F0/1。

关闭配置窗口

分别执行:

S1# show interfaces trunk
S2# show interfaces trunk

可得到结果:

S1#show interfaces trunk
Port        Mode         Encapsulation  Status        Native vlan
Fa0/1       desirable    n-802.1q       trunking      1

Port        Vlans allowed on trunk
Fa0/1       1-1005

Port        Vlans allowed and active in management domain
Fa0/1       1,10,20,99,1000

Port        Vlans in spanning tree forwarding state and not pruned
Fa0/1       1,10,20,99,1000

S2#show interfaces trunk
Port        Mode         Encapsulation  Status        Native vlan
Fa0/1       auto         n-802.1q       trunking      1

Port        Vlans allowed on trunk
Fa0/1       1-1005

Port        Vlans allowed and active in management domain
Fa0/1       1,10,20,99,1000

Port        Vlans in spanning tree forwarding state and not pruned
Fa0/1       1,10,20,99,1000

S2#

image-20230320190703851

0x41d 第4部分 步骤 1.d

d. 验证 VLAN 流量是否经过中继接口 F0/1 传输。

步骤d跟下面的问题差不多啦


Q.4.1.d.1 S1 是否能 ping 通 S2?

S1#ping 192.168.1.12

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.12, timeout is 2 seconds:
..!!!
Success rate is 60 percent (3/5), round-trip min/avg/max = 0/3/9 ms

可以ping通

Q.4.1.d.2 PC-A 是否能 ping 通 PC-B?

这里不是路由器的terminal(终端),是PC-A的命令指示符:

image-20230320191503768

这个东东。

可以ping通

image-20230320191413866

Q.4.1.d.3 PC-A 是否能 ping 通 S1?

S1#SHOW VLan Brief 

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/2, Fa0/3, Fa0/4, Fa0/5
                                                Fa0/7, Fa0/8, Fa0/9, Fa0/10
                                                Fa0/24, Gig0/1, Gig0/2
10   Operations                       active    Fa0/6, Fa0/11, Fa0/21
20   Parking_Lot                      active    
99   Management                       active    Fa0/12, Fa0/13, Fa0/14, Fa0/15
                                                Fa0/16, Fa0/17, Fa0/18, Fa0/19
                                                Fa0/20, Fa0/22, Fa0/23
1000 Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
S1#

S2#show vlan brief 

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/2, Fa0/3, Fa0/4, Fa0/5
                                                Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15, Fa0/16, Fa0/17
                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22
                                                Fa0/23, Fa0/24, Gig0/1, Gig0/2
10   Operations                       active    Fa0/18
20   Parking_Lot                      active    
99   Management                       active    
1000 Native                           active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active 

不可以 ,交换机S1 ,S2 都在VLAN 99 ,而PC-A PC-B都在VLAN10里,因此不可以ping通。

Q.4.1.d.4 PC-B 是否能 ping 通 S2?

同上面,不可以 ,交换机S1 ,S2 都在VLAN 99 ,而PC-A PC-B都在VLAN10里,因此不可以ping通。


如果对以上任何问题做否定回答,请在下面进行解释。

0x42 步骤 2: 手动配置中继接口 F0/1

switchport mode trunk 命令用于手动将端口配置为中继。此命令应该在链路的两端发出。

最后一步啦。加油加油

0x42ab 第4部分 步骤 2.ab

a. 更改接口 F0/1 上的交换机端口模式以强制中继。确保在两台交换机上都执行了这项操作。
打开配置窗口
S1(config)# interface f0/1
S1(config-if)# switchport mode trunk
b.使用 show interfaces trunk 命令查看中继模式。注意,模式已从主动协商更改为打开。
S1# show interfaces trunk

这里要两边一起执行哦。

差不多弄成这样的窗口比较爽

image-20230320192231411

S1执行(PC-A)

S1#conf t
  [Enter configuration commands, one per line.  End with CNTL/Z.]
S1(config)#interface f0/1
S1(config-if)#switchport mode trunk
S1(config)#end
S1#show interfaces trunk

S2执行(PC-B)

S2#conf t
  [Enter configuration commands, one per line.  End with CNTL/Z.]
S2(config)#interface f0/1
S2(config-if)#switchport mode trunk
S2(config)#end
S2#show interfaces trunk

S1输出:

S1#show interfaces trunk
Port        Mode         Encapsulation  Status        Native vlan
Fa0/1       on           802.1q         trunking      1

Port        Vlans allowed on trunk
Fa0/1       1-1005

Port        Vlans allowed and active in management domain
Fa0/1       1,10,20,99,1000

Port        Vlans in spanning tree forwarding state and not pruned
Fa0/1       1,10,20,99,1000

S2输出:

S2#
%SYS-5-CONFIG_I: Configured from console by console
show interfaces trunk
Port        Mode         Encapsulation  Status        Native vlan
Fa0/1       on           802.1q         trunking      1

Port        Vlans allowed on trunk
Fa0/1       1-1005

Port        Vlans allowed and active in management domain
Fa0/1       1,10,20,99,1000

Port        Vlans in spanning tree forwarding state and not pruned
Fa0/1       1,10,20,99,1000

0x42cd 第4部分 步骤 2.cd

c. 在两台交换机上修改中继的配置,把本征 VLAN 从 VLAN 1 修改为 VLAN 1000。
S1(config)# interface f0/1
S1(config-if)# switchport trunk native vlan 1000

d. 输入 show interfaces trunk 命令来查看中继。请注意,本征 VLAN 信息已经更新。
S2# show interfaces trunk

S1输入:

S1#conf t
S1(config)# interface f0/1
S1(config-if)# switchport trunk native vlan 1000
S1(config-if)#end
S1# show interfaces trunk

S2输入:

S2(config)#interface f0/1
S2(config-if)#switchport trunk native vlan 1000
S2(config-if)#end

%SPANTREE-2-UNBLOCK_CONSIST_PORT: Unblocking FastEthernet0/1 on VLAN1000. Port consistency restored.
%SPANTREE-2-UNBLOCK_CONSIST_PORT: Unblocking FastEthernet0/1 on VLAN0001. Port consistency restored.

%SYS-5-CONFIG_I: Configured from console by console
S2#show interfaces trunk

S1输出:

show interfaces trunk
Port        Mode         Encapsulation  Status        Native vlan
Fa0/1       on           802.1q         trunking      1000

Port        Vlans allowed on trunk
Fa0/1       1-1005

Port        Vlans allowed and active in management domain
Fa0/1       1,10,20,99,1000

Port        Vlans in spanning tree forwarding state and not pruned
Fa0/1       1,10,20,99,1000

S2输出:

S2#show interfaces trunk
Port        Mode         Encapsulation  Status        Native vlan
Fa0/1       on           802.1q         trunking      1000

Port        Vlans allowed on trunk
Fa0/1       1-1005

Port        Vlans allowed and active in management domain
Fa0/1       1,10,20,99,1000

Port        Vlans in spanning tree forwarding state and not pruned
Fa0/1       10,20,99

S2#

Q.4.2.d.2 您可能因为什么原因而将接口手动配置为中继模式,而不是使用 DTP?

并不是所有的设备支持DTP,使用命令可以提高兼容性

手动配置中继模式可以提高网络安全性,使用DTP动态协商中继模式时,攻击者可以通过发送伪造的DTP帧来欺骗交换机,将本来应该是主机端口的接口转换为中继端口,可能导致安全漏洞和网络故障。

手动配置中继模式可提高网络可靠性,可以避免由于DTP协商失败而导致的中继链路不可用。

Q.4.2.d.2 为什么我们有可能需要修改干道上的本征VLAN?

关闭配置窗口

干道上的本征VLAN通常被用来区分不同的VLAN,不需要在数据帧中添加VLAN ID。

有助于提高网络性能和减少带宽消耗。

有时需要将干道上的本征VLAN从默认的VLAN 1修改为其他VLAN。

使用VLAN1 也可能有一些安全风险,没有标记的流量使用VLAN1 交换,可能会暴力信息。

Q.4.2.t.1 需要怎样才能允许 VLAN 10 上的主机与 VLAN 20 上的主机通信?

在两个VLAN之间配置路由器或三层交换机,将它们连接起来并配置为VLAN接口或子接口,两个VLAN之间的通信才能实现。

Q.4.2.t.2 组织通过有效使用 VLAN 主要可以获得哪些优势?

  • 提高网络性能:缓解广播风暴。将不同的设备和流量隔离在不同的VLAN中,可以减少网络拥塞,提高带宽利用率和网络性能。
  • 提高网络安全性:VLAN可以帮助隔离敏感数据和关键系统,提高网络安全性。
  • 简化管理:将网络拆分为多个逻辑段,可以简化管理和配置,并使网络更加灵活和易于扩展。
  • 降低成本:VLAN可以帮助节省硬件和设备成本,减少数据中心的空间占用率,并提高资源利用率。
  • 提高管理效率,运维成本。

0x50 sbsjc

image-20230320193935813

0x51 文件下载

image-20230320194718488

文件:

3.4.6-packet-tracer_dayi.pka:https://p.dabbit.net/blog/pic_bed/2023/03/56e202b6e7a56239_202303201948620.zip

mysql 懒人包虚拟机(仅40M)(备用法子)

该方法是某种意义的懒人包。

如果你mysql实在装不上,各种奇怪的问题,可以试试这个用虚拟机替代使用。 这个方法挺省心的。


吃法如下

开机

  • 下载文件:alpine_virt_mysql.7z

  • 解压文件:alpine_virt_mysql.7z
  • 双击: alpine_virt_mysql.vmx
  • 点击开启虚拟机,可能提示 复制虚拟机/迁移虚拟机,都可以。

    image-20230319194417068

  • 查看虚拟机IP

    目的是找到虚拟机的IP,然后用Navicat直接连接。

    • 这里出现的IP (类似192.168.226.139)就是虚拟机的IP地址

      image-20230319193445574

    找不到ip?

    将虚拟机网卡切换为NAT模式,重启虚拟机即可。

    其他的方法:

    如果你没找到IP(按理说上面有了),试试这样做:登录虚拟机:

    输入用户名:root
    密码:123456
    
    输入 ip addr

    image-20230319193537957

Navicat 连接MYSQL:

  • 左上角连接,选择mysql

    image-20230319193702347

  • 输入相关,登录名root,密码123456
  • 主机填刚刚找到的IP

    image-20230319193941191

  • 不出意外就可以啦

    image-20230319194028885

安全关机(可选)

没啥很需要的东西的话直接关机就行

登录后输入

poweroff