DHCP服务器的架设
来源:
作者:
时间:2008-06-24
Tag:
点击:
另外如果主机上安装了两个网卡,但是只想让DHCP服务在其中的一个网卡上监听,则需要配置DHCP服务器只在那个设备上启动。在/etc/sysconfig/dhcpd中,把网卡接口的名称添加到DHCPDARGS列表中。
#Command line options here
最后在客户端上使用netconfig命令设置客户端自动获取地址,完成后重启服务即可。
[root@localhost RPMS]# cat /var/lib/dhcp/dhcpd.leases 在服务器上查看已经分配出去的IP
# All times in this file are in UTC (GMT), not your local timezone. This is
# not a bug, so please don't ask about it. There is no portable way to
# store leases in the local timezone, so please don't request this as a
# feature. If this is inconvenient or confusing to you, we sincerely
# apologize. Seriously, though - don't ask.
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-V3.0.1
lease 192.168.1.200 {
starts 6 2007/03/17 04:36:31;
ends 6 2007/03/17 10:36:31;
binding state active;
next binding state free;
hardware ethernet 00:0c:29:67:57:c1;
}
lease 192.168.1.199 {
starts 6 2007/03/17 04:37:13;
ends 6 2007/03/17 10:37:13;
binding state active;
next binding state free;
hardware ethernet 00:0c:29:ef:cc:aa;
uid "\001\000\014)\357\314\252";
client-hostname "cheshi-eeb7e489";
}
嘿嘿 成功。。。
二,DHCP服务器源码包配置
还是和上面的rpm包一样,我们这次用源码包来设置dhcp服务器,在配置之前首先准备工作:
软件:
gcc
dhcp-4.0.0.tar.gz
1,先安装gcc
[root@localhost cdrom]# rpm -ivh gcc* --aid
2,安装dhcp源码包
首先确定系统上没安装rpm包
[root@localhost dhcp-3.0.2]# rpm -q dhcp
package dhcp is not installed
[root@localhost pub]# tar -zxvf dhcp-4.0.0.tar.gz -C /usr/local/src/
[root@localhost pub]# cd /usr/local/src/dhcp-4.0.0/
[root@localhost dhcp-4.0.0]# ./configure
[root@localhost dhcp-4.0.0]# make
[root@localhost dhcp-4.0.0]# make install
[root@localhost dhcp-4.0.0]# find / -name dhcpd.conf #查找dhcp主配置文件
/etc/log.d/conf/services/dhcpd.conf
/usr/local/etc/dhcpd.conf
/usr/local/src/dhcp-4.0.0/server/dhcpd.conf
[root@localhost dhcp-4.0.0]# cp /usr/local/etc/dhcpd.conf /etc/dhcpd.conf
3,dhcp服务器的配置
[root@localhost dhcp-4.0.0]# cat /etc/dhcpd.conf
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks...
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
#default-lease-time 600;
#max-lease-time 7200;
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
#subnet 10.152.187.0 netmask 255.255.255.0 {
#}
# This is a very basic subnet declaration.
#subnet 10.254.239.0 netmask 255.255.255.224 {
# range 10.254.239.10 10.254.239.20;
# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
#}
# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.
#subnet 10.254.239.32 netmask 255.255.255.224 {
# range dynamic-bootp 10.254.239.40 10.254.239.60;
# option broadcast-address 10.254.239.31;
# option routers rtr-239-32-1.example.org;
#}
# A slightly different configuration for an internal subnet.
subnet 10.0.0.0 netmask 255.0.0.0 {
range 10.10.10.100 10.10.10.200;
option domain-name-servers 10.0.0.253;
option domain-name "crazylinux.com";
option routers 10.0.0.253;
option subnet-mask 255.0.0.0;
option broadcast-address 10.255.255.255;
default-lease-time 21600;
max-lease-time 43200;
}
# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.
#host passacaglia {
# hardware ethernet 0:0:c0:5d:bd:95;
# filename "vmunix.passacaglia";
# server-name "toccata.fugue.com";
#}
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
host crazylinux {
hardware ethernet 00:0C:29:3B:68:25;
fixed-address 10.10.10.150;
}
# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.
class "foo" {
match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
}
shared-network 224-29 {
subnet 10.17.224.0 netmask 255.255.255.0 {
option routers rtr-224.example.org;
}
subnet 10.0.29.0 netmask 255.255.255.0 {
option routers rtr-29.example.org;
}
pool {
allow members of "foo";
range 10.17.224.10 10.17.224.250;
}
pool {
deny members of "foo";
range 10.0.29.10 10.0.29.230;
}
}
4,服务启动
[root@localhost dhcp-4.0.0]# touch /var/db/dhcpd.leases
[root@localhost dhcp-4.0.0]# dhcpd
相关文章: