路由器和 VLAN

网络工程 思科 转变 路由器 VLAN 数据包追踪器
2021-07-08 23:53:26

PC 1 在 VLAN 10 上

PC 2 位于 VLAN 20

路由器 1 位于 VLAN 30

SW 和 Router2 之间是中继,允许 vlan 10-30

我可以在 PC1 和 PC2 之间 ping,但我不能从路由器 1 ping 任何 PC。我应该添加额外的路由吗?

更新:

更简单的版本(仍然不起作用)

我有这样的拓扑:

在此处输入图片说明

这是我的配置:

转变

int fa0/1
sw mode access 
sw access vlan 10

int fa0/2
sw mode access
sw access vlan 20

int fa0/3
sw mode trunk
sw trunk allowed vlan 10-20

路由器 R_1 配置

int fa0/0.10
encapsulation dot1q
ip address 10.0.10.1 255.255.255.0

int fa0/0.20
encapsulation dot1q
ip address 10.0.20.1 255.255.255.0

电脑配置

ip : 10.0.10.100/24  default gateway : 10.0.10.1

路由器 R_2 上的配置

int fa0/0
ip address 10.0.20.100 255.255.255.0

R_2的路由配置

Gateway of last resort is not set

     10.0.0.0/24 is subnetted, 2 subnets
C       10.0.10.0 is directly connected, FastEthernet0/0.10
C       10.0.20.0 is directly connected, FastEthernet0/0.20

演出结束后:

Router#show run
Building configuration...

Current configuration : 719 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
!
ip cef
no ipv6 cef
!
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/0
 no ip address
 duplex auto
 speed auto
!
interface FastEthernet0/0.10
 encapsulation dot1Q 10
 ip address 10.0.10.1 255.255.255.0
!
interface FastEthernet0/0.20
 encapsulation dot1Q 20
 ip address 10.0.20.1 255.255.255.0
!
interface FastEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Vlan1
 no ip address
 shutdown
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
end

R_2的路由配置

Gateway of last resort is 10.0.20.1 to network 0.0.0.0

     10.0.0.0/24 is subnetted, 1 subnets
C       10.0.20.0 is directly connected, FastEthernet0/0
S*   0.0.0.0/0 [1/0] via 10.0.20.1

演出结束后:

Router#show run
Building configuration...

Current configuration : 596 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
!
ip cef
no ipv6 cef
!
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/0
 ip address 10.0.20.100 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Vlan1
 no ip address
 shutdown
!
ip classless
ip route 0.0.0.0 0.0.0.0 10.0.20.1 
!
ip flow-export version 9
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
end
1个回答

我认为您缺少的部分是如果两个 VLAN 之间没有路由器,则一个 VLAN 无法与另一个 VLAN 通信;就好像它们是单独接口上的单独电缆。

交换机是第 2 层设备,它对第 3 层地址一无所知。它不能桥接 VLAN 之间的流量,这是 VLAN 的重点。交换机只会将流量从一个 VLAN 上的端口发送到具有相同 VLAN 的端口或中继。它根本无法从 VLAN 20 上的 R_2 获取流量并将其发送到 VLAN 10 上的 PC。

从逻辑上讲,R_2 连接到一个接口上的 R_1,而 PC 连接到另一个接口上的 R_1。PC 具有到其网关 (R_1) 的隐式默认路由。R_2 没有隐式默认路由,因此它只知道直接连接的路由 (VLAN 20) 和任何静态路由或通过路由协议获知的路由,但您没有运行路由协议。这就是您必须配置静态路由的原因。

静态路由,就像您在 R_2 上配置的一样,根本无法扩展,也不是灵活或动态的。真正做到这一点的方法是在两台路由器上运行通用路由协议,以便 R_2 自动接收从 R_1 到 VLAN 10 的路由。