Dhcp.conf example

One thing that gets to us about the internet is that there is not that many examples of everyday use of config files or scripts.  So here is a start.

This is an example of a dhcpd.conf (Version-3) file for someone who has a large network and is going to need multiple subnets (groups of ip’s) going out of one network card and then is going to need different ip addresses going out of another network card etc.

I have set the lease times very short this is for testing purposes if you are going to use it I would suggest you increase the times.

So in this example I have a box that has four network cards in it and is going to have multiple networks connected to it and is also going to deny anyone a ip address unless there is a host declaration. Now the cool part is that you will only have to add host declarations to the first section because the DHCP daemon is smart enough to know if someone is plugged into eth2 only give out ip’s in the range associated to the card.

eth0—outside network

eth1–one gateway with ip address of 10.10.10.1 and has aliases of 10.10.150.1

eth2–another gateway with ip address of 10.10.2.1

eth3–another gateway with ip address of 10.15.2.1

each nic can have a vlan or a physical network plugged into it and the DHCP server will only hand out ip addresses that belong to that nic card.  The only problem that we have come across so far is that you can not have duplicate host declarations.

 

authoritative;
ddns-update-style ad-hoc;
max-lease-time 60;
default-lease-time 60;
dynamic-bootp-lease-length 60;
option domain-name-servers 10.10.10.1, 10.10.100.2;
shared-network COMPANY-NAME-ETH1 {
subnet 10.10.10.0 netmask 255.255.254.0 {
option routers 10.10.10.1;
option broadcast-address 10.10.11.255;
range 10.10.10.2 10.10.10.254;
range 10.10.11.2 10.10.11.254;
deny unknown-clients;
}
subnet 10.10.150.0 netmask 255.255.254.0 {
option routers 10.10.150.1;
option broadcast-address 10.10.160.255;
range 10.10.150.2 10.10.150.254;
range 10.10.151.2 10.10.151.254;
deny unknown-clients;
}
}
host XX1 { hardware ethernet 00:02:2a:b1:38:de; }
host XX2 { hardware ethernet 00:01:02:c6:f5:4e;}

authoritative;
ddns-update-style none;
max-lease-time 60;
default-lease-time 60;
dynamic-bootp-lease-length 60;
option domain-name-servers 10.10.10.1, 10.10.100.2;
shared-network COMPANY-NAME-ETH2 {
subnet 10.10.2.0 netmask 255.255.255.0 {
option routers 10.10.2.1;
range 10.10.2.100 10.10.2.200;
deny unknown-clients;
}
}
authoritative;
ddns-update-style none;
max-lease-time 60;
default-lease-time 60;
dynamic-bootp-lease-length 60;
option domain-name-servers 10.10.10.1, 10.10.100.2;
shared-network COMPANY-NAME-ETH3 {
subnet 10.15.2.0 netmask 255.255.255.0 {
option routers 10.15.2.1;
range 10.15.2.2 10.15.2.254;
deny unknown-clients;
}
}

 

Be the first to comment

Leave a Reply