如何使用 cisco 路由器在棒上配置路由器

网络工程 思科 路由器 转变
2021-07-24 04:10:57

我的家庭实验室中有这个场景

在此处输入图片说明

我的 cisco 2600 路由器只有 1 个物理接口,所以我分成了 3 个子接口

  1. VLAN 10 的 E0/0.1
  2. E0/0.2 FOR VLAN 20
  3. VLAN 1 的 E0/0.3 与我的 mian netgear 路由器(即 dhcp 服务器)在同一子网中
  4. cisco交换机是二层交换机

  1. 首先我想知道这个设置是否可行或需要路由器两个 2 个接口
  2. 我已将默认网关设置为 192.168.0.1,但我无法从路由器 ping 到它。

笔记本电脑上的互联网通过以太网电缆工作正常,并且从 netgear 路由器获取有效 IP

2个回答
  1. 对的,这是可能的。

  2. 您做错了什么,很可能是在路由器上标记帧,但中继将 VLAN 1 设为本机。

要确认您使用的中继设置:

show interfaces trunk

我喜欢保持子接口 ID 与 VLAN 编号匹配,尽管这不是必需的。使用如下配置:

! Switch
! Port to Laptop
interface Fax/x
switchport mode access
switchport access vlan 1
spanning-tree portfast
description Port to PC
! Port to Netgear
interface Fax/x
switchport mode access
switchport access vlan 1
spanning-tree portfast
description Port to Netgear
! Port to Cisco router
interface Fax/x
switchport trunk encapsulation dot1q
switchport mode trunk
spanning-tree portfast trunk
description port to Cisco router

对于路由器:

! Router
! Port to switch
interface E0/0.1
encapsulation dot1q 1 native
ip add 192.168.0.70 255.255.255.0
description VLAN1 to Netgear
interface E0/0.10
encapsulation dot1q 10
ip add 192.168.10.70 255.255.255.0
description VLAN10
interface E0/0.20
encapsulation dot1q 20
ip add 192.168.20.70 255.255.255.0
description VLAN20
ip routing
ip route 0.0.0.0 0.0.0.0 192.168.0.1

显然,将 IP 替换为子网中所需的 IP。

连接到默认网关的端口上的交换机似乎存在标记问题。您是否在端口中指定了允许的 vlan?尝试添加命令switchport trunk allowed vlan 1,10,20