第二步:开启路由器DHCP功能
[DHCP]dhcp enable 系统视图下开启路由器DHCP功能
第三步:给路由器接口配置地址,并在接口上启用DHCP功能
[DHCP]interface GigabitEthernet 0/0/0 进入接口视图
[DHCP-GigabitEthernet0/0/0]ip address 192.168.1.254 24接口配置IP地址
注意:接口地址要和网关地址一致
[DHCP-GigabitEthernet0/0/0]dhcp select global 接口下启用基于全局的DHCP
2、基于接口的DHCP
第一步:开启路由器DHCP功能
<Huawei>system-view 进入系统视图
[Huawei]sysname + 名字,如DHCP 给路由命名
第二步:给路由器接口配置地址,并在接口上启用DHCP功能
[DHCP]interface GigabitEthernet 0/0/0 进入接口视图
[DHCP-GigabitEthernet0/0/0]ip address 192.168.1.254 24 给接口配置IP地址和子网掩码
注意:网关地址就是接口地址
[DHCP-GigabitEthernet0/0/0]dhcp select interface 在接口下应用基于接口DHCP功能
[DHCP-GigabitEthernet0/0/0]dhcp sever dns-list 8.8.8.8 设置DNS地址
注意:真实环境下用运营商提供的地址
[DHCP-GigabitEthernet0/0/0]dhcp sever lease day + 天数 设置DHCP租约时间
[DHCP-GigabitEthernet0/0/0]dhcp sever excluded-ip address + 地址 设置保留地址
三、DHCP中继及其配置
1、DHCP中继(dhcp relay)当你的 DHCP 客户端与 DHCP 服务器不在同一个网段的时候,就要用到DHCP
中继。DHCP中继通常配置在DHCP 客户端所在的 VLAN 的 “网关接口”上。
2、配置命令
dhcp relay server-ip 192.168.88.88
3、导致的结果:
将收到的以广播方式发送的 DHCP 报文,转换成“以单播方式”发送的 报文,
然后转发给了指定的 DHCP 服务器;
实验一:DHCP 中继
需求:
PC-1/2/3/4通过 DHCP 获得对应网段的IP地址;
PC-1/2/3/4能够实现互相 ping 通 ;
配置思路:
1、配置 DHCP 客户端
-双击模拟器,选择“DHCP”,然后应用。
2、配置 DHCP 客户端与 DHCP 服务器中间的传输网络
-创建 VLAN
-配置端口模式:access + trunk
-配置 SW1 为 vlan 10 / 200
-配置 SW1 与 DHCP-Server 之间的连通性
SW1/2:
[huawei]vlan batch 10 200 300
交换机1
[SW1]interface gi0/0/1
[SW1-gi0/0/1] port link-type access
[SW1-gi0/0/1] port default vlan 10
[SW1]interface gi0/0/2
[SW1-gi0/0/2] port link-type access
[SW1-gi0/0/2] port default vlan 200
[SW1]interface gi0/0/24
[SW1-gi0/0/24] port link-type trunk
[SW1-gi0/0/24] port trunk allow-pass vlan all
交换机2
[SW2]interface gi0/0/3
[SW2-gi0/0/3] port link-type access
[SW2-gi0/0/3] port default vlan 10
[SW2]interface gi0/0/4
[SW2-gi0/0/4] port link-type access
[SW2-gi0/0/4] port default vlan 200
[SW2]interface gi0/0/1
[SW2-gi0/0/24] port link-type trunk
[SW2-gi0/0/24] port trunk allow-pass vlan all
交换机1
[SW1]interface vlan 10
[SW1-vlan10] ip address 192.168.10.254 255.255.255.0
[SW1]interface vlan 200
[SW1-vlan200] ip address 192.168.200.254 255.255.255.0
[SW1]interface gi0/0/3
[SW1-gi0/0/3] port link-type access
[SW1-gi0/0/3] port default vlan 300
[SW1]interface vlan 300
[SW1-vlan300] ip address 192.168.88.66 255.255.255.0
3、配置 DHCP 服务器
-为 DHCP-Server 配置IP地址;
-配置 DHCP 地址池 (vlan-10 / vlan-200)
-配置接收 DHCP 报文的接口的 dhcp 地址池选择方式
-开启 DHCP 功能
-配置一个默认路由指向 SW1
[DHCP-Server] interface gi0/0/0
[DHCP-Server-gi0/0/0] ip address 192.168.88.88 255.255.255.0
[DHCP-Server] ip pool VLAN-10
[DHCP-Server-pool-vlan-10] network 192.168.10.0 mask 255.255.255.0
[DHCP-Server-pool-vlan-10] gateway-list 192.168.10.254
[DHCP-Server-pool-vlan-10] dns-list 8.8.8.8
[DHCP-Server] ip pool VLAN-200
[DHCP-Server-pool-vlan-200] network 192.168.200.0 mask 255.255.255.0
[DHCP-Server-pool-vlan-200] gateway-list 192.168.200.254
[DHCP-Server-pool-vlan-200] dns-list 8.8.8.8
[DHCP-Server] dhcp enable
[DHCP-Server] interface gi0/0/0
[DHCP-Server-gi0/0/0]dhcp select global
4、配置 vlan10 与 vlan200 的网关为 DHCP 中继;
[SW1] dhcp enable
[SW1]interface vlanif 10
[SW1-vlanif10] dhcp select relay
[SW1-vlanif10] dhcp relay server-ip 192.168.88.88
[SW1]interface vlanif 200
[SW1-vlanif200] dhcp select relay
[SW1-vlanif200] dhcp relay server-ip 192.168.88.88
5、配置 DHCP-Server 的返回路由
[DHCP-Server] ip route-static 0.0.0.0 0.0.0.0 192.168.88.66
6、验证与测试
pc-1/2/3/4 : ipconfig
PC-1:
ping 192.168.10.3 | ping 192.168.200.2/4
实验二:DHCP 中继
要求:DHCP Client成功获取到IP地址;
配置思路:
1、配置DHCP客户端;
2、配置 SW1 ,确保 DHCP客户端与网关之间的正确连通性;
3、配置 DHCP 服务器;
4、配置 网关为 DHCP 中继;
5、验证与测试
配置步骤:
1、配置 DHCP 客户端;
2、配置 SW1
[SW1]vlan 10
[SW1]interface gi0/0/1
[SW1-gi0/0/1] port link-type access
[SW1-gi0/0/1] port default vlan 10
[SW1]interface gi0/0/2
[SW1-gi0/0/2] port link-type access
[SW1-gi0/0/2] port default vlan 10
配置网关:
[Gateway]interface gi0/0/0
[Gateway-gi0/0/0] ip address 192.168.10.254 255.255.255.0
[Gateway]interface gi0/0/1
[Gateway-gi0/0/1] ip address 192.168.12.1 255.255.255.0
3、配置 DHCP服务器
[DHCP-Server] interface gi0/0/1
[DHCP-Server-gi0/0/1] ip address 192.168.12.2 255.255.255.0
[DHCP-Server] ip pool VLAN-10
[DHCP-Server-pool-vlan-10] network 192.168.10.0 mask 255.255.255.0
[DHCP-Server-pool-vlan-10] gateway-list 192.168.10.254
[DHCP-Server-pool-vlan-10] dns-list 8.8.8.8
[DHCP-Server] dhcp enable
[DHCP-Server] interface gi0/0/1
[DHCP-Server-gi0/0/1] dhcp select global
[DHCP-Server] ip route-static 0.0.0.0 0.0.0.0 192.168.12.1
4、配置 网关为 DHCP 中继
[Gateway] dhcp enable
[Gateway] interface gi0/0/0
[Gateway-gi0/0/0] dhcp select relay
[Gateway-gi0/0/0] dhcp relay server-ip 192.168.12.2
5、验证与测试
DHCP-Client :
ipconfig -> 可以看到相应的IP地址,就成功了。
原文地址:http://blog.51cto.com/13700952/2116372