Hosts file import

Hi,

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 hostname5.test.com remote Description DescriptionHere5 IpAddress 10.10.10.5
db hosts set hostname6.test.com remote Description DescriptionHere6 IpAddress 10.10.10.6
db hosts set hostname7.test.com remote Description DescriptionHere7 IpAddress 10.10.10.7
db hosts set hostname8.test.com remote Description DescriptionHere8 IpAddress 10.10.10.8
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)

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.3 hostname1.test.com hostname2.test.com www.test.com
10.0.0.5 hostname3.test.com
10.0.0.6 hostname6.test.com hostnnn.test.com
10.0.0.7 hostname7.test.com
ā€¦ so on

I had 130 lines, but 250 entries.

To import, clean up your exported HOSTS file (take out 127.0.0.1 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!

2 Likes

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