DHCP Server
From OpenBSD-Wiki
| Written for: OpenBSD Version 4.2 |
Contents |
[edit] Overview
The default DHCP server daemon is dhcpd(8). Its main config file is /etc/dhcpd.conf, see dhcpd.conf(5).
[edit] Startup
To start dhcpd at boot time, append the following to /etc/rc.conf.local:
dhcpd_flags=""
The interfaces the daemon should answer on are listed in /etc/dhcpd.interfaces. Just add the name of the interface, or multiple names separated by whitespaces.
if0 if1
In OpenBSD 4.3 and above, the dhcpd.interfaces file is ignored. You may specify the name(s) of interfaces that the daemon should listen to in the dhcpd_flags variable in /etc/rc.conf.local
dhcpd_flags="fxp1"
After configuration you may load the daemon by hand and save yourself a reboot.
# /usr/sbin/dhcpd if0
[edit] Configuration
A minimal configuration for a home network might look like this, with DNS addresses from OpenDNS:
option domain-name "localdomain";
option domain-name-servers 208.67.222.222, 208.67.220.220;
subnet 192.168.0.0 netmask 255.255.255.0
{
option routers 192.168.0.1;
range 192.168.0.11 192.168.0.20;
}
If you configured name and time server(s) on your network, have a Samba or Windows server operating, and offer clients to boot from network, consider this example:
option domain-name "my.domain";
option domain-name-servers 10.0.0.11, 10.0.0.12;
option netbios-name-servers 10.0.0.21;
option ntp-servers 10.0.0.1;
subnet 10.0.0.0 netmask 255.255.0.0
{
option routers 10.0.0.1;
range 10.0.1.1 10.0.2.254
filename "pxeboot";
}
Note: the example configuration in the original dhcpd.conf file has a shared-network declaration. If you do not have more than one subnet on a physical interface, this declaration is not needed, but won't hurt either.
If you want to have a certain MAC address always get the same IP then you would add a host mapping. Below is an example. Replace "somename" with whatever label you would like to attach to it. The clients don't care about the label so make it descriptive for yourself. This part is useful for e.g. port forwarding, but you need to maintain DHCP for simplicities sake (for example, you have a laptop you take to work and bring back home; so keeping DHCP makes your life a bit easier with less settings to change).
host somename
{
hardware ethernet 00:01:02:03:04:05;
fixed-address 10.0.3.1;
}
[edit] Testing
Finally you should check if your config file is correct. You should also do this every time you change it by running the following command:
# /usr/sbin/dhcpd -n
If it stays quiet everything is alright.
[edit] Links
[edit] Comments
Place your comments here.
