• 最简单的DHCP服务


     

       这几天在准备网络安装linux操作系统。最后决定用pxe + kickstart 的方式完成。原理、方案弄完了之后,开始搭建,结果被DHCP给挡住了。这不就得研究研究最简单最实用的DHCP使用方法。

     

       * 红色的是必须有

       * 绿色的是要注意

       * 蓝色的是包安装时,要有的程序包

     

               1. DHCP的实现

               2. 配置文件实例

                   实例1

                   实例2

       -----------------------------------------------------------------

    1. DHCP的实现

    DHCP服务必须给本网段提供一个地址池。

    # yum -y install dhcp-devel
    # rpm -aq | grep dhcp
       dhcp-4.1.1-38.P1.el6.centos.i686
       dhcp-devel-4.1.1-38.P1.el6.centos.i686
    
    # cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
    # vi dhcpd.conf
       ddns-update-style interim;
       default-lease-time 21600;
       max-lease-time 43200;
       option domain-name “test.com”;
       option domain-name-servers 192.168.1.1,202.106.0.20;
    subnet
    192.168.1.0 netmask 255.255.2550 { range 192.168.1.128 192.168.1.254; option subnet-mask 255.255.255.0; option routers 192.168.1.1; } host server01 { hardware ethernet 0:c0:c3:22:46:81; fixed-address 192.168.1.11; option subnet-mask 255.255.255.0; option routers 192.168.1.1; } subnet 117.34.70.0 netmask 255.255.255.0 { default-lease-time 21600; max-lease-time 43200; option routers 117.34.70.1; option subnet-mask 255.255.255.0; }

     

    一台主机有多块网卡,需要在某个网卡上启用DHCP服务时,需要配置如下:

    # vi /etc/sysconfig/dhcpd
       # Command line options here
    
       DHCPDARGS="eth0"

     

    ------------------------------

    2. 配置文件实例

    简单的样例:(红色部分必须有)

     

    # vi /etc/dhcp/dhcpd.conf
       # 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.
       subnet 117.34.73.0 netmask 255.255.255.0 {
    
       }
    
       subnet 10.152.187.0 netmask 255.255.255.0 {
    
       }
    
       # vi /etc/dhcp/dhcpd.conf
       default-lease-time 600;
       max-lease-time 7200;
       ddns-update-style none;
       subnet 117.34.73.0 netmask 255.255.255.0 {
    
       }

       -----------------------------------------------------------------

    * 注意:

        ● 如果主机网卡比较多,可以选择一块作为服务网卡。

            vi /etc/sysconfig/dhcpd

            # Command line options here
            DHCPDARGS="em1:1"
        ● 提供服务的网卡必需是 非自动获取 的地址。

            ifconfig eth0 172.16.40.129/25 up

        ● 服务提供的地址池必需包含本地提供服务的地址在里面。

        ● 地址池(range)不能与作用域(subnet)冲突。

        ● 其他的参数、选项没有也可以启动的。所以可以不设置,因为这里是为了网络安装。

        ● 如果配置了这里所说的最简单的 dhcp 服务,却无法启动。就剩下一个原因,每句后面有没有分号。

    一切代码都是为了生活,一切生活都是调剂
  • 相关阅读:
    1051 Wooden Sticks(贪心-3)
    97 等价交换(贪心-2)
    python文件操作
    python学习-day 2
    python学习-day 1
    Python 测试题目-1
    Python list和dict方法
    Python 字符串
    while循环语句
    Python if判断语句
  • 原文地址:https://www.cnblogs.com/argor/p/7905160.html
Copyright © 2020-2023  润新知