码迷,mamicode.com
首页 > 其他好文 > 详细

RHEL DHCP服务器及其中继

时间:2014-06-26 06:06:47      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:dhcp   rhel   服务器   

DHCP服务器:

环境:Red Hat Enterprise Linux Server release 5.2

!!注意:设置ip地址为静态ip地址,我这里设置为:192.168.0.80

(一)先挂载光盘并安装dhcp包:

挂载:mount /dev/cdrom /mnt/

安装包:rpm -ivh /mnt/Server/dhcp*

        rpm -ivh dhcp-3.0.5-13.el5.i386.rpm

(二)编辑配置文件:

 进入编辑界面:vim /etc/dhcpd.conf

拷贝配置文件模版,在编辑界面命令行模式::r /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample(有几个网段拷贝几次模版)

1.拷贝完后将此相同部分删除,只留最前面

            *ddns-update-style none;(此处可以选择三种模式:none|interim|ad-hoc)注意:配置文件中必须包含这一个参数并且要放在第一行。

          #作用:定义所支持的

          #none

          #interim

          #ad-hoc

            *ignore client-updates;作用:忽略客户端更新

2.配置网关、子网掩码、nis域、(根据需求而定可以默认):

# --- default gateway
        option routers                  192.168.0.1;网关
        option subnet-mask              255.255.255.0;掩码

        option nis-domain               "domain.org";nis域

        option domain-name              "domain.org";默认搜索区域

        option domain-name-servers      192.168.1.1;为客户端指定DNS服务器

        option time-offset              -18000; # Eastern Standard Timerange dynamic-bootp 192.168.0.10 192.168.0.60;

         *range dynamic-bootp 192.168.0.10 192.168.0.60;子网声明
         default-lease-time 21600;默认租约时间
         max-lease-time 43200;最大租约时间

主机声明*host test1 {

                注意:主机声明中主机名不能完全相同,例如可以是:test1   test2   test3

                next-server marvin.redhat.com;
                hardware ethernet 12:34:56:78:AB:CD;这个选项和windows中的主机保留是一样的,当启动时核对mac地址如果符合则分配保留ip
                fixed-address 207.175.42.254;保留ip
        }

我这个是192.168.0.0/24网段的,我还做了192.168.1.0/24和192.168.2.0/24网段的,同样是拷贝模版文件来按照上面的流程修改,值得注意的是我上面标星“*”处在一个配置文件中是不允许重复的。

(三)启动服务:service dhcpd restart

(四)添加默认 的网关:route add default gw 192.168.0.1(就是dhcp中继服务器ip地址)

 DHCP中继服务器:

环境:Red Hat Enterprise Linux Server release 5.2,并为其添加三块网卡(我们是以三个网段为例)

(一)同样是安装DHCP软件包和上面步骤一样

(二)修改网卡ip地址(vim /etc/sysconfig/network-scripts/ifcfg-ethX):

修改第一块网卡地址为:192.168.0.1(为dhcp服务器第一个网段的网关地址)

修改第一块网卡地址为:192.168.1.1(为dhcp服务器第二个网段的网关地址)

修改第一块网卡地址为:192.168.2.1(为dhcp服务器第三个网段的网关地址)

重新启动网卡:service network restart

(三)开启服务器的路由转发功能:

[root@ns1 ~]# vim /etc/sysctl.conf

net.ipv4.ip_forward = 1(此处默认为0,将此修改为1)

[root@ns1 ~]# sysctl -p(刷新使刚才的设置生效)

(五)设置允许DHCP中继数据的接口及DHCP服务器的ip地址:

[root@ns1 Server]# vim /etc/sysconfig/dhcrelay

INTERFACES="eth0 eth1 eth2"
DHCPSERVERS="192.168.0.80"

(六)启动dhcrelay中继服务程序

[root@ns1 Server]# service dhcrelay start

chkconfig --level 35 dhcrelay on

(七)检查dhcp服务器和dhcp中继服务器是否能连通

(八)做测试:

先测试192.168.0.0/24网段:

bubuko.com,布布扣

接着测试192.168.1.0/24网段:

bubuko.com,布布扣

继续测试192.168.2.0/24网段:

bubuko.com,布布扣

也可以在dhcp服务器上查看租约文件查看租约信息

[root@localhost Server]# tail -9 /var/lib/dhcpd/dhcpd.leases
lease 192.168.2.60 {
  starts 1 2011/10/24 09:22:23;
  ends 1 2011/10/24 15:22:23;
  binding state active;
  next binding state free;
  hardware ethernet 00:0c:29:75:49:9c;
  uid "\001\000\014)uI\234";
  client-hostname "jia-pc";

}

哈哈~到此为止dhcp服务器和dhcp中继服务器就搭建好了。。简单哇!只不过中间有些细节挺值得注意的!!


 


本文出自 “精彩IT圈” 博客,请务必保留此出处http://jiagd.blog.51cto.com/3915719/1430767

RHEL DHCP服务器及其中继,布布扣,bubuko.com

RHEL DHCP服务器及其中继

标签:dhcp   rhel   服务器   

原文地址:http://jiagd.blog.51cto.com/3915719/1430767

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!