PC 无法 ping 切换

网络工程 思科 数据包追踪器
2021-07-13 20:31:15

我正在尝试通过 PT 连接几台 PC,混合使用 VLAN 和物理连接。我已设法 ping 2 台不同的 PC,但无法 ping 交换机、路由器或任何子路由。

这是IP地址的详细信息

192.168.50.15
255.255.255.0
192.168.10.1

这是交换机 B 上端口的设置

Using 2764 bytes
!
version 12.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Switch
!
!
spanning-tree mode pvst
spanning-tree extend system-id
!
interface FastEthernet0/1
switchport access vlan 50
switchport trunk allowed vlan 1-99
switchport mode trunk
!
interface FastEthernet0/2
switchport access vlan 50
switchport mode access

(这与 Fa0/12 相同)

interface FastEthernet0/13
switchport access vlan 80
switchport mode access

(这对于 24 之前的所有端口都是相同的)

interface GigabitEthernet0/1
switchport trunk allowed vlan 1-99
switchport mode trunk
!
interface GigabitEthernet0/2
switchport access vlan 32
switchport trunk allowed vlan 1-99
switchport mode trunk
!
interface Vlan1
ip address 192.168.70.1 255.255.255.0
!
interface Vlan50
mac-address 0002.4a18.6202
ip address 192.168.50.1 255.255.255.0
!
interface Vlan99
mac-address 0002.4a18.6203
ip address 192.168.99.2 255.255.255.0
!
ip default-gateway 192.168.10.1
!
!
line con 0
!
line vty 0 4
login
line vty 5 15
login
!
!
end

这是交换机 A 上端口的设置

Building configuration...

Current configuration : 2762 bytes
!
version 12.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Switch
!
!
!
!
!
spanning-tree mode pvst
spanning-tree extend system-id
!
interface FastEthernet0/1
switchport access vlan 50
switchport trunk allowed vlan 1-99
switchport mode trunk
!   
interface FastEthernet0/2
switchport access vlan 50
switchport mode access

(这与 fa0/12 相同)

interface FastEthernet0/13
switchport access vlan 80
switchport mode access

(这对所有端口都相同,直到 24)

interface GigabitEthernet0/1
switchport trunk allowed vlan 1-99
switchport mode trunk
!
interface GigabitEthernet0/2
switchport access vlan 32
switchport trunk allowed vlan 1-99
switchport mode trunk
!
interface Vlan1
ip address 192.168.1.1 255.255.255.0
!
!
interface Vlan50
mac-address 0001.64db.c002
ip address 192.168.50.1 255.255.255.0
!
interface Vlan99
mac-address 0001.64db.c003
ip address 192.168.99.1 255.255.255.0
!
ip default-gateway 192.168.10.1
!
!
line con 0
!
line vty 0 4
login
line vty 5 15
login
!
!
!
!
end

这是路由器的详细信息

Current configuration : 1289 bytes
!
version 15.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
ip dhcp pool SERVICEPOOL
network 192.168.50.0 255.255.255.0
default-router 192.168.10.1
ip dhcp pool STUDENTPOOL
dns-server 8.8.8.8
domain-name STUDENTPOOL
ip dhcp pool ADMINPOOL
network 192.168.80.0 255.255.255.0
default-router 192.168.10.1
dns-server 8.8.8.8
!    
!
no ip cef
no ipv6 cef
!
!
!
!
license udi pid CISCO2901/K9 sn FTX1524S0XS
!
!
!
!
!
spanning-tree mode pvst
!
!
!
interface GigabitEthernet0/0
no ip address
duplex auto
speed auto
shutdown
!
interface GigabitEthernet0/1
ip address 192.168.10.1 255.255.255.0
duplex auto
speed auto
!
interface GigabitEthernet0/1.5
no ip address
!
interface GigabitEthernet0/1.50
encapsulation dot1Q 50
ip address 192.168.50.1 255.255.255.0
!
interface GigabitEthernet0/1.80
encapsulation dot1Q 80
ip address 192.168.89.254 255.255.255.0
!
interface Serial0/0/0
no ip address
clock rate 2000000
shutdown
!
interface Serial0/0/1
no ip address
clock rate 2000000
shutdown
!
interface Vlan1
no ip address
shutdown
!
ip classless
!
ip flow-export version 9
!
!
!
no cdp run
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
login
!
end

这是网络图

网络图

我确实设法找到了原始问题的一部分的解决方案,但我对其余部分感到困惑。

提前致谢

2个回答

如果 PC 配置就像我认为的那样:192.168.50.15 <- pc ip 地址 255.255.255.0 <- 掩码 192.168.10.1 <- 默认网关

然后是错误的,因为您的网关在不同的子网中。默认网关应与计算机位于同一子网中,因此在这种情况下网关可能位于 192.168.50.1。现在您应该可以 ping 路由器有关交换机的信息:

如果您的交换机是第 2 层设备(不是 L3)并且管理 vlan 的地址与您的 PC 不同,那么交换机应该设置 ip default-gateway,还有您在 vlan 接口上设置的 L2 交换机 ip 地址,因为您无法在正常情况下设置 ip 地址L2 交换机上的物理接口。

您有一些严重的配置问题。

看起来你有一些解决问题。

转变:

interface Vlan1
 ip address 192.168.1.1 255.255.255.0 <- ##### Does not match network of router interface GigabitEthernet0/1 #####
!
interface Vlan50
 mac-address 0001.64db.c002
 ip address 192.168.50.1 255.255.255.0 <- ##### Duplicate of router interface GigabitEthernet0/1.50 #####
!
interface Vlan99
 mac-address 0001.64db.c003
 ip address 192.168.99.1 255.255.255.0 <- ##### Does not exist on router, so isolated and cannot reach any other network #####
!
ip default-gateway 192.168.10.1 <- ##### the switch does not know how to reach this network #####
!

路由器:

interface GigabitEthernet0/1
ip address 192.168.10.1 255.255.255.0 
duplex auto
speed auto
!
interface GigabitEthernet0/1.5 <- ##### Useless and should be removed #####
no ip address
!
interface GigabitEthernet0/1.50
encapsulation dot1Q 50
ip address 192.168.50.1 255.255.255.0 <- ##### Duplicate of switch interface Vlan50 #####
!
interface GigabitEthernet0/1.80
encapsulation dot1Q 80
ip address 192.168.89.254 255.255.255.0<- ##### Does not match the DHCP pool network #####
!

如果您使用第 2 层交换机,则只需要一个 SVI(用于交换机管理)。删除除 VLAN 1 之外的所有 SVI。可能类似于:

开关A:

interface Vlan1
 ip address 192.168.10.2 255.255.255.0
!

开关B:

interface Vlan1
 ip address 192.168.10.3 255.255.255.0
!

您还想使用 globalvlan命令在交换机上创建 VLAN ,您可以选择为它们命名。您不需要对 VLAN 1 执行此操作,只需对要使用的任何其他 VLAN 执行此操作。根据路由器的定义,它看起来像这样:

vlan 50
 name <VLAN name> ! This line is optional, and VLAN names cannot contain spaces
 exit
!
vlan80
 name <VLAN name, no spaces> ! This line is optional, and VLAN names cannot contain spaces
 exit
!

此外,您的 DHCP 池有一些问题:

ip dhcp pool SERVICEPOOL
network 192.168.50.0 255.255.255.0
default-router 192.168.10.1 <- ##### The default gateway for a network must be an address on the network, in this case the router VLAN 50 address of 192.168.50.1 #####
ip dhcp pool STUDENTPOOL
dns-server 8.8.8.8
domain-name STUDENTPOOL
ip dhcp pool ADMINPOOL
network 192.168.80.0 255.255.255.0 <- ##### Does not match the router network for VLAN 80 of 192.168.89.0 #####
default-router 192.168.10.1 <- ##### The default gateway for a network must be an address on the network, in this case the router VLAN 80 address of 192.168.89.254 #####
dns-server 8.8.8.8
!