路由交换-作业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

最后修改:2023 年 04 月 02 日
如果觉得我的文章对你有用,请随意赞赏