拓扑如下:
1、SW和Router均需开启DHCP enable,以及配置对应的vlan
2、DHCP RELAY信息配置在SW里面
3、DHCP POOL配置在Router里面
4、Router里面需要配置默认路由,网关指向SW的vlan10网关
5、连接dhcp客户端的以太网接口均需配置好vlan模式。
SW配置:
vlan batch 10 20 30
dhcp enable
interface Vlanif10
ip address 12.1.1.1 255.255.255.0
#
interface Vlanif20
ip address 192.168.20.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 12.1.1.2
#
interface Vlanif30
ip address 172.17.30.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 12.1.1.2
interface GigabitEthernet0/0/1
port link-type access
port default vlan 10
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 20
#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 30
#
Router配置:
vlan batch 10 20 30
dhcp enable
#
ip pool vlan20
gateway-list 192.168.20.1
network 192.168.20.0 mask 255.255.255.0
excluded-ip-address 192.168.20.2 192.168.20.100
dns-list 192.168.20.1
#
ip pool vlan30
gateway-list 172.17.30.1
network 172.17.30.0 mask 255.255.255.0
lease day 8 hour 0 minute 0
dns-list 172.17.30.1
#
interface GigabitEthernet0/0/0
ip address 12.1.1.2 255.255.255.0
dhcp select global
#
ip route-static 0.0.0.0 0.0.0.0 12.1.1.1