ensp做实验PC无法获得IP地址,如何解决?

配置如下——
PC:设置为DHCP客户端
SW1:
undo terminal monitor
system-view
sysname SW1
vlan batch 10 20 30 40 66
interface gi0/0/12
port link-type trunk
port trunk allwo-pass vlan all
quit
interface gi0/0/1
port link-type access
prot default vlan 10
quit
interface gi0/0/2
port link-type access
port default vlan 20
quit

SW2:
undo terminal monitor
system-view
sysname SW2
vlan batch 10 20 30 40 66
interface gi0/0/12
port link-type trunk
port trunk allwo-pass vlan all
quit
interface gi0/0/3
port link-type access
prot default vlan 10
quit
interface gi0/0/4
port link-type access
port default vlan 30
quit

SW3:
undo terminal monitor
system-view
sysname SW3
vlan batch 10 20 30 40 66
interface gi0/0/12
port link-type trunk
port trunk allwo-pass vlan all
quit
interface gi0/0/5
port link-type access
prot default vlan 20
quit
interface gi0/0/6
port link-type access
port default vlan 40
quit

SW4:
undo terminal monitor
system-view
sysname SW4
vlan batch 10 20 30 40 66
interface gi0/0/12
port link-type trunk
port trunk allwo-pass vlan all
quit
interface gi0/0/23
port link-type trunk
port trunk allwo-pass vlan all
quit
interface gi0/0/7
port link-type access
prot default vlan 40
quit
interface gi0/0/8
port link-type access
port default vlan 30
quit

SW10:
undo terminal monitor
system-view
sysname SW10

vlan batch 10 20 30 40 66

interface gi0/0/23
port link-type trunk
port trunk allwo-pass vlan all
quit

interface gi0/0/24
port link-type trunk
port trunk allwo-pass vlan all
quit

interface gi0/0/6
port link-type access
prot default vlan 66
quit

SW6:
undo terminal monitor
system-view
sysname SW6
vlan batch 10 20 30 40 66
interface gi0/0/1
port link-type trunk
port trunk allwo-pass vlan all
quit
interface gi0/0/2
port link-type trunk
port trunk allwo-pass vlan all
quit
interface gi0/0/3
port link-type trunk
port trunk allwo-pass vlan all
quit
interface gi0/0/4
port link-type trunk
port trunk allwo-pass vlan all
quit


DHCP 服务器:
undo terminal monitor
system-view
sysname DHCP
interface gi0/0/0
ip address 192.168.66.1 24
quit

dhcp enable

ip pool VLAN10
network 192.168.10.0 mask 24
gateway-list 192.168.10.254
dns-list 8.8.8.8
quit

ip pool VLAN20
network 192.168.20.0 mask 24
gateway-list 192.168.20.254
dns-list 8.8.8.8
quit

ip pool VLAN30
network 192.168.30.0 mask 24
gateway-list 192.168.30.254
dns-list 8.8.8.8
quit

ip pool VLAN40
network 192.168.40.0 mask 24
gateway-list 192.168.40.254
dns-list 8.8.8.8
quit

interface gi0/0/0
dhcp select global
quit

ip route-static 0.0.0.0 0 192.168.66.254

同时,在SW6上配置 vlan 66 的网关IP地址:

SW6:
interface vlanif 66
ip address 192.168.66.254 24
quit


@配置 DHCP 中继

SW6:
dhcp enable
interface vlanif 10
ip address 192.168.10.254 24
dhcp select relay
dhcp relay server-ip 192.168.66.1
quit

interface vlanif 20
ip address 192.168.20.254 24
dhcp select relay
dhcp relay server-ip 192.168.66.1
quit

interface vlanif 30
ip address 192.168.30.254 24
dhcp select relay
dhcp relay server-ip 192.168.66.1
quit

interface vlanif 40
ip address 192.168.30.254 24
dhcp select relay
dhcp relay server-ip 192.168.66.1
quit
此时,PC就可以自动获取IP地址了。

img

img

看配置是没问题,给pc一个固定ip和网关,看看能否ping通dhcp服务器,如果能ping通就是dhcp设置的问题,如果ping不通就是网络问题,是不是ping没设置自动获取地址