如何从 L3 交换机 ping 路由器

网络工程 路由 转变 网络访问 路线
2022-02-12 02:23:27

我被困在那个交换机不能ping路由器和路由器不能ping交换机。如何解决?

我尝试了很多变种,但它们对我没有帮助

实际上路由器必须做静态路由,我正在尝试这样做,但这对我没有帮助

我知道这里的某些配置很糟糕,实际上是在那个连接的交换机上,但我正在学习。图片

在此处输入图像描述

L3 开关显示运行代码

interface FastEthernet0/1
 switchport access vlan 12
 switchport trunk allowed vlan 2-11
 switchport trunk encapsulation dot1q
 switchport mode trunk
 switchport nonegotiate
!
interface FastEthernet0/2
 switchport access vlan 2
 switchport mode access
 switchport nonegotiate
!
interface FastEthernet0/3
 switchport access vlan 3
 switchport mode access
 switchport nonegotiate
!
interface FastEthernet0/4
 switchport access vlan 4
 switchport mode access
 switchport nonegotiate
!
interface FastEthernet0/5
 switchport access vlan 5
 switchport mode access
 switchport nonegotiate
!
interface FastEthernet0/6
 switchport access vlan 6
 switchport mode access
 switchport nonegotiate
!
interface FastEthernet0/7
 switchport access vlan 7
 switchport mode access
 switchport nonegotiate
!
interface FastEthernet0/8
 switchport access vlan 8
 switchport mode access
 switchport nonegotiate
!
interface FastEthernet0/9
 switchport access vlan 9
 switchport mode access
 switchport nonegotiate
!
interface FastEthernet0/10
 switchport access vlan 10
 switchport mode access
 switchport nonegotiate
!
interface FastEthernet0/11
 switchport access vlan 11
 switchport mode access
 switchport nonegotiate
!
interface FastEthernet0/12
!
interface FastEthernet0/13
!
interface FastEthernet0/14
!
interface FastEthernet0/15
!
interface FastEthernet0/16
!
interface FastEthernet0/17
!
interface FastEthernet0/18
!
interface FastEthernet0/19
!
interface FastEthernet0/20
!
interface FastEthernet0/21
!
interface FastEthernet0/22
!
interface FastEthernet0/23
!
interface FastEthernet0/24
!
interface GigabitEthernet0/1
!
interface GigabitEthernet0/2
!
interface Vlan1
 no ip address
 shutdown
!
interface Vlan2
 mac-address 000a.41cd.4e01
 ip address 192.168.0.1 255.255.255.248
!
interface Vlan3
 mac-address 000a.41cd.4e02
 ip address 192.168.0.9 255.255.255.248
!
interface Vlan4
 mac-address 000a.41cd.4e03
 ip address 192.168.0.17 255.255.255.248
!
interface Vlan5
 mac-address 000a.41cd.4e04
 ip address 192.168.0.25 255.255.255.248
!
interface Vlan6
 mac-address 000a.41cd.4e05
 ip address 192.168.0.33 255.255.255.248
!
interface Vlan7
 mac-address 000a.41cd.4e06
 ip address 192.168.0.41 255.255.255.248
!
interface Vlan8
 mac-address 000a.41cd.4e07
 ip address 192.168.0.49 255.255.255.248
!
interface Vlan9
 mac-address 000a.41cd.4e08
 ip address 192.168.0.57 255.255.255.248
!
interface Vlan10
 mac-address 000a.41cd.4e09
 ip address 192.168.0.65 255.255.255.248
!
interface Vlan11
 mac-address 000a.41cd.4e0a
 ip address 192.168.0.73 255.255.255.248
!
interface Vlan12
 mac-address 000a.41cd.4e0b
 ip address 192.168.0.82 255.255.255.248
!
router rip
!
ip classless
ip route 192.168.0.0 255.255.255.0 192.168.0.0 

路由器显示运行代码

interface GigabitEthernet0/0
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface GigabitEthernet0/1
 ip address 196.168.0.81 255.255.255.248
 duplex auto
 speed auto
!
interface GigabitEthernet0/2
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Vlan1
 no ip address
 shutdown
!
router rip
!
ip classless

路由器显示ip路由

 Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
           N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
           E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
           i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
           * - candidate default, U - per-user static route, o - ODR
           P - periodic downloaded static route

    Gateway of last resort is not set

         196.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
    C       196.168.0.80/29 is directly connected, GigabitEthernet0/1
    L       196.168.0.81/32 is directly connected, GigabitEthernet0/1
2个回答

我假设您想将交换机接口 FastEthernet0/1 连接到路由器接口 GigabitEthernet0/1,对吗?

如果要将流量从 vlan 2-11 路由到路由器,您必须:

  • 删除接口Vlan12
  • 直接在接口 FastEthernet0/1 上配置 IP

接口 FastEthernet0/1 ip 地址 192.168.0.82 255.255.255.248

现在应该可以从路由器 ping 交换机,反之亦然

您需要配置单臂路由器。

interface FastEthernet0/1
 switchport trunk allowed vlan 2-11
 switchport trunk encapsulation dot1q
 switchport mode trunk
 switchport nonegotiate

Router(config)# interface g0/0.20
Router(config-subif)# encapsulation dot1q 20
Router(config-subif)# ip add x.x.x.x x.x.x.x
Router(config-subif)# interface g0/0.30
Router(config-subif)# encapsulation dot1q 30
Router(config-subif)# ip add x.x.x.y x.x.x.x
....(add remanining vlan 4,5,6...)
Router(config)# interface g0/0
Router(config-if)# no shut