Since some time ago, I've been
planning to install a DHCP server to automatically assign the IP
addresses of the hosts in my tiny local network.
Here is how I did it:
First I had to install:
the port isc-dhcpd31-server
Execute the commands:
# cd /usr/ports/net/isc-dhcp31-server;
# make install clean
For some reason the dhcpd reason didn't get created, so I have to
issue.
pw add user dhcpd;
After which use vipw to change the default shell for the dhcpd user to /usr/sbin/nologin as
well as the default user home directory to /var/empty
Next I used the following dhcpd.conf file:
--- SNAP ---
option domain-name "pc-freak.net";
option domain-name-servers 83.228.92.2, 83.228.92.2;
default-lease-time 600;
max-lease-time 7200;
# Use this to enble / disable dynamic dns updates globally.
ddns-update-style ad-hoc;
# 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 {
}
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.2 192.168.0.255;
option domain-name-servers 192.168.0.1;
option domain-name "pc-freak.net";
option routers 192.168.0.1;
option broadcast-address 192.255.255.255;
default-lease-time 3600;
max-lease-time 7200;
}
# the lines below enables you to assign specific IP addresses depending on
# machine's MAC address
host jericho {
hardware ethernet 00:13:2a:33:7d:1e;
fixed-address 192.168.0.2;
}
host noah {
hardware ethernet 00:0b:e4:c9:7b:59;
fixed-address 192.168.0.4;
}
--- END ---
You might need to change some of the IP addresses the conf above is
configured for my local network which is in the IP range
192.168.0.2 to 192.168.0.255.
The above conf file's name servers are my ISP's nameservers
ns.bergon.net and ns1.bergon.net The variable
broadcast-address is the range in which the DHCPD
servers will broadcast and eventually assign IP addresses.
routers variable sets your network default router
in my case it's my local gateway.
range variable is self explanatory.
subnet is the subnet in which your network
is.
max-lease-time is the time interval in which a
DHCP IP reassign occurs
default-lease-time the default time on which IP
reassign occurs
The rest could be red in the commentaries above the
variables:
To make dhcpd log in a separate file it's also necessery to edit
your
/etc/syslog.conf and change the line
*.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err; /var/log/messages
with
*.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err;local7.!*; /var/log/messages
as well as add:
local7.* /var/log/dhcpd
to /etc/syslog.conf.
The above changes in syslog.conf should foce syslogd to log to
/var/log/dhcpd instead of stuffing your /var/log/messages with
dhcpd log output
It's also necessary to create /var/log/dhcpd's file:
Execute:
touch /var/log/dhcpd as well as restart
the syslogd
/etc/rc.d/syslogd restart .
Futhermore execute:
echo 'dhcpd_enable="YES"' >> /etc/rc.conf
echo 'dhcpd_iface="rl0"' >> /etc/rc.conf
The above as you probably know will schedule isc-dhcpd to start up
every time your system boots.
Well you should be now having a shiny spreading dhcpd service in
your local network.
Enjoy and Praise God
!