一、修改dhcp服务器ip地址:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
IPADDR=192.168.1.100
NETMASK=255.255.255.0
BOOTPROTO=static
HWADDR=00:0C:29:AF:43:A6
ONBOOT=yes
TYPE=Ethernet
vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
IPADDR=192.168.2.100
NETMASK=255.255.255.0
BOOTPROTO=static
HWADDR=00:0C:29:AF:43:A7
service network restart 使修改的地址生效
二、挂载光盘并安装DHCP软件包或用yum install dhcp 安装
mount -t iso9660 /dev/cdrom /media/cdrom/
cd /media/cdrom/RedHat/RPMS/
rpm -ivh dhcp-3.0.1-59.EL4.i386.rpm
三、复制dhcpd配置文件的样本
cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf
四、编辑配置文件
vi /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org"; #域名
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
# option netbios-node-type 2;
range dynamic-bootp 192.168.0.128 192.168.0.254;
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 207.175.42.254;
}
}
修改为
ddns-update-style interim; #dhcp服务器和dns服务器内部更新自动协商
ignore client-updates;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1; #网关
option subnet-mask 255.255.255.0; #子网掩码
option domain-name-servers 202.103.24.68,202.103.0.117; #DNS服务器地址
option time-offset -18000; # Eastern Standard Time
# --- 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.1.101 192.168.1.200; #地址池
default-lease-time 21600; #默认租约时间(秒)
max-lease-time 43200; #最大租约时间(秒)
# we want the nameserver to appear at a fixed address
host JTWD01-28 {
next-server marvin.redhat.com;
hardware ethernet 00:1E:90:17:CC:67; #根据主机网卡mac地址分配IP地址
fixed-address 192.168.1.88; #分配的固定IP地址
}
}
subnet 192.168.2.0 netmask 255.255.255.0 {
option routers 192.168.2.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 202.103.24.68,202.103.0.117;
option time-offset -18000; # Eastern Standard Time
# --- 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.2.101 192.168.2.200;
default-lease-time 21600;
max-lease-time 43200;
}
五、应用不同的网络接口:
vi /etc/sysconfig/dhcpd
DHCPDARGS=eth0 // DHCPDARGS=eth1 #仅在eth0上提供dhcp服务
六、开启dhcp服务:
service dhcpd start #stop status restart
注:/var/lib/dhcpd/dhcpd.leases 中记录着DHCP服务器向DHCP客户机提供租用的每个IP地址的信息
七、DHCP中继代理
1)首先安装dhcpd服务(里面包含中继代理服务)
2)启用路由功能:
echo "1" > /proc/sys/net/ipv4/ip_forward
3)然后修改dhcrelay的配置文件:
vi /etc/sysconfig/dhcrelay
加入以下内容:
INTERFACES="eth0 eth1"
DHCPSERVERS="192.168.1.2"
4)给dhcp服务器增加新网段的地址池
5)启动中继服务
service dhcrelay start
6)客户端测试
阅读(21685) | 评论(0) | 转发(1) |