分类: LINUX
2010-07-21 14:54:47
1.
#rpm -ql dhcp 查询DHCP相关文件的位置
2.
/etc/下默认没有dhcpd.conf这个文件
#cp
/usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample /etc/dhcpd.conf
3.
#vi
/etc/dhcpd.conf
ddns-update-style interim; (全局参数)
ignore
client-updates;
subnet 192.168.1.0(网络号) netmask
255.255.255.192(子掩){
# --- default gateway
option routers
(网关) 192.168.1.2;
option subnet-mask (子掩)
255.255.255.192;
# option nis-domain
"domain.org";
option domain-name "test.com";
option domain-name-servers 192.168.1.1;
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 (WINS服务器)
# option
netbios-node-type 2;
DHCP地址是依次从后面向前分,下面的就是从254开始分发IP。????
(地址
池)range dynamic-bootp 192.168.1.1 192.168.1.62;
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
12:34:56:78:AB:CD;
fixed-address 192.168.1.1;(保留地址)
}
}
4.
启动:
多网卡时,设置从哪块网卡启动DHCP服务
#vi
/etc/sysconfig/dhcpd
注意:
1.分配的IP必须和DHCP服务器在一个网段,否则DHCP服务器无法启动。
2.#dhclient
:CLIENT广播
client和server经过4次会话,都是采用广播方式进行。
3.#netstat -anup
|grep :67 查看DHCP默认端口67。
4。租约文件:
#cd /var/lib/dhcp/
dhclient-eth0.leases
dhclient.leases:
客户机的。
dhcpd.leases :服务器的。
5.DHCP中继代理服务器:
要求知道:
1。DHCP服务器的地址
2。多网
卡时从哪块网卡出去的。
#vi /etc/sysconfig/dhcpd
DHCPDARGS="eth0"
DHCPSERVER=172.16.4.1
#service
dhcrelay start
#ps -ef |grep dhcrelay
HDCP功能扩展:
*******************
7.
DHCP
共享作用域:
#vi /etc/dhcpd.conf
#全局配置:
---略---
#共享作用域配置
shared-network
gdlc {
subnet 192.168.1.0 netmask 255.255.255.0{
option routers 192.168.1.254;
option
broadoast-address 192.168.1.255;
range 192.168.1.100
192.168.1.200;
}
subnet 192.168.2.0 netmask
255.255.255.0{
option routers 192.168.2.254;
option broadoast-address 192.168.2.255;
range
192.168.2.100 192.168.2.200;
}
}
#gdlc是共享网络名.
8.
DHCP多作用域:
8.1
#vi /etc/dhcpd.conf
#
全局配置:
---略---
#多作用域配置
subnet 192.168.1.0 netmask
255.255.255.0{
option routers 192.168.1.254;
option broadoast-address 192.168.1.255;
range
192.168.1.100 192.168.1.200;
}
subnet 192.168.2.0
netmask 255.255.255.0{
option routers
192.168.2.254;
option broadoast-address 192.168.2.255;
range 192.168.2.100 192.168.2.200;
}
8.2
在每个子网里设置一
台中继代理(DHCP服务器和中继代理的IP都是静态的) :
#vi /etc/syscofig/dhcrelay
INTERFACES="eth0"
DHCPSERVERS="192.168.1.199"
启动中继代理即可:
#serviec dhcrelay start
备注:
知道网段和机器数量计算IP范围和子掩的快速方法:
如:
#ipcalc
-bnm 192.168.1.0/26
NETMASK=255.255.255.192
BROADCAST=192.168.1.63
NETWORK=192.168.1.0