# 路由交换-作业7-4.2.8-CCNA 7 配置单臂路由-2

> 当前进度 1.0
>
> 更新地址:https://blog.dayi.ink/?p=8
>
> 更新地址:/posts/9cbf91c1-89ac-5bfc-98fb-fca32cb6a32c

【dayi的大键盘】新的博客：https://blog.dayi.ink ，欢迎来体验新的阅读。

有阅读模式，可能会更好的阅读体验。

## 更新中修改的内容

在试错过程中发现并修改的内容:

```bash
目前没有
```

## 0x00 准备文件

- 好像没有pka文件
- 唔
- 下载地址：https://p.dabbit.net/blog/pic_bed/2023/03/2cf6e31ed0fea3a6_202303272123640.7z
- 如果你感觉不知道要做什么，你可以先看看pdf 或者word，然后不会的地方再对照文章，这样你就会啦！
- 尽可能的多手打一点指令，加深自己的熟练度哦
- **本文尝试了分步骤保存文件，在文章末尾可以下载到分步骤分章节的文件哦。**

# 0x01 基础信息

**网络拓扑图：**

也就是等会要搭建的

![image-20230327212701842](/media/ae/ae989a9c35f09cd2794b606085d88d3880fe275353af2ada0bd0ea5bafe7a146.png#vwid=783&vhei=297)

**地址分配表**

| 设备 | 接口     | **IP** 地址  | 子网掩码      | 默认网关    |
| ---- | -------- | ------------ | ------------- | ----------- |
| R1   | G0/0/1.3 | 192.168.3.1  | 255.255.255.0 | 不适用      |
| *R1* | G0/0/1.4 | 192.168.4.1  | 255.255.255.0 | 不适用      |
| *R1* | G0/0/1.8 | 不适用       | 不适用        | 不适用      |
| S1   | VLAN 3   | 192.168.3.11 | 255.255.255.0 | 192.168.3.1 |
| S2   | VLAN 3   | 192.168.3.12   | 255.255.255.0 | 192.168.3.1 |
| PC-A | NIC      | 192.168.3.3  | 255.255.255.0 | 192.168.3.1 |
| PC-B | NIC      | 192.168.4.3  | 255.255.255.0 | 192.168.4.1 |



**VLAN** 应该是这个样子

| VLAN | Name       | Interface Assigned             |
| ---- | ---------- | ------------------------------ |
| 3    | Management | S1: VLAN 3                     |
| 3    | Management | S2: VLAN 3                     |
| 3    | Management | S1: F0/6                       |
| 4    | Operations | S2: F0/18                      |
| 7    | ParkingLot | S1: F0/2-4, F0/7-24, G0/1-2    |
| 7    | ParkingLot | S2: F0/2-17,  F0/19-24, G0/1-2 |
| 8    | Native     | N/A                            |



**目标**

第 **1** 部分：构建网络并配置设备的基本设置

第 **2** 部分：创建 **VLAN** 并分配交换机端口

第 **3** 部分：在交换机之间配置一条 **802.1****Q** 干道

第 **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](/media/fb/fb90996400f927422c586cdaad1250731a0363faa1902452d2e6d9b48eb4b81e.png#vwid=954&vhei=524)



说实在，我没找到4221，我拿了个4321，应该差不多，看了看固件信息：

```bash
isr4300-universalk9.03.16.05.S.155-3.S5-ext.SPA.bin
```

应该问题也不大

![image-20230327213700630](/media/12/12da7e289f6ba8ebe5a4633f228a96a6422db31e2c80f4b2e8d9fddad0538861.png#vwid=403&vhei=320)

连接示意gif:

![](/media/da/da0d891d73f3de6abc1e342476331335eafcd77775aa6e61eb67bf1dc4dba3de.gif#vwid=1082&vhei=784)

连接最后的结果

![image-20230327214820145](/media/0d/0df78c6d404b6967a8d81aebab5ae46d878a96748c78bcc6a979c60c2e1fb6e3.png#vwid=481&vhei=434)、



## 0x12 步骤 2： 配置路由器的基本设置。

> a. 通过控制台连接到路由器并进入特权模式。
> b. 进入配置模式。
> c. 为路由器分配一个设备名称。
> d. 要防止路由器尝试将错误输入的命令视为主机名，则禁用 DNS 查找。
> e. 指定 class 作为特权EXEC 加密密码。
> f. 指定 cisco 作为控制台密码并启用登录。
> g. 指定 cisco 作为 VTY 密码并启用登录。
> h. 加密明文密码。
> i. 创建一个向访问设备者发出警告的标语：未经授权，禁止访问。
> j. 将运行配置保存到启动配置文件中。
> k. 设置路由器上的时钟。
> 注意：使用问号 (?) 可以确定这行这条命令所需参数的正确顺序。

其实这些步骤之前都已经做过啦，这里就直接放命令啦

```bash
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交换机：**
```bash
#输入命令进入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交换机**，同理啦，这里就注释命令啦

```bash
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-A | NIC  | 192.168.3.3 | 255.255.255.0 | 192.168.3.1 |
| PC-B | NIC  | 192.168.4.3 | 255.255.255.0 | 192.168.4.1 |

![image-20230327221400867](/media/78/783630727fe203734cba41e188a8ac0c6d3dd08975eb55a804765c6dad8f77e0.png#vwid=689&vhei=336)

![image-20230327221450026](/media/83/83f7b0e5b65c094edeeefc39ae4bcee87dac135180693630b8223f385e7bdac8.png#vwid=678&vhei=317)

## 0x20 第 2 部分： 创建 VLAN 并分配交换机端口
> 在第2 部分中，您需要根据上表中表示的信息，在两台交换机上创建VLAN。然后将 VLAN 分配到相应的接口。show vlan 命令用于验证您的配置设置。在各台交换机上完成下面的任务。

## 0x21 第 2 部分：步骤 1： 在两台交换机上创建VLAN。
>a. 按照上表的内容，在每台交换机上创建并命名VLAN。
>b. 使用地址分配表中包含的 IP 地址信息配置管理接口和默认网关。
>c. 把交换机上所有未使用的端口都划分到 ParkingLot VLAN，将其配置为access 模式，并从管理上关闭这些端口。
>注意: interface range 命令可以帮助我们用尽可能少的命令来完成这个任务。

VLAN 表：
| VLAN | Name       | Interface Assigned             |
| ---- | ---------- | ------------------------------ |
| 3    | Management | S1: VLAN 3                     |
| 3    | Management | S2: VLAN 3                     |
| 3    | Management | S1: F0/6                       |
| 4    | Operations | S2: F0/18                      |
| 7    | ParkingLot | S1: F0/2-4, F0/7-24, G0/1-2    |
| 7    | ParkingLot | S2: F0/2-17,  F0/19-24, G0/1-2 |
| 8    | Native     | N/A                            |

**对于S1交换机**

```bash
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交换机**

```bash
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 表：
| VLAN | Name       | Interface Assigned             |
| ---- | ---------- | ------------------------------ |
| 3    | Management | S1: VLAN 3                     |
| 3    | Management | S2: VLAN 3                     |
| 3    | Management | S1: F0/6                       |
| 4    | Operations | S2: F0/18                      |
| 7    | ParkingLot | S1: F0/2-4,F0/7-24, G0/1-2    |
| 7    | ParkingLot | S2: F0/2-17,F0/19-24, G0/1-2 |
| 8    | Native     | N/A                            |

### **先配S1的：**

- VLAN 3 Management 有 F0/6
- VLAN 7  的接口 ParkingLot 的已经配完啦

也就是只需要配置F0/6的命令

```bash
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就可以啦

```bash
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信息：**

```bash
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](/media/bf/bfcc6fc1c4a5f834fccacdd9680f222e9470b505654d441d2709ea4fc2302907.png#vwid=716&vhei=689)



![image-20230327224018350](/media/96/9616eb4e9da82a01e336a1c282441531023a1b9cce38bc56dff390b43a114019.png#vwid=716&vhei=689)


## 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:
```bash
#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：

```bash
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
```



### 显示中继信息：

```bash
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交换机：

```bash
#进入配置模式
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交换机：

```bash
#保存配置
S2#copy running-config startup-config
Destination filename [startup-config]? 
Building configuration...
[OK]
```



### 验证：

```bash
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 命令来验证子接口是否已启用。

### 进入路由器
```bash
Password:[cisco]
R1>enable
Password:[class]
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#
```

### a.激活端口：
```bash
R1(config)# interface g0/0/1
R1(config-if)# no shutdown
R1(config-if)# exit
```
### b.分配VLAN
```bash
#第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.验证：
```bash
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 操作。

```powershell
ping 192.168.3.1
```

![image-20230327232615575](/media/d5/d5a6117e5c569d18e6c33327cded29a7c0a4ef9316959eeadfb5525e000588fa.png#vwid=716&vhei=689)

### b. 从 PC-A 对 PC-B 执行 ping 操作

```powershell
ping 192.168.4.3
```

结果：

```powershell
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](/media/d6/d65fc009a939935f3f498ee30f846426fe3090f07db9984edc97d228065d8248.png#vwid=716&vhei=689)



### c. 从 PC-A 向 S2 发起 Ping 测试。

```powershell
ping 192.168.3.12
```

```powershell
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](/media/55/55beeb089e4c659497882cb3b21e973b22c0772ddc1e19cbfbccf686f412d433.png#vwid=716&vhei=689)




## 0x52 步骤 2： 从PC-B 发起下列的测试。
> 从 PC-B 上的命令提示符，向 PC-A 的地址执行 tracert 命令。

```powershell
tracert 192.168.3.3
```



```powershell
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](/media/98/98234eb0866590bc19934c820c384d46bb9ed5d882d4bbc7c669d18a7b10c873.png#vwid=444&vhei=186)

----


### Q.0x52 结果中会显示哪些中间IP 地址？
节点1的IP地址是`192.168.4.1`，表示该节点是本地网络的网关，也是R1的`G0/0/1.4`口
节点2的IP地址是`192.168.3.3`，表示目标主机的IP地址


## 0x60 文件下载：
分了步骤啦：

![image-20230327233540882](/media/e9/e98f6288f2d61dd6dbd7d1323998ac3330a3745291817a02dbcbcfa949551a6b.png#vwid=697&vhei=379)


https://p.dabbit.net/blog/pic_bed/2023/03/011537484bc73cf3_202303272334452.zip