eNSP——DHCP

DHCP(Dynamic Host Configuration Protocol:动态主机配置协议)

基于UDP封装,68:dhcp客户端→67:dhcp服务器


目录

DHCP基本工作过程

接口模式地址池分配

全局模式地址池分配

DHCP server配置

DHCP中继

DHCP server配置

R3配置

R2配置 

S1配置

总结:

//打TODO,dhcp snooping下次写


DHCP基本工作过程

eNSP——DHCP_第1张图片

eNSP——DHCP_第2张图片

接口模式地址池分配

eNSP——DHCP_第3张图片

DHCP server配置 

[DHCP sever]dhcp enable    //全局开启dhcp
[DHCP sever]int g0/0/0
[DHCP sever-GigabitEthernet0/0/0]ip add 192.168.1.254 24
[DHCP sever-GigabitEthernet0/0/0]dhcp select interface        //配置为接口模式
[DHCP sever-GigabitEthernet0/0/0]dhcp server dns-list 8.8.8.8    //配置dns

测试:pc1是否能使用dhcp获取ip地址

eNSP——DHCP_第4张图片

成功!! 

全局模式地址池分配

eNSP——DHCP_第5张图片

DHCP server配置

[DHCP server]ip pool common
[DHCP server-ip-pool-common]network 192.168.1.0 mask 24
[DHCP server-ip-pool-common]gateway-list 192.168.1.254
[DHCP server-ip-pool-common]dns-list 8.8.8.8
[DHCP server-ip-pool-common]excluded-ip-address 192.168.1.240 192.168.1.253

测试:pc3能否获取ip地址

eNSP——DHCP_第6张图片

成功!!

DHCP中继

eNSP——DHCP_第7张图片

注:

左边是路由器作为中继,右边是三层交换机作为中继

DHCP server配置

[DHCP server]ip pool common        //配置common地址池
[DHCP server-ip-pool-common]gateway-list 192.168.1.254 
[DHCP server-ip-pool-common]network 192.168.1.0 mask 255.255.255.0 
[DHCP server-ip-pool-common]excluded-ip-address 192.168.1.240 192.168.1.253 
[DHCP server-ip-pool-common]dns-list 8.8.8.8 
[DHCP server-ip-pool-common]ip pool vlan2        //配置vlan2地址池
[DHCP server-ip-pool-vlan2]gateway-list 192.168.2.254 
[DHCP server-ip-pool-vlan2]network 192.168.2.0 mask 255.255.255.0 
[DHCP server-ip-pool-vlan2]dns-list 8.8.8.8 
[DHCP server-ip-pool-vlan2]ip pool vlan3        //配置vlan3地址池
[DHCP server-ip-pool-vlan3]gateway-list 192.168.3.254 
[DHCP server-ip-pool-vlan3]network 192.168.3.0 mask 255.255.255.0 
[DHCP server-ip-pool-vlan3]dns-list 8.8.8.8 
[DHCP server-ip-pool-vlan3]qu
[DHCP server]int g0/0/0
[DHCP server-GigabitEthernet0/0/0]ip address 10.1.1.1 30
[DHCP server-GigabitEthernet0/0/0]dhcp select global     //接口应用全局模式地址池
[DHCP server-GigabitEthernet0/0/0]qu
[DHCP server]ip route-static 0.0.0.0 0 10.1.1.2    //写入一条默认路由

R3配置

[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 192.168.200.1 30
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 192.168.100.1 30
[R3-GigabitEthernet0/0/1]int g0/0/2
[R3-GigabitEthernet0/0/2]ip add 10.1.1.2 30
[R3]ip route-static 192.168.1.0 255.255.255.0 192.168.100.2    //写入一条指向PC1网段的路由
[R3]ip route-static 192.168.2.0 255.255.255.0 192.168.200.2    //写入一条指向PC2网段的路由
[R3]ip route-static 192.168.3.0 255.255.255.0 192.168.200.2    //写入一条指向PC3网段的路由

R2配置 

[R2]dhcp enable
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 192.168.100.2 30
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.1.254 24
[R2-GigabitEthernet0/0/1]dhcp select relay        //接口开启dhcp中继服务
[R2-GigabitEthernet0/0/1]dhcp relay server-ip 192.168.100.1  //中继地址指向server接口地址
[R2-GigabitEthernet0/0/1]qu
[R2]ip route-static 10.1.1.0 255.255.255.252 192.168.100.1  //写入一条指向server的路由

S1配置

[S1]vlan batch 2 3 200
[S1]int vlan 200
[S1-Vlanif200]ip add 192.168.200.2 30
[S1-Vlanif200]int vlan 2
[S1-Vlanif2]ip add 192.168.2.254 24
[S1-Vlanif2]int vlan 3
[S1-Vlanif3]ip add 192.168.3.254 24
[S1-Vlanif3]int g0/0/1
[S1-GigabitEthernet0/0/1]p l t
[S1-GigabitEthernet0/0/1]p l a
[S1-GigabitEthernet0/0/1]p d v 200
[S1-GigabitEthernet0/0/1]int g0/0/2
[S1-GigabitEthernet0/0/2]p l a
[S1-GigabitEthernet0/0/2]p d v 2
[S1-GigabitEthernet0/0/2]int g0/0/3
[S1-GigabitEthernet0/0/3]p l a
[S1-GigabitEthernet0/0/3]p d v 3
[S1-GigabitEthernet0/0/3]qu
[S1]dhcp enable
[S1]int vlan 2
[S1-Vlanif2]dhcp select  relay	
[S1-Vlanif2]dhcp relay server-ip 192.168.200.1
[S1-Vlanif2]int vlan 3
[S1-Vlanif3]dhcp select relay
[S1-Vlanif3]dhcp relay server-ip 192.168.200.1
[S1-Vlanif3]qu
[S1]ip route-static 10.1.1.0 255.255.255.252 192.168.200.1  //写入一条指向server的路由

测试1:PC1能否通过dhcp获取到ip地址

eNSP——DHCP_第8张图片

成功!!

测试2:PC2、PC3能否通过dhcp获取到ip地址

eNSP——DHCP_第9张图片

eNSP——DHCP_第10张图片

成功!!

总结:

        1. <重点> dhcp中继实现的前提是中继设备和dhcp服务器在网络上要畅通!!!(这就是为什么要在设备中打上路由的原因)<重点>

        2. dhcp中继的dhcp select relaydhcp relay server-ip命令只敲一次(在同一个请求dhcp的网段),并在dhcp请求流量的入方向敲(例如:pc1网段流量在R2的g0/0/1口敲而不是在g0/0/0,pc2网段流量在S1的vlanif2口敲而不是在g0/0/2或g0/0/3......)

        3. dhcp中继与dhcp服务器之间若还有路由器等网络设备,不再需要额外地敲有关dhcp命令

//打TODO,dhcp snooping下次写

你可能感兴趣的:(华为eNSP,网络)