当前位置:网站首页>Learning diary - (routing and switching technology) DHCP (Dynamic Host Configuration Protocol)
Learning diary - (routing and switching technology) DHCP (Dynamic Host Configuration Protocol)
2022-07-23 12:51:00 【Make money and marry sweet】
One 、 Related knowledge
DHCP( Dynamic Host Configuration Protocol ) Allocate to customers in a mobile way TCP/IP Information
advantage :
- Reduce the workload of Administrators
- Reduce the possibility of input errors
- avoid IP Conflict
- When the network changes the network segment , There is no need to reconfigure each computer IP
- Computer mobility does not require reconfiguration IP
- Improved IP Address utilization
working process

notes : When there are multiple servers , The client will first choose the server that responds to it
- When DHCP The client has a lease term of 50% when : Renew lease , The client sends DHCPRequest package
- When DHCP The client has a lease term of 87.5% when : Enter the re application status , The client sends DHCPDiscover package
- Use ipconfig/renew The command to DHCP Server send DHCPRequest package . If DHCP The server is not responding , The client will continue to use the current configuration .
- Use ipconfig/release command : Of the client TCP/IP Contact stopped (IP 0.0.0.0 Subnet mask :0.0.0.0), The server will release IP Assign to other clients .
DHCP Is based on Client/Server Working mode ,DHCP The server assigns to the host that needs dynamic configuration IP Address and host configuration parameters .
DHCP There are three mechanisms for distribution IP Address :
- Automatically assigned :DHCP Assign permanent IP Address
- Dynamic allocation :DHCP The assignment to the client will expire after a period of time IP Address ( Or the client can automatically release IP Address ) Default ( default ) The term of the lease is 1 God .
- Manual configuration : Configured by the network administrator IP Address
Of the three ways of address assignment , Only dynamic allocation can reuse addresses that the client does not need
Two 、 Related examples
1、 Routing operation DHCP The server
step
1、 open DHCP service
2、 Configure the address of the router interface and open
3、 To configure DHCP agreement
topology :

Code :
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host R1
R1(config)#se
R1(config)#ser
R1(config)#service dhc
R1(config)#service dhcp Turn on DHCP service
R1(config)#INT
R1(config)#INTerface g
Configure router
R1(config)#INTerface gigabitEthernet 0/0
R1(config-if)#ip add
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#no sh
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
R1(config-if)#e
R1(config-if)#exit
R1(config)#ip dh
R1(config)#ip dhcp po
R1(config)#ip dhcp pool SYJ To build a DHCP Address pool (SYJ It's the name )
R1(dhcp-config)#net
R1(dhcp-config)#network 192.168.1.0 255.255.255.0 Divide the address pool into ranges
R1(dhcp-config)#de
R1(dhcp-config)#default-router 192.168.1.254 Set the gateway address
R1(dhcp-config)#dns
R1(dhcp-config)#dns-server 192.168.1.1 DNS Domain name address
R1(dhcp-config)#e
R1(dhcp-config)#exit
R1(config)#ip dh
R1(config)#ip dhcp ex
Put some useless IP Address exclusion
R1(config)#ip dhcp excluded-address 192.168.1.1
R1(config)#ip dhcp excluded-address 192.168.1.2 192.168.1.10
R1(config)#ip dhcp excluded-address 192.168.1.254
R1(config)#ex
R1(config)#exit
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#
result :PC0 use DHCP Protocol auto access IP Address

2、 The layer-2 switch works DHCP The server
topology :

Corresponding code :
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#host
Switch(config)#hostname S1
Divide VLAN
S1(config)#vlan 10
S1(config-vlan)#e
S1(config-vlan)#exit
S1(config)#vlan 20
S1(config-vlan)#e
S1(config-vlan)#exit
S1(config)#in
take 4 Interfaces are divided into corresponding VLAN
S1(config)#interface f
S1(config)#interface fastEthernet 0/1
S1(config-if)#sw
S1(config-if)#switchport mo
S1(config-if)#switchport mode a
S1(config-if)#switchport mode access
S1(config-if)#sw
S1(config-if)#switchport a
S1(config-if)#switchport access vlan 10
S1(config-if)#e
S1(config-if)#exit
S1(config)#int
S1(config)#interface f
S1(config)#interface fastEthernet 0/2
S1(config-if)#sw
S1(config-if)#switchport mo
S1(config-if)#switchport mode ac
S1(config-if)#switchport mode access
S1(config-if)#sw
S1(config-if)#switchport ac
S1(config-if)#switchport access vlan 10
S1(config-if)#e
S1(config-if)#exit
S1(config)#int
S1(config)#interface fastEthernet 0/3
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 20
S1(config-if)#e
S1(config-if)#exit
S1(config)#interface fastEthernet 0/4
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 20
S1(config-if)#e
S1(config-if)#exit
VLAN surface
S1(config)#do show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/14, Fa0/15, Fa0/16
Fa0/17, Fa0/18, Fa0/19, Fa0/20
Fa0/21, Fa0/22, Fa0/23, Fa0/24
Gig0/1, Gig0/2
10 VLAN0010 active Fa0/1, Fa0/2
20 VLAN0020 active Fa0/3, Fa0/4
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
S1(config)#int
open VLAN , Configure the corresponding address
S1(config)#interface vlan 10
S1(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
S1(config-if)#ip add
S1(config-if)#ip address 192.168.10.1 255.255.255.0
S1(config-if)#no sh
S1(config-if)#no shutdown
S1(config-if)#e
S1(config-if)#exit
S1(config)#interface vlan 20
S1(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
S1(config-if)#ip address 192.168.20.1 255.255.255.0
S1(config-if)#no sh
S1(config-if)#no shutdown
S1(config-if)#e
S1(config-if)#exit
S1(config)#ser
S1(config)#service DH
S1(config)#service DHcp open DHCP service
S1(config)#ip dh
S1(config)#ip dhcp poo
S1(config)#ip dhcp pool vlan10 establish DHCP Address pool
S1(dhcp-config)#net
S1(dhcp-config)#network 192.168.10.0 255.255.255.0 Divide the address pool into a network segment
S1(dhcp-config)#de
S1(dhcp-config)#default-router 192.168.10.1 configure gateway
S1(dhcp-config)#dn
S1(dhcp-config)#dns-server 1.1.1.1 Domain name service
S1(dhcp-config)#ex
S1(dhcp-config)#exit
S1(config)#ip
S1(config)#ip dh
S1(config)#ip dhcp po
S1(config)#ip dhcp pool vlan20
S1(dhcp-config)#net
S1(dhcp-config)#network 192.168.20.0 255.255.255.0
S1(dhcp-config)#de
S1(dhcp-config)#default-router 192.168.20.1
S1(dhcp-config)#dn
S1(dhcp-config)#dns-server 2.2.2.2
S1(dhcp-config)#ex
S1(dhcp-config)#exit
S1(config)#ip ah
S1(config)#ip dh
S1(config)#ip dhcp ex
Get rid of the unused IP Address
S1(config)#ip dhcp excluded-address 192.168.10.1
S1(config)#ip dhcp excluded-address 192.168.10.2 192.168.10.100
S1(config)#ip dhcp excluded-address 192.168.20.1
S1(config)#ip dhcp excluded-address 192.168.20.2 192.168.20.200
S1(config)#ex
S1(config)#exit
S1#
%SYS-5-CONFIG_I: Configured from console by console
result :


DHCP relay
topology :

Related codes
R1:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host
Router(config)#hostname R1
R1(config)#int g
Configure interface IP Address
R1(config)#int gigabitEthernet 0/0
R1(config-if)#ip add
R1(config-if)#ip address 172.16.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
R1(config-if)#e
R1(config-if)#exit
R1(config)#int gigabitEthernet 0/1
R1(config-if)#ip address 172.16.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
R1(config-if)#e
R1(config-if)#exit
R1(config)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
R1(config)#route
To configure RIP route
R1(config)#router rip
R1(config-router)#net
R1(config-router)#network 172.16.1.0
R1(config-router)#network 172.16.12.0
R1(config-router)#ver
R1(config-router)#version 2
R1(config-router)#end
R1#
% Unknown command or computer name, or unable to find computer address
R1#show ip ro
The configured routing table
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
C 172.16.1.0/24 is directly connected, GigabitEthernet0/0
L 172.16.1.1/32 is directly connected, GigabitEthernet0/0
R 172.16.2.0/24 [120/1] via 172.16.12.2, 00:00:07, GigabitEthernet0/1
C 172.16.12.0/24 is directly connected, GigabitEthernet0/1
L 172.16.12.1/32 is directly connected, GigabitEthernet0/1
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ser
To configure DHCP
R1(config)#service dhcp
R1(config)#ip dhc
R1(config)#ip dhcp pool SYJ
R1(dhcp-config)#net
R1(dhcp-config)#network 172.16.1.0 255.255.255.0
R1(dhcp-config)#de
R1(dhcp-config)#default-router 172.16.1.1
R1(dhcp-config)#dns
R1(dhcp-config)#dns-server 1.1.1.1
R1(dhcp-config)#e
R1(dhcp-config)#exit
R1(config)#%DHCPD-4-PING_CONFLICT: DHCP address conflict: server pinged 172.16.1.1.
R1(config)#ip dhc
R1(config)#ip dhcp poo
R1(config)#ip dhcp pool JTN
R1(dhcp-config)#net
R1(dhcp-config)#network 172.16.2.0 255.255.255.0
R1(dhcp-config)#de
R1(dhcp-config)#default-router 172.16.2.1
R1(dhcp-config)#dns
R1(dhcp-config)#dns-server 2.2.2.2
R1(dhcp-config)#e
R1(dhcp-config)#exit
R1(config)#ip dh
R1(config)#ip dhcp ec
R1(config)#ip dhcp ex
R1(config)#ip dhcp excluded-address 172.16.1.1
R1(config)#ip dhcp excluded-address 172.16.2.1
R1(config)#
R2:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host
Router(config)#hostname R2
R2(config)#int g
Configuration interface IP Address
R2(config)#int gigabitEthernet 0/0
R2(config-if)#ip address 172.16.2.1 255.255.255.0
R2(config-if)#no sh
R2(config-if)#no shutdown
R2(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
R2(config-if)#e
R2(config-if)#exit
R2(config)#int gigabitEthernet 0/1
R2(config-if)#ip address 172.16.12.2 255.255.255.0
R2(config-if)#no s
R2(config-if)#no sh
R2(config-if)#no shutdown
R2(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
R2(config-if)#e
R2(config-if)#exit
To configure RIP agreement
R2(config)#route r
R2(config)#route rip
R2(config-router)#net
R2(config-router)#network 172.16.2.0
R2(config-router)#network 172.16.12.0
R2(config-router)#ver
R2(config-router)#version 2
R2(config-router)#end
R2#
%SYS-5-CONFIG_I: Configured from console by console
R2#show ip rou
Routing table
R2#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
R 172.16.1.0/24 [120/1] via 172.16.12.1, 00:00:01, GigabitEthernet0/1
C 172.16.2.0/24 is directly connected, GigabitEthernet0/0
L 172.16.2.1/32 is directly connected, GigabitEthernet0/0
C 172.16.12.0/24 is directly connected, GigabitEthernet0/1
L 172.16.12.2/32 is directly connected, GigabitEthernet0/1
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#ser
R2(config)#service dhc
R2(config)#service dhcp Be sure to turn on DHCP service
R2(config)#int
R2(config)#interface g
R2(config)#interface gigabitEthernet 0/0 Access interface
R2(config-if)#ip help
R2(config-if)#ip helper-address 172.16.12.1 To configure DHCP relay
R2(config-if)#e
R2(config-if)#exit
R2(config)#
result :


PC1ping PC4

This article is written here !
边栏推荐
- Unity3D+moba+技能指示器(一)
- [fee of AUTOSAR (difference between nonvolatile memory flash and EEPROM)]
- post表单提交数据限制
- Unity Shader丢失问题
- Explain the establishment of TCP connection in detail
- Knowledge points and skills of Wireshark network analysis is so simple
- GameFramework:资源热更代码分析,检查版本信息,下载版本文件,校验版本文件,得到更新文件数量,下载文件,TaskPool
- Article on the basic technology needed to build hybrid app
- MySQL性能优化,索引优化
- 0回溯/动态规划中等 LeetCode526. 优美的排列
猜你喜欢

C# 自定义Queue队列集合

unity3d:Assetbundle模拟加载,同步加载,异步加载,依赖包加载,自动标签,AB浏览器,增量打包
![[fee of AUTOSAR (difference between nonvolatile memory flash and EEPROM)]](/img/cc/34bfcc450d82befab24173b0cb132d.png)
[fee of AUTOSAR (difference between nonvolatile memory flash and EEPROM)]

GameFramework:打包资源,打随app发布包,打包生成文件夹说明,上传资源至服务器,下载资源,GameFreamworkList.dat 与GameFrameworkVersion.dat

Hcip --- HCIA knowledge review (I)

OSPF和RIP的路由扩展配置

Hcip--- BGP related configuration

psutil监控的简单使用

HCIP---BGP相关配置(联邦篇)

Hcip--- BGP related configuration (Federal chapter)
随机推荐
学习日记——(路由与交换技术)动态路由(rip协议)和静态路由
InheritableThreadLocal与阿里的TransmittableThreadLocal设计思路解析
HCIP---BGP ---边界网关协议
Unity3d: special effect object pool, timeout delete GameObject in the pool, GC weight
@Requiredargsconstructor annotation use
C # custom bidirectional linked list
MySQL performance optimization, index optimization
Routing and switching technology - static routing
0最短路径问题 LeetCode743. 网络延迟时间
Super easy to use packet capturing tool tcpdump
Take go language as an example to explain [performance analysis] by analogizing detective reasoning
OSPF综合实验
unity3d:向量计算,AOE图形相交
HCIP---条件匹配和OSPF协议
路由与接口技术——直连网络总结
In depth analysis of replication in redis
[database] basic theory
The correspondence between the concept of go ability and the concept of software development ability
Explain the flow control mechanism and congestion control mechanism of TCP in detail
Basic knowledge of high voltage technology