zoukankan      html  css  js  c++  java
  • DHCP服务

    一.DHCP总览

    DHCP:动态主机配置协议,通过dhcpd实施,为dhcpd和bootp ipv4,ipv6客户端提供服务。

    二.DHCP协议工作原理
    第一步:客户端请求IP地址-----发送一个DHCPDISCOVER广播包
    第二步:DHCP SERVER响应请求----广播一个DHCPOFFER包
    第三步:客户端选择IP地址----广播一个DHCPREQUEST包
    第四步:服务器确认IP租约----发送一个DHCPACK包

    三.服务简介:DHCP
    类型:system V 管理的服务
    软件名:dhcp
    守护进程:/usr/sbin/dhcpd
    脚本:/etc/init.d/dhcpd
    端口:67(bootps),68(bootpc)
    配置文件:/etc/dhcp/dhcpd.conf,/var/lib/dhcpd/dhcpd.leases

    四.配置IPv4 DHCP服务器
    第一步:安装软件包
    #yum install dhcp
    第二步:获取配置文件 (rpm -ql dhcp|less)
    #cp /usr/share/doc/dhcp-version/dhcp.conf.sample /etc/dhcp/dhcpd.conf
    第三步:按需求定义配置文件,并启动服务
    1./etc/init.d/dhcpd start
    2.chkconfig dhcpd on

    五.DHCP配置文件模版
    #必须至少要定义一个subnet块

    subnet 192.168.177.0 netmask 255.255.255.0 {
    range 192.168.177.26 192.168.177.30;
    option domain-name-servers ns1.internal.example.org;
    option domain-name "internal.example.org";
    option routers 192.168.177.128;
    option broadcast-address 192.168.177.255;
    default-lease-time 600;
    max-lease-time 7200;
    }

    全部的配置文件如下:
    # dhcpd.conf
    #
    # Sample configuration file for ISC dhcpd
    #

    # option definitions common to all supported networks...
    option domain-name "example.org";
    option domain-name-servers ns1.example.org, ns2.example.org;

    default-lease-time 600;
    max-lease-time 7200;

    # Use this to enble / disable dynamic dns updates globally.
    #ddns-update-style none;

    # If this DHCP server is the official DHCP server for the local
    # network, the authoritative directive should be uncommented.
    #authoritative;

    # Use this to send dhcp log messages to a different log file (you also
    # have to hack syslog.conf to complete the redirection).
    log-facility local7;

    # No service will be given on this subnet, but declaring it helps the
    # DHCP server to understand the network topology.


    # This is a very basic subnet declaration.

    # This declaration allows BOOTP clients to get dynamic addresses,
    # which we don't really recommend.

    # A slightly different configuration for an internal subnet.
    subnet 192.168.177.0 netmask 255.255.255.0 {
    range 192.168.177.26 192.168.177.30;
    option domain-name-servers ns1.internal.example.org;
    option domain-name "internal.example.org";
    option routers 192.168.177.128;
    option broadcast-address 192.168.177.255;
    default-lease-time 600;
    max-lease-time 7200;
    }

    # Hosts which require special configuration options can be listed in
    # host statements. If no address is specified, the address will be
    # allocated dynamically (if possible), but the host-specific information
    # will still come from the host declaration.

    # Fixed IP addresses can also be specified for hosts. These addresses
    # should not also be listed as being available for dynamic assignment.
    # Hosts for which fixed IP addresses have been specified can boot using
    # BOOTP or DHCP. Hosts for which no fixed address is specified can only
    # be booted with DHCP, unless there is an address range on the subnet
    # to which a BOOTP client is connected which has the dynamic-bootp flag
    # set.
    host fantasia {
    hardware ethernet 08:00:07:26:c0:a5;
    fixed-address fantasia.fugue.com;
    }

    六.绑定IP地址
    subnet 192.168.177.0 netmask 255.255.255.0 {
    range 192.168.177.26 192.168.177.30;
    ......truncated......
    }

    host client1 {
    hardware ethernet aa:bb:cc:dd:ee:ff;
    #该地址必须是DHCP和BOOTP ranges之外的
    fixed-address fantasia.fugue.com;
    }

    七.DHCP提供文件

    subnet 192.168.177.0 netmask 255.255.255.0 {
    range 192.168.177.26 192.168.177.30;
    ......truncated......
    #指定服务器和文件的位置
    next-server 192.168.0.254;#可以是DNS服务器,也可以是TFTP服务器
    filename "pxelinux.0";#要使用引号
    }

    八.DHCP服务其他
    语法检查工具:service dhcpd configtest
    限制DHCP监听特定接口:修改/etc/sysconfig/dhcpd

  • 相关阅读:
    【Uvalive4960】 Sensor network (苗条树,进化版)
    【UVA 1151】 Buy or Build (有某些特别的东东的最小生成树)
    【UVA 1395】 Slim Span (苗条树)
    【UVA 10600】 ACM Contest and Blackout(最小生成树和次小生成树)
    【UVA 10369】 Arctic Network (最小生成树)
    【UVA 10816】 Travel in Desert (最小瓶颈树+最短路)
    【UVA 11183】 Teen Girl Squad (定根MDST)
    【UVA 11865】 Stream My Contest (二分+MDST最小树形图)
    【UVA 11354】 Bond (最小瓶颈生成树、树上倍增)
    【LA 5713 】 Qin Shi Huang's National Road System (MST)
  • 原文地址:https://www.cnblogs.com/AlwaysWIN/p/6138668.html
Copyright © 2011-2022 走看看