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

Hi,

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.

THX

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

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 10.1.1.113  MacAddress c8:3a:35:d6:c8:b1
signal-event nethserver-dnsmasq-update
1 Like

Hi, I have approx. 30 hosts to maintain.

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

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 10.1.1.150
00:16:3e:00:00:02 kvm2 10.1.1.200

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

read-ethers

and run

signal-event nethserver-dnsmasq-update

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

Try from full path

signal-event
usage:
/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!

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?

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

/sbin/e-smith/db

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

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
./host_import.sh

4 Likes

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

@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.

1 Like

This is an old thread I know but wondering if this info is still true and a valid method of doing a mass import of new entries specifically for DNS entries /etc/hosts.

I attempted the the steps @Nas wrote…

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 10.1.1.150
00:16:3e:00:00:02 kvm2 10.1.1.200

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

read-ethers

and run

signal-event nethserver-dnsmasq-update

But I never see any new entries make it into /etc/hosts. Pinging devices included in /etc/ethers after doing the aobe by hostname also does not translate.

There has to a be working method to do am ass import of entries into /etc/hosts and play nice with the programming side of this setup. Manually adding hundreds of new entries into DNS from the GUI is out of the question.

Any help is greatly appreciated.

1 Like