小雪崩 发表于 2018-5-12 08:47:19

Redhat 5 配置DHCP服务器

  实验环境:

DHCP服务器系统:redhat 5
网卡接口:eth0
IP地址:192.168.228.135
网关:192.168.228.2
子网掩码:255.255.255.0
DNS:114.114.114.1148.8.8.8
Vmware虚拟机

一、安装
检查是否安装DHCP服务
rpm -qa|grep dhcp

如果未安装DHCP可以用此命令挂载光驱,从光盘安装DHCP服务:
mount /dev/cdrom /mnt

进入光盘安装包目录:
cd /mnt/Server/

找到安装包dhcp-3.0.5-3.el5.i386.rpm进行安装
rpm -ivh dhcp-3.0.5-3.el5.i386.rpm

二、配置
cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
cp: overwrite `/etc/dhcpd.conf'? Y#提示是否覆盖,按Y,回车。



vi /etc/dhcpd.conf#编辑配置文件

ddns-update-style none;      #关闭动态DNS更新,开启将none改为interim
ignore client-updates;       #忽略客户端更新
subnet 192.168.228.0 netmask 255.255.255.0 {         #设置子网声明

# --- default gateway
      option routers         192.168.228.3;    #设置客户机默认网关
      option subnet-mask   255.255.255.0;    #设置客户机子网掩码
      option nis-domain      "domain.org";   #设置客户端DIS域
      option domain-name   "domain.org";   #设置客户端DNS域
   option domain-name-servers      114.114.114.114,8.8.8.8;      #为客户端设置DNS服务器
option time-offset            -18000; # Eastern Standard Time

#option ntp-servers             192.168.1.1;            
option netbios-name-servers   192.168.1.1;
# --- 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 192.168.228.100 192.168.228.200;   #设置DHCP服务器IP地址租用范围
      default-lease-time 21600;      #默认租约时间,21600秒即6个小时
      max-lease-time 43200;            #最大租约时间

      # we want the nameserver to appear at a fixed address
      host ns {                     #设置固定IP
next-server marvin.redhat.com;
hardware ethernet 00:0C:29:0E:63:81;   #指定客户端的MAC地址
fixed-address 192.168.228.88;          #指定客户端固定IP地址
      }
}


注:VI编辑器常用的,进入VI以后按I开始编辑文本,需要保存按ESC键后在输入:wq 不保存 :q!
更多VI命令使用参考:
http://blog.csdn.net/xueziheng/article/details/2048054

service dhcpd start    #启动dhcp服务
service dhcpd restart#重启dhcp服务
chkconfig dhcpd on   #设置开机启动

三、测试客户端

由于Vmware自带DHCP服务,所以要暂停它自带的DHCP服务。
右键计算机---管理,如图所示,找到该服务,禁止DHCP服务。

  启动客户端后,成功获取IP:



  如果未获取成功,请先释放:

Ipconfig /release
然后在获取:
Ipconfig /rene


本文参考“CentOS 5.5配置DHCP服务器”
原文地址:http://www.iyunv.com/archives/1744.html


页: [1]
查看完整版本: Redhat 5 配置DHCP服务器