DHCP篇
一、基于接口地址池的DHCP
二、基于全局地址池的DHCP
三、DHCP中继
(1)跨网络简单DHCP中继
(2)跨网络多vlan DHCP中继
一、基于接口地址池的DHCP
目标:
1.DHCP的配置方法
2.基于接口的DHCP
3.DHCP地址租约/不参与自动分配的IP/DNS的配置
实验要求:
公司里面有两个部门:市场部和销售部,两个部门分别接入到两台接入交换机,即S1、S2,两台交换机都接入到路由器R1,并能通过自动获取得到IP地址,要求使用接口DHCP
G0/0/0 | IP:192.168.1.254/24 | PC1 | 自动获取 |
G0/0/1 | IP:192.168.2.254/24 | PC2 | 自动获取 |
配置步骤:
R1:
<Huawei>sys
[Huawei]sysname R1
[R1]dhcp enable
interface GigabitEthernet0/0/0
ip address 192.168.1.254 255.255.255.0
dhcp select interface
dhcp server excluded-ip-address 192.168.1.250 192.168.1.253
dhcp server lease day 2 hour 0 minute 0
dhcp server dns-list 114.114.114.114
interface GigabitEthernet0/0/1
ip address 192.168.2.254 255.255.255.0
dhcp select interface
dhcp server excluded-ip-address 192.168.2.250 192.168.2.253
dhcp server lease day 2 hour 0 minute 0
dhcp server dns-list 114.114.114.114
二、基于全局地址池的DHCP
目标:DHCP全局配置
配置步骤:
R1:
dhcp enable
#
ip pool vlan10
gateway-list 192.168.1.254
network 192.168.1.0 mask 255.255.255.0
excluded-ip-address 192.168.1.200 192.168.1.253
lease day 2 hour 0 minute 0
dns-list 114.114.114.114 61.166.150.123
#
ip pool vlan20
gateway-list 192.168.2.254
network 192.168.2.0 mask 255.255.255.0
excluded-ip-address 192.168.2.200 192.168.2.253
lease day 2 hour 0 minute 0
dns-list 114.114.114.114 61.166.150.123
interface GigabitEthernet0/0/0
ip address 192.168.1.254 255.255.255.0
dhcp select global
#
interface GigabitEthernet0/0/1
ip address 192.168.2.254 255.255.255.0
dhcp select global
三、DHCP中继
目标:
1.什么是DHCP中继
2.DHCP中继配置
1.什么是DHCP中继:
DHCP中继就是在一个网段中没有配置DHCP服务器,通过从其他网段的DHCP服务器中动态获取到本网段的IP地址所采用的一个方式。
解决了DHCP不能跨网段自动获取IP地址的问题
2.DHCP中继配置
(1)跨网络简单DHCP中继实验要求:
1.PC1、PC2自动获取10.1.1.0网段的地址
2.R3为DHCP服务器
配置步骤:
1.R1、R2、R3配置接口地址
R1:
interface Ethernet1/0/1
ip address 10.1.1.254 255.255.255.0
interface GigabitEthernet0/0/0
ip address 200.1.1.2 255.255.255.0
R2:
interface GigabitEthernet0/0/0
ip address 200.1.1.1 255.255.255.0
interface GigabitEthernet0/0/1
ip address 100.1.1.1 255.255.255.0
R3:
interface GigabitEthernet0/0/1
ip address 100.1.1.2 255.255.255.0
2.做路由使得网络互通(可使用rip/ospf/静态路由)
R1:
ospf 1
area 0.0.0.0
network 10.1.1.0 0.0.0.255
network 200.1.1.0 0.0.0.255
R2:
ospf 1
area 0.0.0.0
network 100.1.1.0 0.0.0.255
network 200.1.1.0 0.0.0.255
R3:
ospf 1
area 0.0.0.0
network 100.1.1.0 0.0.0.255
可用dis ip routing-table 来查看宣告的路由
3.R3做DHCP服务配置
R3:
dhcp enable
ip pool vlan10
gateway-list 10.1.1.254
network 10.1.1.0 mask 255.255.255.0
excluded-ip-address 10.1.1.250 10.1.1.253
lease day 2 hour 0 minute 0
dns-list 114.114.114.114 2.2.2.2
interface GigabitEthernet0/0/1
dhcp select global
4.R1配置DHCP中继
dhcp enable
interface Ethernet1/0/1
ip address 10.1.1.254 255.255.255.0
dhcp select relay
dhcp relay server-ip 100.1.1.2
(2)跨网络多vlan DHCP中继实验要求:
1.R3为总公司路由器,在R3上配置了DHCP服务器
2.R1为分公司路由器
3.PC1、PC2分别属于vlan 10 , vlan 20;
4.使PC1,PC2分别能够自动获取到对应vlan的IP地址
配置思路:
1.配置各设备接口地址
2.使S1到R3的网络互通(我使用了ospf+静态路由)
3.R3上配置全局DHCP(见上文)
4.在S1上配置DHCP中继,应用于vlan接口中