网络通信 频道

DHCP服务器安装与配置笔录

    二、安装配置全过程:

#rpm -ivh dhcp*.rpm (安装软件)
#cp /usr/share/doc/dhcp-*/dhcpd.conf.sample /etc/dhcpd.conf(复制配置文件)
#vi /etc/dhcpd.conf  (修改配置文件)

############################################################################################
ddns-update-style interim;
ignore client-updates;

subnet 10.45.63.0 netmask 255.255.255.0 {

# --- default gateway
        option routers                  10.45.63.185;
        option subnet-mask              255.255.255.0;

        option nis-domain               "xuanfei.org";
        option domain-name              "xuanfei.org";
        option domain-name-servers      202.96.128.86;

        option time-offset              -18000; # Eastern Standard Time
#       option ntp-servers              10.45.63.185;
#       option netbios-name-servers     10.45.63.185;
# --- Selects point-to-point node (default is hybrid). Don''t change this unless
# -- you understand Netbios very well
#       option netbios-node-type 2;

        range dynamic-bootp 10.45.63.1 10.45.63.255;
        default-lease-time 21600;
        max-lease-time 43200;

        # we want the nameserver to appear at a fixed address
        host ns {
                next-server marvin.redhat.com;
                hardware ethernet 12:34:56:78:AB:CD;
                fixed-address 10.45.63.189;
        }
}
############################################################################################
    以上的配置可是实现DHCP的服务

    其发给DHCP客户端的参数是:
子网掩码:255.255.255.0
广播地址:10.45.63.255
网络地址:10.45.63.0
默认网关:10.45.63.185
DNS服务器:202.96.128.86
    要为一台单独的计算机分配固定的IP地址,可以在/etc/dhcpd.conf文件中加上一条:
host doit{
#doit计算机网卡的硬件地址。
Hardware Ethernet  12:34:56:78:AB:CD;
#固定的IP地址
fixed-adress 10.45.63.189;
}
#也可连写为一行:host Jephe {hardware ethernet 12:34:56:78:AB:CD;fixed-address

10.45.63.189;}
你也可为某台机器指定不同的网关地址,名服务器等:host Jephe {hardware ethernet

12:34:56:78:AB:CD;fixed-address 10.45.63.189;option routers 10.45.63.185;}

    三、启用与测试

    启动DHCPD服务的方法为:
#/etc/init.d/dhcpd  start

    停止DHCPD服务的方法为:
#/etc/init.d/dhcpd  stop

    重新启动DHCPD服务的方法为:
#/etc/init.d/dhcpd  restart

    将DHCPD守护进程设置在运行级别35启用:
# chkconfig --level 35 dhcpd on


    测试dhcp
linux下:
#dhclient
windows下:
    打开一台windows xp客户端TCP/IP属性,选择“自动获得IP地址”和“自动获得DNS 服务器地址”或者在

    命令提示符下分别键入ipconfig /release、 ipconfig /renew 最后在命令提示符下键入ipconfig /all, 就会发现客户端通过广播成功从服务器租得IP地址信息


    当一台终端计算机动态获得IP地址后,在/var/lib/dhcpd/dhcpd.leases文件中建立一条类似下面的记录。记录内容为:
lease 10.45.63.185 {
  starts 1 2007/05/28 17:19:21;
  ends 1 2007/05/28 23:19:21;
  tstp 1 2007/05/28 23:19:21;
  binding state active;
  next binding state free;
  hardware ethernet 00:66:e7:4a:71:35;
  uid "\001\000\026\346Ja4";
  client-hostname "win_xuanfei";
}


    四、小结:
   在较为大型的网络中为确保证网络的稳定性、健壮性,可采用2台DHCP服务器偕同工作,实现DHCP服务

器的冗余。但多台DHCP服务器的IP地址资源必须合理的调配,建议不要重复分配IP地址!
   上面的配置文献是最基本的配置,在实际的应用还要考虑到IP地址分配和策略的问题!在以后的无盘

工作站,无人职守安装系统等各领域都是在先前工作中起着重要的作用,是不可以忽视的一门技术。

    资料参考地址:http://www.dhcp.org/
http://www.dhcp-handbook.com/dhcp_faq.html

0
相关文章