# Configuring DHCP server



## freebird1 (Apr 26, 2014)

I want my virtual router (freebsd FreeBSD and in Virtualbox) to be a DHCP server so it can give its own IP addresses to the virtual clients on the network.  I installed isc-dhcp42-server, but it did not install the dhcpd.conf.example file.  So I'm creating it by hand using the example from the FreeBSD handbook.  However, some of the options I don't know how to apply it to my own situation of a virtualized network.

For a domain name, I don't have one.  But I can make one up just to serve the purpose.  But for the routers and the dns servers, I am going to rely on my freebsd FreeBSD router.  So would I type something like this:


```
option domain-name-servers freebsdrouter;
option routers freebsdrouter;
```

And also, in the host fantasia function, whose MAC address is referenced there?  I'm assuming it's the ethernet card of the DHCP server.  But if that's the case, how is this referring to the client's MAC address as I'm not understanding the correlation of the explanation.  Or I'm over thinking...as I know what DHCP does but this function makes no mention of a DHCP client's MAC address but the server itself who already has an IP address.  (I don't think I explained this correctly 

Thanks


----------



## asteriskRoss (Apr 26, 2014)

The example configuration file for net/isc-dhcp42-server should be located at /usr/local/etc/dhcpd.example.conf.  If you want to use a local domain name then you can choose whatever you want.  Using something ending in the special use domain name ".local" (see RFC 6762) would be sensible in case a misconfiguration means that your domain name is queried outside your network.

Using names rather than IP address in dhcp.conf options is fine, but you will need a DNS server running before your DHCP server starts for this to work properly.  If this is your first time setting something like this up, I suggest you start by configuring your DHCP server with IP addresses rather than names and then move on to names once your DNS server is up and you have worked through the dependencies.  Edit: Another option that occurred to me is that you may be able to use /etc/hosts for resolving names and switch later to your DNS server once you have it up and running.

Lastly, you mentioned the "host fantasia" function, which I'm guessing you are referring to from the /usr/local/etc/dhcpd.example.conf file (which must mean that you do have it?).  In the host declaration, the MAC address refers to the MAC address of the client machine, that is, the one requesting an IP address from the DHCP server.  Implementing the declaration below would mean that the network interface with MAC address 08:00:07:26:c0:a5 of a client that requested an IP address would be assigned the IP address returned by a DNS query for fantasia.fugue.com.

```
host fantasia {
  hardware ethernet 08:00:07:26:c0:a5;
  fixed-address fantasia.fugue.com;
}
```

Whether you will be able to configure different MAC addresses for your virtual clients will depend on your virtual machine software's capabilities and configuration.


----------



## freebird1 (Apr 26, 2014)

Aha ok thanks.  
No, I got the dhcpd.conf.example from the FreeBSD manual.  It gave an example so I followed it.  Do I need the fantasia function though or can it be done dynamically?  Meaning...I don't want to statically type in MAC addresses of my clients.  Not yet anyways.  I want, for now, the router to act like a DHCP server that will give to any MAC address whether it has it in its MAC tables or not.


----------



## kpa (Apr 26, 2014)

Default operation of a DHCP server is to assign a random IP to an unknown client (MAC address) or to re-use an address that was previously assigned to the same MAC address. Unless you need to make sure that a host always gets the same IP address there's no need for the host entries.


----------

