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 10.10.10.0/24
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 10.10.10.100, "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
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:
calling it with a flat file with contents like this:
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:
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
which generates files like
I used the contents of the Key: line from the private file
Edit yout dhcp.conf file and add
}; omapi-key omapi_key;
using the key generated above.
Start dhcpd
now you can use omshell to add hosts
Now you can add host entries as explained in the man page.
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.