320、基于接口的DHCP:
配置:
#
interface Ethernet0/0/0
?ip address 192.168.1.1 255.255.255.0
?dhcp select interface
?dhcp server dns-list 8.8.8.8
#
tips:基于接口的DHCP,默认分配的IP地址与接口是同一网段,网关默认就是接口的IP地址;
321、DHCP relay,DHCP的(中继):
实验;
实验topo:
实验步骤:
分别将将SW2、SW3、的上联口打trunk,下联口打access:
SW2:
#
interface MEth0/0/1
#
interface Ethernet0/0/1
?port link-type trunk
?port trunk allow-pass vlan 10
#
interface Ethernet0/0/2
?port link-type access
?port default vlan 10
#
SW3:
#
interface MEth0/0/1
#
interface Ethernet0/0/1
?port link-type trunk
?port trunk allow-pass vlan 20
#
interface Ethernet0/0/2
?port link-type access
?port default vlan 20
#
将SW1 的G0/0/2-3打trunk,G0/0/0打access,并且分别配置VLAN 10 、VLAN 20 、VLAN 800 ,分别配置上IP地址:
#
interface Vlanif10
?ip address 192.168.10.1 255.255.255.0
#
interface Vlanif20
?ip address 192.168.20.1 255.255.255.0
#
interface Vlanif800
?ip address 192.168.254.1 255.255.255.0
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
?port link-type access
?port default vlan 800
#
interface GigabitEthernet0/0/2
?port link-type trunk
?port trunk allow-pass vlan 10
#
interface GigabitEthernet0/0/3
?port link-type trunk
?port trunk allow-pass vlan 20
#
利用静态路由模拟DHCP服务器的网关:
#
ip route-static 0.0.0.0 0.0.0.0 192.168.254.1
#
322、配置DHCP relay:
?
①在DHCP服务器上面配置两个地址池,分别用来给VLAN10 、VLAN20 分配地址:
VLAN10 的地址池:
#
ip pool vlan10
?gateway-list 192.168.10.1
?network 192.168.10.0 mask 255.255.255.0
?dns-list 8.8.8.8
#
VLAN 20 的地址池:
#
ip pool vlan20
?gateway-list 192.168.20.1
?network 192.168.20.0 mask 255.255.255.0
?dns-list 114.114.114.114
#
#
dhcp enable
dhcp select global
#
②将DHCP服务中继至DHCP服务器:
VLAN 10
#
interface Vlanif10
?ip address 192.168.10.1 255.255.255.0
?dhcp select relay
?dhcp relay server-ip 192.168.254.2
#
VLAN20
#
interface Vlanif20
?ip address 192.168.20.1 255.255.255.0
?dhcp select relay
?dhcp relay server-ip 192.168.254.2
#
查看实验结果:
323、DHCP relay的工作原理:
在同一个VLAN之间,客户机发送ARP报文寻找DHCP服务器,但是由于VLAN隔离了广播域,,所以只能由DHCP relay将广播的源IP地址和目的IP地址替换,源IP地址替换成为同VLAN的虚拟地址,目的地址替换陈成为DHCP服务器的IP地址,这样,DHCP请求报文就变成了单播,就可以穿过广播域,当DHCP offer报文回来的时候,给数据包打上tag,传给客户机,客户机就可以获得IP地址;
|