#!/bin/sh
echo ""
echo "Configuring DHCP Server"
echo ""

IFCONFIG=`which ifconfig 2>/dev/null||echo /sbin/ifconfig`
IPADDR=`$IFCONFIG eth0|gawk '/inet addr/{print $2}'|gawk -F: '{print $2}'`

cat > /etc/dhcpd.conf <<EOF
ddns-update-style interim;
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 nis-domain               "asterisk.local";
  option domain-name              "asterisk.local";
  option domain-name-servers      192.168.1.1;
  option time-offset              -18000; # Eastern Standard Time
  option ntp-servers              $IPADDR;
  option tftp-server-name         "$IPADDR";

  range dynamic-bootp 192.168.1.128 192.168.1.254;
  default-lease-time 43200;
  max-lease-time 86400;
}
EOF

chkconfig --level 2345 dhcpd on

echo "Created /etc/dhcpd.conf and set dhcpd to autostart on reboot."
echo "you can edit /etc/dhcpd.conf and add you own options"
echo ""
