DHCP

DHCP

  1. 用于终端设备自动获取IP地址、子网掩码、网关地址、DNS、租约时间等信息。
  2. 在cisco设备上默认IP地址租约时间是1天,终端设备在到期之前要续约,不然到期就会被收回。
  3. 终端设备需要提交Username、MAC地址、Client-ID这几种中的一个,来获取地址信息。
  4. DHCP服务收到用户信息,会从IP地址池中选一个地址发给终端设备。

DHCP的过程

  1. 终端设备使用广播地址发起DHCP请求
  2. DHCP服务器收到请求后用广播回复将要分配的地址信息
  3. 终端设备收到后确定地址信息
  4. DHCP服务器收到确认后,正式回复地址信息发放信息

DHCP配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
ip dhcp excluded-address 192.168.1.1 192.168.1.99
# 这个范围内的IP地址不分配
ip dhcp excluded-address 192.168.1.201 192.168.1.254
ip dhcp pool cisco
network 192.168.1.0 255.255.255.0
default-router 192.168.1.6
dns-server 36.36.36.3
R6#sh ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
192.168.1.100 0063.6973.636f.2d61. Dec 26 1990 11:20 PM Automatic
6162.622e.6363.3030.
2e30.3430.302d.4574.
302f.30
192.168.1.101 0063.6973.636f.2d61. Dec 26 1990 11:26 PM Automatic
6162.622e.6363.3030.
2e30.3530.302d.4574.
302f.30

客户端获取IP地址

1
2
3
int e0/0
ip add dhcp
no sh

DHCP静态分配IP地址

  • dhcp服务器在知道对方的Client-ID、MAC地址或Username的情况下,可以指定分配的IP地址

首先获取Clinet-ID

清空现有的DHCP绑定池

clear ip dhcp bind *

进行如下配置

1
2
3
4
5
6
7
8
9
10
ip dhcp pool R4
host 192.168.1.4 255.255.255.0
client-identifier 0063.6973.636f.2d61.6162.622e.6363.3030.2e30.3430.302d.4574.302f.30
default-router 192.168.1.6
dns-server 36.36.36.3
ip dhcp pool R5
host 192.168.1.5 255.255.255.0
client-identifier 0063.6973.636f.2d61.6162.622e.6363.3030.2e30.3530.302d.4574.302f.30
default-router 192.168.1.6
dns-server 36.36.36.3

最后要记得重启客户端的网卡

DHCP中继

  • 为了让多个局域网可以集中管理,集中分配IP地址,有时候只会设置一台DHCP服务器,所有的设备都从这个设备上获取IP

实验拓扑

img

实验需求

  • R4和R5模拟终端设备,R1,R2,R3运行ospf,R2是dhcp给终端设备分配IP地址
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
R1
interface Ethernet0/0
ip address 192.168.14.1 255.255.255.0
ip helper-address 192.168.12.2
ip ospf 1 area 0

interface Ethernet0/1
ip address 192.168.12.1 255.255.255.0
ip ospf 1 area 0
==============================
R2
ip dhcp pool 14
network 192.168.14.0 255.255.255.0
default-router 192.168.14.1

ip dhcp pool 35
network 192.168.35.0 255.255.255.0
default-router 192.168.35.3

interface Loopback0
ip address 2.2.2.2 255.255.255.0
ip ospf 1 area 0

interface Ethernet0/0
ip address 192.168.12.2 255.255.255.0
ip ospf 1 area 0

interface Ethernet0/1
ip address 192.168.23.2 255.255.255.0
ip ospf 1 area 0
==============================
R3
interface Ethernet0/0
ip address 192.168.23.3 255.255.255.0
ip ospf 1 area 0

interface Ethernet0/1
ip address 192.168.35.3 255.255.255.0
ip helper-address 2.2.2.2
ip ospf 1 area 0
==============================
R4
interface Ethernet0/0
ip address dhcp
==============================
R5
interface Ethernet0/0
ip address dhcp

寒假作业

TCP负载均衡.pdf

注意!上面那个pdf的答案有错误,请自己动脑筋解决!

评论
加载中,最新评论有1分钟缓存...