当前位置:网站首页>HCIA-R&S自用笔记(23)DHCP
HCIA-R&S自用笔记(23)DHCP
2022-07-26 22:15:00 【筐瓢大师小吕】
DHCP(7/26,64min)
DHCP:Dynamic Host Configure Protocol,动态主机配置协议
UDP封装,服务器为67,客户端为68
动态分析TCP/IP信息(IP地址、子网掩码、默认网关、DNS服务器等)
分配除去的信息有租约(默认一天,86400s)
ipconfig /all能看到租期起始与结束
一般情况下,DHCP服务器位于网关上(不一定)
DHCP系统组成:
| DHCP Client(客户端) | 需要动态获取IP地址的主机 |
| DHCP Server(服务器) | 能提供DHCP功能的服务器或网络设备 |
| DHCP Relay(中继) | 一般为路由器或三层交换机等网络设备 |
搭建拓扑如下:

SW1:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei]int gi0/0/1
[Huawei-GigabitEthernet0/0/1]p l t
[Huawei-GigabitEthernet0/0/1]p t a vlan all
[Huawei-GigabitEthernet0/0/1]qu
[Huawei]int gi0/0/2
[Huawei-GigabitEthernet0/0/2]p l a
[Huawei-GigabitEthernet0/0/2]p d v 10
[Huawei-GigabitEthernet0/0/2]qu
[Huawei]int gi0/0/3
[Huawei-GigabitEthernet0/0/3]p l a
[Huawei-GigabitEthernet0/0/3]p d v 20SW2:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys SW2
[SW2]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW2]int vlan 10
[SW2-Vlanif10]ip add 192.168.10.254 24
[SW2-Vlanif10]qu
[SW2]int vlanif 20
[SW2-Vlanif20]ip add 192.168.20.254 24
[SW2-Vlanif20]qu
[SW2]int gi0/0/1
[SW2-GigabitEthernet0/0/1]p l t
[SW2-GigabitEthernet0/0/1]p t a vlan all
[SW2-GigabitEthernet0/0/1]qu在PC1接口处抓包,注意,PC1、PC2都未配置地址,此时将PC1的地址获取方式改为“DHCP”
如下,抓取到PC的DHCP发现报文(Discover)

DHCP简单配置
SW2:
[SW2]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[SW2]int vlanif 10
[SW2-Vlanif10]dhcp select interface
[SW2-Vlanif10]qu
[SW2]int vlanif 20
[SW2-Vlanif20]dhcp select interface 此时PC1、2都能够获取到地址,网关为Vlanif地址
DHCP数据包

常见为前四种,地址已经租出去,但是有其他主机想要该地址通过ipconfig /release可以抓取到DHCP RELEASE包
Discover

我想要些什么(掩码、网关……)
Offer

我能给你些什么
剩下两种不抓了

为何Request也是广播?
因为可能存在多个DHCP服务器,在广播后可能收到多个DHCP服务器的Offer,主机优先获取第一个Offer
Request广播代表我只从多个Offer中选择一个
DHCP租期

注意,该Request为单播(找房东续租);
主机对应的接入交换机端口未设置快速端口(Portfast)或边缘端口(Edged-Port)的话,底下的主机需要等待stp收敛30s(discarding到forwarding)

若50%时,服务器没有给出回应,则87.5%时则广播(急了)
没租到房子(睡大街)169.254.x.x
自动保留IP
APIPA(Automatic Private IP Addressing)
Window客户端无法从DHCP Server租到地址时,自动使用网络号为169.254.0.0/16的专用地址,仅供相同处境的PC临时通讯
DHCP的排错:手动配置地址然后ping DHCP服务器,查看连通性
Win中的DHCP Client也需要开启(若不启动,不会抓取到Discover包)
租期设置建议
设置较短:增加网络负担,适合客户端较多(流动场所,如机场、车站、商场)
设置较长:减轻网络负担(固定场所,如家庭、企业)
服务器只在租期到期后收回地址,无论对方是否开机,
Windows会记录上一次租到的地址,在租期后重新discover后会有requested ip(即上一次的地址),若此时更换环境(从公司到家),则对方(另一dhcp服务器)会拒绝请求,此时产生DHCP NAK数据包
IP地址释放
要么客户主动释放,ipconfig /release(Windows),此时向DHCP Server发送Release报文
要么被动释放,租期到期前都没有得到服务器回应,或关机时间超过租期
DHCP地址池

DHCP配置
| dhcp enable | 全局开启DHCP功能 |
| dhcp select interface | 关联接口与接口地址池 (网关为接口地址) |
| dhcp server dns-list x.x.x.x | 配置接口地址池的DNS服务器 (可配置多个) |
| dhcp server lease 数字 | 配置接口地址池租期,缺省1天 |
| dhcp server excluded-ip-address x.x.x.x | 配置接口地址池的排除地址范围 |
| dhcp select global | 关联接口和全局地址池 (接口地址并非网关,如VRRP、DHCP-Relay场景) |
| ip pool 名称 | 创建全局地址池并命名 |
| network x.x.x.x | 配置全局地址池的可分配网段地址 |
| gateway-list x.x.x.x | 配置全局地址池的网关 |
| dns-list x.x.x.x | 配置全局地址池的DNS地址 (可配置多个) |
| lease 数字 | 配置全局地址池下的租期,缺省1天 |
| excluded-ip-address x.x.x.x | 配置全局地址池下的排出地址范围 |
| display ip pool [interface gi0/0/x all] | 查看地址池的属性 |
无线路由器的DNS可以是自己(192.168.1.1)帮忙转发域名解析给运营商
生成树还有一小章没补完,自己给自己绕晕了,恁娘
边栏推荐
- 你知道磁环电感的常见磁芯类型有哪些吗?
- SQL二次注入详解
- 每周招聘|PostgreSQL数据库研发工程师,年薪60+,名企高薪,挑战自我!
- Embedded SIG | 分布式软总线
- [paper reading] logan:membership influence attacks against generative models
- Plato farm is expected to further expand its ecosystem through elephant swap
- 【HCIP】OSPF 关系建立
- 华为Atlas900揭秘:集成数千颗昇腾910芯片,算力堪比50万台PC!
- 数据库全栈工程师(DevDBOps)低首付、高回报,先就业后付款
- Module 8 (message queue MySQL table storing message data)
猜你喜欢
![[IO Development Notes] smart cloud intelligent watering device practice (3) - automatic code generation and transplantation](/img/f6/e23089c473cc72a7d763ff975d8e62.png)
[IO Development Notes] smart cloud intelligent watering device practice (3) - automatic code generation and transplantation

杰理下载器强制下载工具的使用介绍_AC695N696NAD14AD15全系列支持

7.27 watch first | openeuler is ambitious, open source Huizhi creates the future - the most detailed agenda of the Euler sub forum of the open atom global open source summit is released

sql多表查询的练习

Cached database for memcached

Calendar documents implemented by several qwidgets

Lighting 5g in the lighthouse factory, Ningde era is the first to explore the way made in China

Summary of shell related commands

Programmer growth chapter 29: how to motivate employees?
![Leetcode:857. Minimum cost of employing K workers [think in blocks + start with simplicity]](/img/ff/5839bf4c0dd0bcf7588a928823dd26.png)
Leetcode:857. Minimum cost of employing K workers [think in blocks + start with simplicity]
随机推荐
Embedded SIG | 分布式软总线
PostgreSQL and Navicat: the backbone of the database industry
麒麟990系列为何无缘Cortex-A77和Mali G77?
Page file system based on C language
顺序表实现
模块8(消息队列存储消息数据的mysql表格)
蔚来杯2022牛客暑期多校训练营2
2019 biometric forum successfully ended: these ten highlights should not be missed!
Makefile related syntax summary (openc910)
Day07 MySql知识点再总结与多表查询
Regular expressions and bypass case recurrence
App information reconnaissance & night God simulator burp packet capture configuration
动态规划之线性DP
Luo Xu talks with Siemens wanghaibin: advanced manufacturing requires benefits from Digitalization
Promote the replacement of X86 with arm server chips, and Huawei and Feiteng carry the banner of localization!
DAO:OP 代币和不可转让的 NFT 致力于建立新的数字民主
『MongoDB』你想要的MongoDB基本操作这里都有
『Mysql』汇总Mysql索引失效的常见场景
gateway基本使用
【HCIP】OSPF 特殊区域、汇总、认证