DHCP leases by Bash Script

Hi there guys.

I`m having a problem with the DHCP leases, it is saying that the IP address can’t be allocated.

I can´t find how to assing the leases by a comand line, I need to configure at least 140 IP address per server.

Can somebody helpme??

1 Like

Hi @hector

If you have a list of hosts you want placed in DHCP (reservations), simply edit the file Hosts in /var/lib/nethserver/db/.
The used format is fairly straightforward, especially if there are already hosts in that file.

You can use any preferred tool to manipulate that, just check it afterwards!
Eg: CSV import into Excel, then merging the data and reexporting…

You simply could also allocate a large enough DHCP pool, add the hosts to the network and let NethServers DHCP allocate the hosts to IPs. Afterwards you can allocate static IPs for any or all of those hosts, as you wish, in Nethservers Cockpit.

All roads lead to Rome, just choose the easiest and safest route!

My 2 cents
Andy

2 Likes

Thanks Andy!!! that was I was looking for; I’ll try and give comments if it work.

Thank you All.

@hector

I’ve done that several times in the past, never had issues except for my own typos…
(Migrating SME to NethServer, SBS to NethServer…)

The biggest headaches were from MS, they are the only ones who do not stick to the global standard notation of MAC adresses: aa:bb:cc:33:22:11.
MS uses 2 diferent formats, depending where:
AABBCCDDEEFF11
or
AA_BB_CC_DD_EE_FF_11

But nothing a bit of encoded logic can’t solve…

My 2 cents
Andy

@Andy_Wismer the edit of DHCP settings on the cockpit interface will overwrite the hosts file you mentioned?

@pike

Yes, that is where the DHP server in Nethserver keeps its records.
As it’s very unlikely that a new host will come online on the day IT is planning to add 140 hosts, there should be no conflict of access to that file. The DHCP server will “see” the records, and accept them.
The DN hosts file can be edited, eg to allocate a new IP, from NethServers Cockpit, even the old NethGUI will accept this. But it can also be edited by the administrator, to pre-allocate a large number of hosts, which is common in medium to large environments.

Worst thing which can happen: A single host does not get the IP when attaching to the network… So what, who cares? It will work soon after, and that host will also get it’s IP…

My 2 cents
Andy

Anyway the reminder “file and settings will be destroyed if you edit/save on the cockpit interface” should be mentioned when giving the tip

@pike

Stop giving out FAKE Information Pike, especially as you have NO IDEA of what is involved, and never used it yourself!

You will ONLY lose Information, if you specifically delete it from Cockpit.

Exactly the same as editing a Word file on a file server from two different workstations.
The file lock will prevent both modifying the file at the same time in this case.

In the NethServer file case, it’s the administrator preventing simultanous modification to the file, and if the administrator allows non-admins access to editing a server config file, that’s beyond the scope of this discussion. It’s an absolute No-Go!

It’s that simple.

→ No warning needed, except maybe for some fake news, by overzealous paranoia…

My 2 cents
Andy

1 Like