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


#1

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


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

#4

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

DNS import for 178 hosts
#6

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

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


#8

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


#10

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>


#12

What should be used?

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


(Artem Fedai) #13

/sbin/e-smith/db


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


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