We have a hodgepodge of systems that are either static IP addresses, or DHCP reservations. (We don't hand out any addresses except reserved ones). Some servers have multiple Nics, and ILO cards. Its getting annoying to have to scan the subnet to find free IP's to be able to use, especially because a server might be offline for a few mintues when I perform the scan. Any listing seems to be forgotten about quickly..

I would like to create a reservation for every single IP address in my subnets. That would make things quite a bit easier to manage/view. (and afterwards, look at setting up DHCP to do DNS updates too)

I have run the following command:

sudo arp-scan -I eth0

And have a list of all IP's and Mac Addresses. I am about to get a list of all host/dns names as well. (and if they don't have a hostname, I will call it ip-last octet, so for, "ip-100".). That is easy to do with some work in Open Office Calcl

Is there a way to automagically add reservations to the dhcpd.conf file?

I really don't want to hand edit this, as there are hundreds (multiple subnets).

is there an easy way I can call a command to create a reservation, or import a list from CSV? I could find many ways to do this with Windows DHCP, using Net Sh, but not with my CentOS based DHCP server.

I would rather use an existing way, then have to write my own tool.

TL:DR - I need a way to modify Cento's DHCPd from the command line, like you can in Windows with Netsh


I suppose you are using ISC DHCPd. In this case just add

host client_name {
    hardware ethernet 00:00:de:ad:be:ef;

to your scope in /etc/dhcpd.conf.

Of course, you would not "hand-edit" this but rather create a short script that would spit out the necessary host definitions per scope. Something like that would do:

function hostdef {
        echo host $1 {
        echo -e \\thardware ethernet $2\;
        echo -e \\tfixed-address $3\;
        echo }

cat $1 | while read name mac ip; do hostdef $name $mac $ip; done

calling it with a flat file with contents like this:

ip-100 00:00:de:ad:be:ef
ip-101 00:00:0b:ad:be:ef
ip-102 00:00:0b:ad:de:ed
ip-103 00:00:de:af:be:ef

would generate the necessary lines to paste into your config file or write the output to a separate file which you would include in your dhcpd.conf configuration like this:

include "/etc/dhcpd-reservations-10-10-10.conf";
| improve this answer | |

Have a look at omshell it may do what you want.It allows you to create new host objects which reserve the ip address fot a particular MAC address.

To get omapi listening on your dhcp server

creat a key to secure access

dnssec-keygen -a HMAC-MD5 -b 512 -n HOST omapi_key 

which generates files like


I used the contents of the Key: line from the private file


Edit yout dhcp.conf file and add

omapi-port 9999;
key omapi_key {
algorithm HMAC-MD5;
secret fzg+LkcuXNcnFL1GqwuGv/OafeWEszUjn3dZV0FJkXyPyrOSjqNUKII0NSqEWN8W9/BEakGf9aa/GSV44C0zNQ==;

}; omapi-key omapi_key;

using the key generated above.

Start dhcpd


now you can use omshell to add hosts

> port 9999
> server
> key omapikey fzg+LkcuXNcnFL1GqwuGv/OafeWEszUjn3dZV0FJkXyPyrOSjqNUKII0NSqEWN8W9/BEakGf9aa/GSV44C0zNQ==
> connect
obj: <null>
> new host
obj: host

Now you can add host entries as explained in the man page.

| improve this answer | |

If you're doing anything with OMshell, per Iain's suggestion, bear in mind that those changes are transient. If you create a new lease object for a given MAC address via OMAPI, the object will be lost the next time the server is restarted.

You need to do both - OMAPI to add the reservation to the running server immediately and a script that updates dhcpd.conf for posterity.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.