linux下配置简单的dhcp服务器

AS4下配置dhcp 操作系统:Red Hat Enterprise Linux AS release 4 (Nahant Update 3)2.6.9-34.EL
Redhat使用dhcpd进程提供DHCP服务,启动时dhcpd自动读它的配置文件/etc/dhcpd.conf。dhcpd将客户的租用信息保存
在/var/lib/dhcp/dhcpd.leases文件中,该文件不断被更新,从这里面可以查到IP地址分配的情况。
配置实例:
--------------------------------------------------
# rpm -qa | grep dhcp
dhcp-3.0pl1-23
# ls /etc/dhcpd.conf
# find /usr/share/doc -name dhcp*.*
/usr/share/doc/dhcp-3.0pl1
/usr/share/doc/dhcp-3.0pl1/dhcpd.conf.sample
# cp /usr/share/doc/dhcp-3.0pl1/dhcpd.conf.sample /etc/dhcpd.conf
----------------------------------------------------------------------
# vi /etc/dhcpd.conf      ----------编辑dhcpd.conf文件
ddns-update-style interim; 公司用的是none    #定义所支持的DNS动态更新的型{none|adhoc|interim}
ignore client-updates;         #allow/ignore允许/忽略客户机更新DNS记录
 
     subnet 192.168.0.0 netmask 255.255.255.0{
                            #定义dhcp服务的子网
 
                    default-lease-time 21600;
                            #默认的租约时间,单位为秒
              
                    max-lease-time     518400;
                            #最长时间518400秒
 
                    option domain-name-servers      202.106.0.20,202.106.46.151;
                            #定义dns地址
 
                    option routers 192.168.0.1;
                            #定义默认路由
 
                    range dynamic-bootp 192.168.0.10 192.168.0.253;
                            #定义给客户端分配的IP地址范围
                    authoritative; 拒绝不正当的IP申请
 
                    option subnet-mask 255.255.255.0;
                            #定义分配的子网掩码
                    option broadcast-address 192.168.0.255;
                            #定义广播地址
                  
                    host ns {
                    next-server marvin.redhat.com;
                    hardware ethernet 00:0C:29:BE:63:32;
                    fixed-address 192.168.0.100;
        }                             #静态IP地址分配,mac地址为63:32的网卡分配192.168.0.100这个地址
vi /etc/sysconfig/dhcpd  指定启用DHCP服务的网络接口
             
[root@apple ~]# /etc/rc.d/init.d/dhcpd start
            #启动dhcp服务,配置完比,可去客户端做测试
 
===========================================================
获取IP:在另外一个redhat linux上,把IP设置成DHCP主机的IP地址。
  检查配置:
  [root@rh root]# cat /etc/sysconfig/ network-scripts/ifcfg-eth0
  DEVICE=eth0
  ONBOOT=yes
  BOOTPROTO=dhcp
  [root@rh root]# dhclient eth0      ----从服务器上去获取IP

你可能感兴趣的:(linux,配置,DHCP服务器)