In this article I’m going to explain some tricks that you can use to create custom dhcp address pools using dhcpd.conf on CentOS 5.3. I was at a client recently and they had a need to hand out different TFTP servers to different sets of phones on their network. Their Cisco 7960 phones needed to see one tftp server that contained an older SIP firmware, and their 7961 phones needed to see a separate tftp server with newer firmware. I’ve already explained how to setup multiple TFTP servers on a single box, now, I’ll show you how to setup your dhcpd.conf file to hand out the different settings.
First, let’s take a look at the file itself.
ddns-update-style none;
option domain-name "example.com";
option domain-name-servers 10.10.11.254;
default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;
All of this is really basic stuff, and you can set these settings based on your specific network needs. This is where it starts getting good:
class "cisco7960"
{
match if substring (option vendor-class-identifier,0,36) = "Cisco IP Phone 7960";
option tftp-server-name "10.10.11.254";
}
Here we’re defining a special class that will receive parameters that override the default. As you can see, this class is for our Cisco 7960′s, and we’re matching based on the vendor-class-identifier, which is part of the DHCP REQUEST packet that the phone sends out onto the network when it first looks for an address. More on how to find this information in a minute.
class "cisco7961"
{
match if substring (option vendor-class-identifier,0,36) = "Cisco Systems, Inc. IP Phone CP-7961";
option tftp-server-name "10.10.10.1";
}
This is the vendor-class-identifier string for a Cisco 7961.
class "polycom"
{
match if substring (hardware,0,10) = "1:00:04:f2";
option tftp-server-name "10.10.10.1";
}
Now, we won’t actually use this polycom class for anything in our setup, I just wanted to show how you can also match classes based on the phone’s MAC address, not just the vendor identifier string.
Below, we’ll look at the default settings for any device requesting an IP address on this vlan:
subnet 10.10.10.0 netmask 255.255.254.0 {
option subnet-mask 255.255.254.0;
option routers 10.10.10.1;
option domain-name-servers 10.10.10.1;
option ntp-servers 10.10.10.1;
option time-offset -21600;
allow bootp;
range 10.10.10.50 10.10.10.200;
range dynamic-bootp 10.10.10.201 10.10.10.254;
Now, we’ll add in the pool definitions that will match based on the classes we defined earlier. This is still a part of the subnet declaration we started in the last section.
pool {
range 10.10.11.25 10.10.11.149;
allow members of "cisco7961";
}
pool {
range 10.10.11.150 10.10.11.225;
allow members of "cisco7960";
}
And lastly, we’ve got static leases for specific phones, based on their MAC addresses. I realize I wasn’t really talking about how to do this in the current article, but it’s something I always have to look up how to do, so I figured it wouldn’t hurt to add it into the post.
host conf2570 {
hardware ethernet 00:04:f2:e1:cf:a5;
fixed-address 10.10.10.204;
}
host conf2571 {
hardware ethernet 00:04:f2:e1:8d:2e;
fixed-address 10.10.10.209;
}
}
And that’s the end of the file. Now, I mentioned earlier that I’d explain how to find the vendor-class-identifier string for a new phone as it sends out it’s DHCP REQUEST packets. Here’s what you need to do. From the shell on your dhcpd server, run the following command while you’re booting your phone:
root@server [~]# tcpdump -lenv -s 1500 port bootps or port bootpc -i eth1
If you don’t want to flood your screen, you can pipe it to a log file by adding ” > logfile.txt” to the end of the above line. This is the type of output you should expect to see, I’ve highlighed the important information to watch for:
16:19:44.691011 00:26:0b:5d:0f:48 > 00:22:19:22:db:c6, ethertype IPv4 (0x0800), length 590: (tos 0x60, ttl 64, id 53013, offset 0, flags [none], proto: UDP (17), length: 576) 10.10.11.146.bootpc > 10.10.10.1.bootps: BOOTP/DHCP, Request from 00:26:0b:5d:0f:48, length: 548, xid:0x7ba0, flags: [none]
Client IP: 10.10.11.146
Client Ethernet Address: 00:26:0b:5d:0f:48
Vendor-rfc1048:
DHCP:REQUEST
CID:[ether]00:26:0b:5d:0f:48
HN:"SEP00260B5D0F48"
VC:"Cisco Systems, Inc. IP Phone CP-7961G^@"
PR:SM+TFTP+NS+DG+DN+T150+AT
You can pull a lot of data from these tcpdumps, and find whatever unique characteristics you want to create your pools. But these ones I’ve given you should get your started on the right path for now. If you have any questions, feel free to leave a comment, or you can contact me!
One Response to “Customizing dhcpd.conf on CentOS 5.3”




can you please tell me what does the “1″ stands for before the MAC?
match if substring (hardware,0,10) = “1:00:04:f2″;