網絡基礎-DHCP

DHCP

  • 動態路由主機協議(dynamic host configuration protocol),局域網協議,使用udp工作

  • 作用

    • 內部網或網絡服務器供應商自動分配ip
    • 用於用戶內部管理員作爲對計算機管理手段
  • 思路

    • 先在匯聚層定義和配置地址池
    • 接入層交換機端口劃分vlan
    • 在地址池中配置pc端Mac或之間指定一個dns-list
    • 在vlan上配置好改網關,並在vlan上開啓DHCP
  • 實現命令

#
dhcp enable 
ip  pool  xxx  //配置地址池名稱
network  x.x.x.x  mask x.x.x.x
static-bina  ip  add  x.x.x.x  mac-add x.x.x.x  //把固定的地址給xxx
dns-list  x.x.x.x  //dns服務器
leese  day xx  //生存時間
gateway-list  x.x.x.x 
exduded-ip-add  x.x.x.x //保留ip
#
int  vlan xx
ip  add  mask
dhcp select  globe   //在vlan內開啓DHCP功能

實驗演示

topo

在這裏插入圖片描述
實驗要求

  • 在 R1 的 g0/0/0 接口配置接口地址池,需求如下:

    不包含地址 10.1.1.1

    租期爲 1 天 2 小時 5 分鐘

    DNS 服務器爲 10.1.1.1

  • 在 R1 的 g0/0/1 接口配置全局地址池,需求如下:

    網關爲 20.1.1.254

    分配的地址爲 20.1.1.0/24

    租期爲 1 天 2 小時 5 分鐘**

#在r1上配置基本的ip地址

[r1]dis  ip  int  br
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 0
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 0

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.1.1.254/24        up         up        
GigabitEthernet0/0/1              20.1.1.254/24        up         up     

接口地址池

配置g0/0/0口
#
interface GigabitEthernet0/0/0
 ip address 10.1.1.254 255.255.255.0 
 dhcp select interface
 dhcp server excluded-ip-address 10.1.1.1 
 dhcp server lease day 1 hour 1 minute 5 
 dhcp server dns-list 10.1.1.1 
#

  • 在pc1上開啓DHCP,在r1的G0/0/0口抓包

在這裏插入圖片描述
全局地址池

在r1的g0/0/1接口上
#
ip pool pool2
 gateway-list 20.1.1.254 
 network 20.1.1.0 mask 255.255.255.0 
 lease day 2 hour 1 minute 5 
#
#
interface GigabitEthernet0/0/1
 ip address 20.1.1.254 255.255.255.0 
 dhcp select global
#


  • 開啓PC2上的DHCP,用ipconfig命令查看
    在這裏插入圖片描述
    可以看到,10.1.1.253這個地址分配到PC1。

同理,r3可以使用抓包或者在PC3的命令行輸入ipconfig查看!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章