Category:

Setting up a DHCP server in FreeBSD

d01ce55cc77017c9ac0adb400f231288

The setup took place at me on the HP ProLiant G4 DL360 server which has 2 Gigabit interfaces (by default bge0 and bge1), you can have both eth0 and eth1. But the point is not this, 2 interface we will need to raise the DNS server, and here we will do one. I chose bge0 ( it will work at the output and give out network addresses to subscribers, it is prescribed respectively a static network address (in my case 10.79.50.1), in rc.conf can be and through sysinstall. The DHCP server will run through chroot by default.

Serviced by server range: 10.79.50.0 — 10.79.50.254, with each known to us the network card do the "permanent record" on the basis of the mac address with a static ip address in the range from 10.79.50.10 to 10.79.50.199, and select the range 10.79.50.200 — 10.79.50.254 for all other computers in the network.

Installation.

Check the version of the installed system:

uname -sr
FreeBSD 9.1-PRERELEASE

pkg_info | grep dhcp
isc-dhcp42-server-4.2.4_2 The ISC Dynamic Host Configuration Protocol server

Install from ports:

cd /usr/ports/net/isc-dhcp42-server
make install clean

In the window that appears, select:

[ ] BIND_SYMBOLS Enable BIND internal symbol table
[ ] IPV6 IPv6 protocol
[ ] LDAP LDAP support
[ ] LDAP_SSL Support LDAP over SSL/TLS
[*] PARANOIA Enable support for chroot

During installation, the server will create the user and group dhcpd. After that, you need to configure our interfaces.
Add in the config /etc/rc.conf:

dhcpd_enable="YES"
dhcpd_flags=-q;
dhcpd_conf="/usr/local/etc/dhcpd.conf"
dhcpd_ifaces="ale0"
dhcpd_withumask="022"

And:

dhcpd_chuser_enable="YES"

dhcpd_withuser="dhcpd"

dhcpd_withgroup="dhcpd"

dhcpd_chroot_enable="YES"

dhcpd_devfs_enable="YES"

dhcpd_rootdir="/var/db/dhcpd"

dhcpd_includedir=""

Then edit the configuration file of the DHCP server (dhcpd.conf) which lies in /usr/local/etc/:

ee /usr/local/etc/dhcpd.conf

File contents:

option domain-name-servers 10.79.50.1; #dns server address
default-lease-time 600; #IP address lease time, default maximum
max-lease-time 7200;
authoritative; #specifies that there will be only one DHCP server on the network
log-facility local7; #for logging
subnet 10.79.50.0 netmask 255.255.255.0 { 
range 10.79.50.200 10.79.50.254; 
option domain-name "guest";
option routers 10.79.50.1;
option broadcast-address 255.255.255.255; 
} #describe the network itself

range - start and end ip addresses that our server gives to clients;

option routers - IP address of the router

option broadcast-address - address for broadcast requests

For each network card that we want to register on the server, and which will have a fixed network address:

host HOSTNAME { # hostname
hardware ethernet XX:XX:XX:XX:XX: XX: XX; # Mac address of the computer
fixed-address 10.79.50.105; # the ip address we want to assign
option domain-name "home"; # domain
option routers 10.79.50.1; # gateway through which will go
option broadcast-address 255.255.255.255; 
}

Server management commands:

/usr/local/etc/rc.d/isc-dhcpd start #start the server
/usr/local/etc/rc.d/isc-dhcpd stop #stop the server
/usr/local/etc/rc.d/isc-dhcpd restart #reboot server
/usr/local/etc/rc.d/isc-dhcpd status #see the server status

This setting is suitable for the deployment of a small network, and distribution of the Internet.


Posted: 2013-02-21

Comments