使用linux操作系统搭建dhcp服务器
作者 佚名技术
来源 Linux系统
浏览
发布时间 2012-03-27
|
在linux环境下搭建Dhcp服务器
(1) 配置dhcp服务器端---安装dhcp服务:
dhcp-3.0.5-23.el5.i386.rpm (dhcp主要配置包)
dhcpv6-1.0.10-18.el5.i386.rpm (dhcp工具包)
rpm -ivh dhcp-3.0.5-23.el5.i386.rpm (可以使用rpm或者yum安装)
(2)配置dhcp服务器:
rpm -qc dhcp 查看dhcp中可配置的脚本
rpm -ql dhcp |less 查看dhcp包的安装位置
Dhcp的主要配置文件为:/etc/dhcpd.conf 进入进行编译
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
#
ddns-update-style interim;
ignore client-updates;
subnet 192.168.10.0 netmask 255.255.255.0 { (建立作用域)
# --- default gateway
option routers 192.168.10.254; 网管地址:
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "test.ct"; 服务器名标识
option domain-name-servers 222.88.88.88,222.85.85.85; 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.10.10 192.168.10.30; 地址池
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 00:0c:29:cf:12:2a;
fixed-address 192.168.10.2;
}
}
:r /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample (在底行使用此方法获取该文件的配置脚本参考)
(3)编译完成后 执行下面命令可以检查脚本是否有错,并可根据报错找出位置
[root@luo Server]# service dhcpd configtest
Syntax: OK (此为没错)
(4)启动dhcp服务
chkconfig dhcpd on 或者 service dhcpd start
(5)在dhcp客户端(linux)获取地址:
在命令行中使用 dhclient工具获取地址,linux dhcp服务器分配地址的顺序是由大到小
dhclient -d eth0 从eth0网卡获取地址
此时便可以看到获取的地址是192.168.10.30,是从192.168.10.3服务器上获取的
我们绑定的主机也获取到了相应的ip
当然对比一下,在windows安装配置dhcp服务器那更是小菜一碟
(6)如果网络内存在上千台主机,那么上叙的配置是远远不行的
这里我们需要使用超级作用域了,顾名思义,超级作用域是一个很大域,里面有若干个小的子作用域组成windows下配置如下:
那么linux下呢,我们可以这样来:
使用一个 shared-network test{ 子作用域 } 例如:
ddns-update-style interim;
ignore client-updates;
shared-network test{
subnet 192.168.20.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.20.254;
|
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn
为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
|