#!/bin/bash
DHCPIPA=192.168.142.0
DHCPIPB=192.168.2.0
DHCPIPC=192.168.3.0
DHCPIPRANGEA="192.168.142.130 192.168.142.254"
DHCPIPRANGEB="192.168.2.130 192.168.2.254"
DHCPIPRANGC="192.168.3.130 192.168.3.254"
DHCPROUTE=192.168.142.128
DHCPROUTEB=192.168.2.1
DHCPROUTEC=192.168.3.1
DNSIP=192.168.142.128
DNSNAME=www.mafei.com
mkdir /mafei
mount /dev/cdrom /mafei
cd /mafei/Server
rpm -ivh /mafei/Server/dhcp-3.0.5-3.el5.i386.rpm
cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf << MAFEI
y
MAFEI
vi /etc/dhcpd.conf << MYMAFEI
:%s/ddns-update-style interim/ddns-update-style none
:%s/subnet 192.168.0.0 netmask 255.255.255.0/subnet $DHCPIPA netmask 255.255.255.0
:%s/192.168.0.1;/$DHCPROUTEA;
:%s/range dynamic-bootp 192.168.0.128 192.168.0.254;/range dynamic-bootp $DHCPIPRANGEA;
:wq!
MYMAFEI
service dhcpd restart
echo "subnet $DHCPIPB netmask 255.255.255.0 {" >> /etc/dhcpd.conf
echo " option routers $DHCPROUTEB;" >> /etc/dhcpd.conf
echo " option subnet-mask 255.255.255.0;" >> /etc/dhcpd.conf
echo " range dynamic-bootp $DHCPIPRANGEB;" >> /etc/dhcpd.conf
echo " default-lease-time 21600;" >> /etc/dhcpd.conf
echo " max-lease-time 43200;" >> /etc/dhcpd.conf
echo "}" >> /etc/dhcpd.conf
echo "subnet DHCPIPC netmask 255.255.255.0 {" >> /etc/dhcpd.conf
echo " option routers $DHCPROUTEC;" >> /etc/dhcpd.conf
echo " option subnet-mask 255.255.255.0;" >> /etc/dhcpd.conf
echo " range dynamic-bootp $DHCPIPRANGEC;" >> /etc/dhcpd.conf
echo " default-lease-time 21600;" >> /etc/dhcpd.conf
echo " max-lease-time 43200;" >> /etc/dhcpd.conf
echo "}" >> /etc/dhcpd.conf
service dhcpd restart
chkconfig --level 35 dhcpd on