Archive for September 21st, 2009

Howto install and configure Local DHCP Server for small LAN local network on FreeBSD

Monday, September 21st, 2009

Since some time ago, I’ve been planning to install a DHCP server to automatically assign the IP addressesof 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 cleanFor 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 aswell as the default user home directory to /var/empty
Next I used the following dhcpd.conf file:
— SNAP —option domain-name “www.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 “www.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 addresshost 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 networkwhich 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.netThe variable broadcast-address is the range in which the DHCPD servers will broadcast and eventuallyassign 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.confand change the line
*.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err; /var/log/messageswith*.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 withdhcpd 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.confecho ‘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 🙂 !
END—–