需求描述
RT1作为DHCP服务器
创建两个全局地址池:
192.168.10.0/24
192.168.20.0/24
RT1和RT3属于VLAN 10
RT2属于VLAN 20
在交换机上配置DHCP中继,确保RT2和RT3都能从RT1处获取IP地址
1、交换机上创建两个vlan
vlan 10
vlan 20
2、给vlan 配置上IP地址,作为RT1、RT2、RT3的网关
interface Vlan-interface10
ip address 192.168.10.1 255.255.255.0
#
interface Vlan-interface20
ip address 192.168.20.1 255.255.255.0
3、把接口加入相应的VLAN
interface Ethernet0/4/0
port link-mode bridge
port access vlan 10
#
interface Ethernet0/4/1
port link-mode bridge
port access vlan 10
#
interface Ethernet0/4/2
port link-mode bridge
port access vlan 20
#
4、配置RT1,配置IP地址和默认网关
[RT1]int gi 0/0/0
[RT1-GigabitEthernet0/0/0]ip add 192.168.10.2 255.255.255.0
[RT1-GigabitEthernet0/0/0]qu
[RT1]ip route-static 0.0.0.0 0.0.0.0 192.168.10.1
5、配置两个全局地址池
启动DHCP服务
dhcp enable
第一个全局地址池
#
dhcp server ip-pool vlan10
network 192.168.10.0 mask 255.255.255.0
gateway-list 192.168.10.1
dns-list 202.106.0.20 8.8.8.8
#
第二个全局地址池
#
dhcp server ip-pool vlan20
network 192.168.20.0 mask 255.255.255.0
gateway-list 192.168.20.1
dns-list 114.123.11.8 202.106.0.20
#
6、配置DHCP中继
中继配置服务端的出口方向,客户端的入口方向
如果客户端连接在路由器的Ge-0/0/1口上,则在Ge-0/0/1上做中继
如果客户端连接在属于VLAN 20的接口上,则在VLAN20上做中继
交换机上也开启DHCP
dhcp enable
指定DHCP服务器的地址(192.168.10.2)
dhcp relay server-group 1 ip 192.168.10.2
#
interface Vlan-interface20
ip address 192.168.20.1 255.255.255.0
dhcp select relay
dhcp relay client-detect enable
dhcp relay server-select 1
#
7、客户端配置和验证
ip add dhcp-alloc
dis ip int br