|
| 1 | +# 第 21 天 实验 |
| 2 | + |
| 3 | +## VLAN 间路由器的子接口实验 |
| 4 | + |
| 5 | +### 实验拓扑图 |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +### 实验目的 |
| 11 | + |
| 12 | + |
| 13 | +学习如何使用路由器子接口,配置 VLAN 间路由。 |
| 14 | + |
| 15 | +我(作者)已将 Packet Tracer 用于这个实验,但当咱们有着对全部可用设备的访问时,咱们也可以使用咱们自己的家庭实验室。要在每台电脑上设置下面显示的 IP 地址,并将顶部那台 PC 的默认网关,设置为 `10.10.10.254`,底部 PC 的默认网关设置为 `10.20.20.254`。下面是顶部 PC 的配置: |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +### 实验步骤 |
| 22 | + |
| 23 | +1. 在其中交换机上创建 `VLAN 10` 及 `VLAN 20`,并为正确 VLAN 设置正确端口; |
| 24 | + |
| 25 | +```console |
| 26 | +Switch#conf t |
| 27 | +Enter configuration commands, one per line. End with CNTL/Z. |
| 28 | +Switch(config)#vlan 10 |
| 29 | +Switch(config-vlan)#vlan 20 |
| 30 | +Switch(config-vlan)#int f0/2 |
| 31 | +Switch(config-if)#switchport mode access |
| 32 | +Switch(config-if)#switchport access vlan 10 |
| 33 | +Switch(config-if)#no shut |
| 34 | +Switch(config-if)#int f0/1 |
| 35 | +Switch(config-if)#switchport mode access |
| 36 | +Switch(config-if)#switchport access vlan 20 |
| 37 | +``` |
| 38 | + |
| 39 | +2. 将面向路由器的接口,设置为中继; |
| 40 | + |
| 41 | +```console |
| 42 | +Switch(config-if)#int g0/1 |
| 43 | +Switch(config-if)#switchport mode trunk |
| 44 | +``` |
| 45 | + |
| 46 | + |
| 47 | +3. 在路由器上配置子接口,每个 VLAN 配置一个; |
| 48 | + |
| 49 | + |
| 50 | +```console |
| 51 | +Router(config)#int g0/1 |
| 52 | +Router(config-if)#no ip address |
| 53 | +Router(config-if)#int g0/1.10 |
| 54 | +Router(config-subif)#encap dot1Q 10 |
| 55 | +Router(config-subif)#ip add 10.10.10.254 255.255.255.0 |
| 56 | +Router(config-subif)# |
| 57 | +Router(config-subif)#int g0/1.20 |
| 58 | +Router(config-subif)#encap dot |
| 59 | +Router(config-subif)#encap dot1Q 20 |
| 60 | +Router(config-subif)#ip add 10.20.20.254 255.255.255.0 |
| 61 | +Router(config-subif)#int g0/1 |
| 62 | +Router(config-if)#no shut |
| 63 | +``` |
| 64 | + |
| 65 | + |
| 66 | +4. 在 `10.10.10.1` 设备上打开一个命令提示符并 `ping` 默认网关。然后 `ping` `VLAN 20` 中的 PC,证明这一子接口配置有效。 |
| 67 | + |
| 68 | +```console |
| 69 | +Packet Tracer PC Command Line 1.0 |
| 70 | +C:\>ping 10.10.10.254 |
| 71 | + |
| 72 | +Pinging 10.10.10.254 with 32 bytes of data: |
| 73 | + |
| 74 | +Reply from 10.10.10.254: bytes=32 time=1ms TTL=255 |
| 75 | +Reply from 10.10.10.254: bytes=32 time=1ms TTL=255 |
| 76 | +Reply from 10.10.10.254: bytes=32 time<1ms TTL=255 |
| 77 | +Reply from 10.10.10.254: bytes=32 time<1ms TTL=255 |
| 78 | + |
| 79 | +Ping statistics for 10.10.10.254: |
| 80 | + Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), |
| 81 | +Approximate round trip times in milli-seconds: |
| 82 | + Minimum = 0ms, Maximum = 1ms, Average = 0ms |
| 83 | + |
| 84 | +C:\>ping 10.20.20.1 |
| 85 | + |
| 86 | +Pinging 10.20.20.1 with 32 bytes of data: |
| 87 | + |
| 88 | +Request timed out. |
| 89 | +Reply from 10.20.20.1: bytes=32 time<1ms TTL=127 |
| 90 | +Reply from 10.20.20.1: bytes=32 time<1ms TTL=127 |
| 91 | +Reply from 10.20.20.1: bytes=32 time<1ms TTL=127 |
| 92 | + |
| 93 | +Ping statistics for 10.20.20.1: |
| 94 | + Packets: Sent = 4, Received = 3, Lost = 1 (25% loss), |
| 95 | +Approximate round trip times in milli-seconds: |
| 96 | + Minimum = 0ms, Maximum = 0ms, Average = 0ms |
| 97 | +``` |
| 98 | + |
| 99 | + |
| 100 | +## VLAN 间的 SVI |
| 101 | + |
| 102 | +### 拓扑 |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | +### 实验目的 |
| 107 | + |
| 108 | +学习如何使用 SVI 配置 VLAN 间路由。 |
| 109 | + |
| 110 | +我已将 Packet Tracer 用于这个实验,以及内置的三层交换机,但当咱们有着对全部可用设备的访问时,咱们可使用咱们自己的家庭实验室。要在每台 PC 上设置下面显示的 IP 地址,并按图中标记设置默认网关。 |
| 111 | + |
| 112 | + |
| 113 | +### 实验步骤 |
| 114 | + |
| 115 | +1. 在交换机上创建 `VLAN 10` 与 `VLAN 20`,并针对正确 VLAN 设置正确端口; |
| 116 | + |
| 117 | + |
| 118 | +```console |
| 119 | +Switch#conf t |
| 120 | +Enter configuration commands, one per line. End with CNTL/Z. |
| 121 | +Switch(config)#vlan 10 |
| 122 | +Switch(config-vlan)#vlan 20 |
| 123 | +Switch(config-vlan)#int f0/2 |
| 124 | +Switch(config-if)#switchport |
| 125 | +Switch(config-if)#switchport mode access |
| 126 | +Switch(config-if)#switchport access vlan 10 |
| 127 | +Switch(config-if)#no shut |
| 128 | +Switch(config-if)#int f0/1 |
| 129 | +Switch(config-if)#switchport |
| 130 | +Switch(config-if)#switchport mode access |
| 131 | +Switch(config-if)#switchport access vlan 20 |
| 132 | +``` |
| 133 | + |
| 134 | + |
| 135 | +2. 因为我(作者)使用的是个三层交换机,所以我们必须以 `switchport` 命令,将接口设置为二层接口,即咱们在上面看到的。接下来,我们需要为 VLAN 添加一个 IP 地址,因为我们未连接到某个路由器; |
| 136 | + |
| 137 | + |
| 138 | +```console |
| 139 | +Switch(config)#interface vlan 10 |
| 140 | +%LINK-5-CHANGED: Interface Vlan10, changed state to up |
| 141 | +%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up |
| 142 | +Switch(config-if)#ip add 10.10.10.1 255.255.255.0 |
| 143 | +Switch(config-if)#no shut |
| 144 | +Switch(config-if)#int vlan 20 |
| 145 | +%LINK-5-CHANGED: Interface Vlan20, changed state to up |
| 146 | +%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up |
| 147 | +Switch(config-if)#ip add 10.20.20.1 255.255.255.0 |
| 148 | +Switch(config-if)#no shut |
| 149 | +Switch(config-if)#exit |
| 150 | +Switch#show vlan brief |
| 151 | +VLAN Name Status Ports |
| 152 | +---- -------------- --------- ------------------------------- |
| 153 | +1 default active Fa0/3, Fa0/4, Fa0/5, Fa0/6 |
| 154 | + Fa0/7, Fa0/8, Fa0/9, Fa0/10 |
| 155 | + Fa0/11, Fa0/12, Fa0/13, Fa0/14 |
| 156 | + Fa0/15, Fa0/16, Fa0/17, Fa0/18 |
| 157 | + Fa0/19, Fa0/20, Fa0/21, Fa0/22 |
| 158 | + Fa0/23, Fa0/24, Gig0/1, Gig0/2 |
| 159 | + Gig0/1, Gig0/2 |
| 160 | +10 VLAN0010 active Fa0/2 |
| 161 | +20 VLAN0020 active Fa0/1 |
| 162 | +1002 fddi-default active |
| 163 | +1003 token-ring-default active |
| 164 | +1004 fddinet-default active |
| 165 | +1005 trnet-default active |
| 166 | +``` |
| 167 | + |
| 168 | +3. 由于我们没有使用路由器,所以我们启用该交换机上的 IP 路由,以便器可在两个子网间路由; |
| 169 | + |
| 170 | + |
| 171 | +```console |
| 172 | +Switch(config)#ip routing |
| 173 | +``` |
| 174 | + |
| 175 | + |
| 176 | +4. 检查 VLAN 接口是否起来; |
| 177 | + |
| 178 | +```console |
| 179 | +Switch#show ip interface brief |
| 180 | +GigabitEthernet0/1 unassigned YES unset down down |
| 181 | +GigabitEthernet0/2 unassigned YES unset down down |
| 182 | +Vlan1 unassigned YES unset administratively down down |
| 183 | +Vlan10 10.10.10.1 YES manual up up |
| 184 | +Vlan20 10.20.20.1 YES manual up up |
| 185 | +[Output Truncated] |
| 186 | +``` |
| 187 | + |
| 188 | +5. `ping` 默认网关,然后 `ping` 另一个 VLAN 上的 PC,检查 VLAN 间路由是否正常。 |
| 189 | + |
| 190 | + |
| 191 | +```console |
| 192 | +C:\>ping 10.10.10.1 |
| 193 | + |
| 194 | +Pinging 10.10.10.1 with 32 bytes of data: |
| 195 | + |
| 196 | +Reply from 10.10.10.1: bytes=32 time<1ms TTL=255 |
| 197 | +Reply from 10.10.10.1: bytes=32 time<1ms TTL=255 |
| 198 | +Reply from 10.10.10.1: bytes=32 time<1ms TTL=255 |
| 199 | +Reply from 10.10.10.1: bytes=32 time<1ms TTL=255 |
| 200 | + |
| 201 | +Ping statistics for 10.10.10.1: |
| 202 | + Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), |
| 203 | +Approximate round trip times in milli-seconds: |
| 204 | + Minimum = 0ms, Maximum = 0ms, Average = 0ms |
| 205 | + |
| 206 | +C:\>ping 10.20.20.20 |
| 207 | + |
| 208 | +Pinging 10.20.20.20 with 32 bytes of data: |
| 209 | + |
| 210 | +Request timed out. |
| 211 | +Reply from 10.20.20.20: bytes=32 time<1ms TTL=127 |
| 212 | +Reply from 10.20.20.20: bytes=32 time<1ms TTL=127 |
| 213 | +Reply from 10.20.20.20: bytes=32 time<1ms TTL=127 |
| 214 | + |
| 215 | +Ping statistics for 10.20.20.20: |
| 216 | + Packets: Sent = 4, Received = 3, Lost = 1 (25% loss), |
| 217 | +Approximate round trip times in milli-seconds: |
| 218 | + Minimum = 0ms, Maximum = 0ms, Average = 0ms |
| 219 | + |
| 220 | +C:\> |
| 221 | +``` |
| 222 | + |
| 223 | + |
| 224 | + |
0 commit comments