[Q] How to import / manually edit hosts database for IP reservation?



I’m migrating to nethserver.
To continue using DHCP with IP reservation, I want to import an existing host file.
Or is it possible to manually maintain the host file in nethserver?

If not it would be inefficient to maintain every single host in WebUI.


(Artem Fedai) #2

Hi , i try to help you, how many hosts do you have?

DNS import for 178 hosts
(Artem Fedai) #3

Your task could be done with 2 ways or maybe 3 :slight_smile:
So first if you want to see your hosts in WEB UI you need to do this :

db hosts set nas local Description lol IpAddress  MacAddress c8:3a:35:d6:c8:b1
signal-event nethserver-dnsmasq-update


Hi, I have approx. 30 hosts to maintain.

Unfortunately I cannot completely understand what you recommend to maintain the hosts for IP reservation.

DNS import for 178 hosts
(Artem Fedai) #5

so if you need to add 30 hosts make file /etc/ethers
cat /etc/ethers
# see man ethers for syntax
00:16:3e:00:00:01 kvm1
00:16:3e:00:00:02 kvm2

and make custom template for dnsmasq.conf file
mkdir -p /etc/e-smith/templates-custom/etc/dnsmasq.conf
cp /etc/e-smith/templates/etc/dnsmasq.conf/30dhcp /etc/e-smith/templates-custom/etc/dnsmasq.conf/30dhcp
vi /etc/e-smith/templates-custom/etc/dnsmasq.conf/30dhcp
and add at the and of file


and run

signal-event nethserver-dnsmasq-update

DNS import for 178 hosts

When I run command I get error message “signal-event: command not found”

[root@vm101-nethserver]# signal-event nethserver-dnsmasq-update
bash: signal-event: command not found

(Artem Fedai) #7

Try from full path

/sbin/e-smith/signal-event eventname [arg1 [arg2…]]


Full path is working.

But I was expecting to see the list of servers maintained in “/etc/ethers” in the WebUI:
Configuration -> DHCP -> IP Reservation

But the table is empty!

(Artem Fedai) #9

I write you 2 variants of make things work :slight_smile:
1 wariand about db you could try it and see that Host would be seen in the WebUI: Configuration -> DHCP -> IP Reservation

2 variant is about Dnsmasq cheat trick , so this hosts you couldnot see in WebUI


Ah… now I understand…

However, I want to see the hosts listed in WebUI. But then I should execute the command

db hosts set nas local Description <host> IpAddress <ip>  MacAddress <mac>

How can I automate the maintenance using a script that reads all hosts from /etc/ethers?

(Artem Fedai) #11

db hosts set <user name> local Description <host> IpAddress <ip> MacAddress <mac>


What should be used?

The command “db hosts set […]” fails again with error:
bash: db: command not found

(Artem Fedai) #13


(Stefano) #14

are you logged in as root or as another user?

if the latter, please do

su -

common users miss the right path to db command

(Artem Fedai) #15

you could make bash script that would cat /etc/ethers
cat /etc/ethers | awk ‘{print "db hosts set “$2” local Description " $2 " IpAddress " $3 " MacAddress " $1}’ > host_import.sh && chmod +x ./host_import.sh
and then simply run this script

(Alessio Fattorini) #16

@cmonty could you try @nas script and give us a feedback? It could be a good import script :smile:

(Artem Fedai) #17

@alefattorini it would be great if @cmonty put header of his file or even make dump from Zentyal , it would be very usefull for our Community. Evenmore @giacomo could make WebUI integration for import static dhcp list.