Hosts file import


I am migrating my DNS/DHCP/LDAP server from clearOs 6 to Nethserver 7.

I managed how import users (without password, but its is ok for me).

I now want to import my DNS entrys (about 130 lines in my /etc/hosts file).
ClearOs also use dnsmasq as DNS server.

I wonder if there is a way to import all.
Entering it one by one in the web admin interface is pretty long.

Thank you form your help.

I found this. It seem to work.

Am I sending the right signal-event ?

db hosts set remote Description DescriptionHere5 IpAddress
db hosts set remote Description DescriptionHere6 IpAddress
db hosts set remote Description DescriptionHere7 IpAddress
db hosts set remote Description DescriptionHere8 IpAddress
signal-event nethserver-dnsmasq-update
signal-event nethserver-hosts-update

1 Like

I am answering my own question.
I hope it will help someone else.

My HOSTS file was in this format (dnsmasq from clear0s 6) localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
ā€¦ so on

I had 130 lines, but 250 entries.

To import, clean up your exported HOSTS file (take out and ::1 lines, and extra text if so)

Execute that command :
cat cleanedHOSTSfile.txt | awk ā€™ { for ( i = NF ; i > 1 ; i-- ) {print "db hosts set ā€œ$iā€ remote Description ā€œ$iā€ IpAddress "$1}}ā€™ >> ImportHOSTS.txt

Then you can chmod +x ImportHOSTS.txt, and execute it.

Finally, send these signal-event
signal-event nethserver-dnsmasq-update
signal-event nethserver-hosts-update

250 DNS entries imported!


Thank you for your solution, it will be useful to other users!