关于子接口DHCP中继CISCO的问题

网络工程 思科 局域网 dhcp 界面
2022-03-01 09:55:20

在此处输入图像描述

我想让 4 台 PC 获得 DHCP IP 地址 左侧没有问题,但右侧 2 台 PC 无法自动获得 IP。我认为问题是DHCP中继。如何将 ip helper-address 用于 R2 的子接口?

s1

 interface FastEthernet0/1
   switchport mode trunk
 interface FastEthernet0/2
   switchport access vlan 11
   switchport mode access
 interface FastEthernet0/3
   switchport access vlan 10
   switchport mode access

s2

 interface FastEthernet0/1
   switchport mode trunk
 interface FastEthernet0/2
   switchport access vlan 20
   switchport mode access
 interface FastEthernet0/3
   switchport access vlan 30
   switchport mode access

R1-DHCP

1.建筑配置...

Current configuration : 1593 bytes
!
version 15.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
ip dhcp pool Area-1
 network 192.168.11.0 255.255.255.0
 default-router 192.168.11.1
ip dhcp pool Area-2
 network 192.168.10.0 255.255.255.0
 default-router 192.168.10.1
ip dhcp pool Area-3
 network 192.168.20.0 255.255.255.0
 default-router 192.168.20.1
ip dhcp pool Area-4
 network 192.168.30.0 255.255.255.0
 default-router 192.168.30.1
!
!
!
ip cef
no ipv6 cef
!
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface GigabitEthernet0/0/0
 ip address 190.168.50.1 255.255.255.0
 duplex auto
 speed auto
!
interface GigabitEthernet0/0/0.20
 encapsulation dot1Q 20
 ip address 192.168.20.1 255.255.255.0
!
interface GigabitEthernet0/0/0.30
 encapsulation dot1Q 30
 ip address 192.168.30.1 255.255.255.0
!
interface GigabitEthernet0/0/1
 no ip address
 duplex auto
 speed auto
!
interface GigabitEthernet0/0/1.10
 encapsulation dot1Q 10
 ip address 192.168.10.1 255.255.255.0
!
interface GigabitEthernet0/0/1.11
 encapsulation dot1Q 11
 ip address 192.168.11.1 255.255.255.0
!
interface GigabitEthernet0/0/2
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Vlan1
 no ip address
 shutdown
!
router rip
 version 2
 network 192.168.20.0
 network 192.168.30.0
 network 192.168.50.0
 no auto-summary
!
ip classless
ip route 192.168.20.0 255.255.255.0 192.168.50.2 
ip route 192.168.30.0 255.255.255.0 192.168.50.2 
!
ip flow-export version 9
!
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
end

R2

Building configuration...

Current configuration : 1151 bytes
!
version 15.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 GigabitEthernet0/0/0
 ip address 192.168.50.2 255.255.255.0
 ip helper-address 192.168.50.1
 duplex auto
 speed auto
!
interface GigabitEthernet0/0/1
 no ip address
 duplex auto
 speed auto
!
interface GigabitEthernet0/0/1.20
 encapsulation dot1Q 20
 ip address 192.168.20.1 255.255.255.0
 ip helper-address 192.168.50.1
!
interface GigabitEthernet0/0/1.30
 encapsulation dot1Q 30
 ip address 192.168.30.1 255.255.255.0
 ip helper-address 192.168.50.1
!
interface GigabitEthernet0/0/2
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Vlan1
 no ip address
 shutdown
!
router rip
 version 2
 network 192.168.10.0
 network 192.168.11.0
 network 192.168.50.0
 no auto-summary
!
ip classless
ip route 192.168.10.0 255.255.255.0 192.168.50.1 
ip route 192.168.11.0 255.255.255.0 192.168.50.1 
!
ip flow-export version 9
2个回答

这应该通过 R2 进行配置。

ip dhcp pool Area-3
 network 192.168.20.0 255.255.255.0
 default-router 192.168.20.1
ip dhcp pool Area-4
 network 192.168.30.0 255.255.255.0
 default-router 192.168.30.1

一些问题:

  • ip helper-address 192.168.50.2您已将路由器本身添加为 DHCP 服务器。那条线需要走。
  • 没有为 VLAN 30 设置 DHCP 中继。
  • 在每个路由器上为远程网络添加静态路由。事实上,每个路由器只能看到直接连接的网络。缺少路由,其他网络的数据包将被丢弃。
  • 目前,您在 R1/Gig0.0.0(朝向 R2)上有 VLAN 20 和 30 的子接口。这是行不通的,因为 R2 上没有 L2 连接。同时,DHCP 中继不适用于(看似)直接连接的 IP 子网;路由也无法正常工作。您需要删除这些子接口。