欢迎光临散文网 会员登陆 & 注册

配置设备作为DHCP服务器示例(基于接口地址池),建议收藏!

2023-03-22 15:07 作者:竞予科技  | 我要投稿

DHCP服务器简介

通常用户希望网络中的每台终端能够动态获取IP地址、DNS服务器的IP地址、路由信息、网关信息等网络参数,不需要手动配置终端的IP地址等网络参数;另外,针对一些移动终端(手机、ipad、办公笔记本等)希望能够即插即用,不需要每次修改终端的IP等网络参数。如果用户网络中有这些需求,就可以在汇聚层的用户网关设备或核心层设备上配置DHCP服务器功能,来给终端分配IP地址等网络参数。

动态主机配置协议DHCP(Dynamic Host Configuration Protocol)采用客户端/服务器模式对用户的网络参数进行动态配置和集中管理。其中,DHCP服务器通过地址池为用户分配IP地址等网络参数。地址池分为接口地址池和全局地址池两种。

接口地址池配置方式简单,只能用于用户与DHCP服务器在同一个网段的场景,并且只能给对应接口下的用户分配IP地址等网络参数;适用于设备数量有限、配置以及维护量可控的小型网络。在用户网关设备上配置基于接口地址池的DHCP服务器功能之后,对应接口下的固定主机、移动终端等都可以自动获取IP地址等网络参数,不需要用户手动配置修改。

与接口地址池相比,全局地址池可应用于大型网络,推荐在核心层设备上配置基于全局地址池的DHCP服务器功能或在服务器区域搭建一台专门的DHCP服务器统一分配IP地址等网络参数,而用户网关设备上只需要启用简单的DHCP中继功能即可。

配置注意事项

本举例适用的产品包括:

  • V200R005C00SPC300及后续版本的S2350-EI、S5300-LI

  • S2320-EI、S3300-SI、S3300-EI、S3300-HI

  • S5300-SI、S5300-EI、S5300-HI、S5310-EI、S5320-LI、S5320-SI、S5320-EI、S5320-HI、S5330-SI、S5330-HI、S5331-H、S5332-H、S5335-L1、S5335-L、S5335-S、S5336-S

  • S6300-EI、S6320-SI、S6320-EI、S6320-HI、S6330-H

  • S9303、S9306、S9312、S9310、S9310X、S9300X-4、S9300X-8、S9300X-12、S9303E、S9306E、S9312E

本举例中产品的默认适用版本请参见“案例适用的产品和版本说明”中的表1-1。

如需了解交换机软件配套详细信息,请点击Info-Finder,在选择产品系列或产品型号后,在“硬件中心”进行查询。

组网需求

如图7-3所示,某企业为办公终端规划了两个网段,网段10.1.1.0/24内PC为员工固定办公终端,网段10.1.2.0/24供企业出差人员临时接入网络。企业希望通过DHCP方式为员工固定办公终端和企业出差人员分配IP地址。其中,企业管理者的办公PC(Client_1)由于业务需要,希望使用固定IP地址为10.1.1.100/24。


图7-3 配置设备作为DHCP服务器组网图


配置思路

基于接口地址池的DHCP服务器的配置思路如下:

通过在网关设备Switch上配置DHCP服务器,实现为企业两个网段内的终端动态分配IP地址。其中,网段10.1.1.0/24内的PC为员工固定办公终端,IP地址租期配置为30天;网段10.1.2.0/24供企业出差人员临时接入网络,IP地址租期配置为1天。

二层交换机LSW_1和LSW_2上,需要配置接口的链路类型和加入的VLAN,实现二层互通。

操作步骤

  1. 使能DHCP服务,缺省未使能


    <Quidway> system-view

    [Quidway] sysname Switch

    [Switch] dhcp enable


  2. 配置接口加入VLAN


    # 配置GE0/0/1接口加入VLAN10。

    [Switch] vlan batch 10 to 11

    [Switch] interface gigabitethernet 0/0/1

    [Switch-GigabitEthernet0/0/1] port link-type access

    [Switch-GigabitEthernet0/0/1] port default vlan 10

    [Switch-GigabitEthernet0/0/1] quit

# 配置GE0/0/2加接口入VLAN11。

[Switch] interface gigabitethernet 0/0/2 

[Switch-GigabitEthernet0/0/2] port link-type access 

[Switch-GigabitEthernet0/0/2] port default vlan 11 

[Switch-GigabitEthernet0/0/2] quit


3、配置VLANIF接口IP地址

# 配置VLANIF10接口地址。

[Switch] interface vlanif 10 

[Switch-Vlanif10] ip address 10.1.1.1 24  //企业为固定办公终端的网段 

[Switch-Vlanif10] quit

# 配置VLANIF11接口地址。

[Switch] interface vlanif 11 

[Switch-Vlanif11] ip address 10.1.2.1 24  //企业为出差人员分配的网段 

[Switch-Vlanif11] quit

4、配置接口地址池


# 配置VLANIF10接口下的终端从接口地址池中获取IP地址。

[Switch] interface vlanif 10 

[Switch-Vlanif10] dhcp select interface  //使能接口采用接口地址池的DHCP服务器功能,缺省未使能 

[Switch-Vlanif10] dhcp server lease day 30  //租期的缺省值为1天,修改租期为30天 

[Switch-Vlanif10] dhcp server static-bind ip-address 10.1.1.100 mac-address 00e0-fc12-3456  //为Client_1分配固定的IP地址 

[Switch-Vlanif10] quit

# 配置VLANIF11接口下的终端从接口地址池中获取IP地址。租期采用缺省值1天(不需配置)。

[Switch] interface vlanif 11 

[Switch-Vlanif11] dhcp select interface  //使能接口采用接口地址池的DHCP服务器功能,缺省未使能 

[Switch-Vlanif11] quit


5、配置DHCP数据保存功能,设备发生故障时,可以在系统重启后,执行命令dhcp server database recover,从存储设备文件恢复DHCP数据。


[Switch] dhcp server database enable


6、配置各终端自动获取IP地址(以操作系统为Windows 7的PC为例)

    1. 右击桌面“网络”,单击“属性”,进入“网络和共享中心”窗口。

    2. 单击“本地连接”,进入“本地连接 状态”窗口。

    3. 单击“属性”,进入“本地链接 属性”窗口。

    4. 选择“Internet 协议版本 4(TCP/IPv4)”,点击“属性”,进入“Internet 协议版本4(TCP/IPv4)属性”窗口,选择“自动获得 IP 地址”,单击“确定”。


    7、验证配置结果


    1. 在Switch上执行命令display ip pool查看接口地址池VLANIF10和VLANIF11的配置信息。假设企业员工固定办公终端有100个,出差人员接入3个。

      [Switch] display ip pool interface vlanif10  

      Pool-name        : Vlanif10  

      Pool-No          : 0  

      Lease            : 30 Days 0 Hours 0 Minutes  

      Domain-name      : -  

      DNS-server0      : -  

      NBNS-server0     : -  

      Netbios-type     : -  

      Position         : Interface       Status             : Unlocked  

      Gateway-0        : 10.1.1.1  

      Network          : 10.1.1.0  

      Mask             : 255.255.255.0  

      VPN instance     : --  

      Logging          : Disable  

      Conflicted address recycle interval: -  

      Address Statistic: Total       :253       Used        :100                      Idle        :153       Expired     :0                      Conflict    :0         Disable     :0  -------------------------------------------------------------------------------  

      Network section          Start           End       Total    Used Idle(Expired) Conflict Disabled  -------------------------------------------------------------------------------         10.1.1.1      10.1.1.254     253     100        153(0)       0     0  -------------------------------------------------------------------------------

      [Switch] display ip pool interface vlanif11  

      Pool-name        : Vlanif11  

      Pool-No          : 1  

      Lease            : 1 Days 0 Hours 0 Minutes  

      Domain-name      : -  

      DNS-server0      : -  

      NBNS-server0     : -  

      Netbios-type     : -  

      Position         : Interface       Status             : Unlocked   、

      Gateway-0        : 10.1.2.1  

      Network          : 10.1.2.0  

      Mask             : 255.255.255.0  

      VPN instance     : --  

      Logging          : Disable  

      Conflicted address recycle interval: -  

      Address Statistic: Total       :253       Used        :3                      Idle        :250       Expired     :0                      Conflict    :0         Disable     :0  -------------------------------------------------------------------------------   Network section          

      Start           End       Total    Used Idle(Expired) Conflict Disabled  -------------------------------------------------------------------------------        

      10.1.2.1      10.1.2.254     253     3          250(0)       0     0  -------------------------------------------------------------------------------

    在Client_1(操作系统以Windows 7为例)上查看IP地址信息,可以看到Client_1已经获取到IP地址10.1.1.100/24。

    C:\Documents and Settings\Administrator>ipconfig 

    Windows IP Configuration 

    Ethernet adapter Local Area Connection 2:    

    Connection-specific DNS Suffix  . :    

    IPv4 Address. . . . . . . . . . . : 10.1.1.100    

    Subnet Mask . . . . . . . . . . . : 255.255.254.0    

    Default Gateway . . . . . . . . . : 10.1.1.1

    在其他DHCP客户端(以10.1.1.0/24网段中操作系统为Windows 7的某终端为例)上查看IP地址信息,可以看到已经成功获取到IP地址。

    C:\Documents and Settings\Administrator>ipconfig 

    Windows IP Configuration 

    Ethernet adapter Local Area Connection 2:    

    Connection-specific DNS Suffix  . :    

    IPv4 Address. . . . . . . . . . . : 10.1.1.51    

    Subnet Mask . . . . . . . . . . . : 255.255.254.0    

    Default Gateway . . . . . . . . . : 10.1.1.1


配置文件

Switch的配置文件

#

sysname Switch 

vlan batch 10 to 11 

dhcp enable 

dhcp server database enable 

interface Vlanif10 

 ip address 10.1.1.1 255.255.255.0  

dhcp select interface  

dhcp server static-bind ip-address 10.1.1.100 mac-address 00e0-fc12-3456  

dhcp server lease day 30 hour 0 minute 0 

interface Vlanif11  

ip address 10.1.2.1 255.255.255.0  

dhcp select interface 

#

interface GigabitEthernet0/0/1  

port link-type access  

port default vlan 10

#

interface GigabitEthernet0/0/2  

port link-type access  

port default vlan 11 

#

return


配置设备作为DHCP服务器示例(基于接口地址池),建议收藏!的评论 (共 条)

分享到微博请遵守国家法律