Multiple references in hosts file. Is NS1 also necessary?

After various configurations, in the host file we have the same server referenced 2 times in addition to the one referred to localhost.

First time at the IP address with the server name, as it was initially installed.
A second time with his IP address.
A third time under the name NS1.

The server acts as both a Web Server and a Name Server, but I wonder if it is necessary to keep the NS1 reference in the hosts file. localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters hostname.domain hostname

My-IP4 ns1.domain ns1
My-IP6 ns1.domain ns1

My-IP4 hostname.domain hostname
My-IP6 hostname.domain hostname
OS type and version Debian 12
Webmin version 2.111
Virtualmin version 7.10.0 Pro
Related packages Hosts file

I’m running name servers and don’t have those options & everything works, as long as your name server can be resolved from the internet I guess there is no need for then entries

is one for IPv4 and one for IPv6 ?

This server is the name server.
Its hostname is used for web and I don’t like that it’s called NS1
On the other hand it is usual to call name servers with NS.

There is an A record with host.domain
There is an NS record with ns1.domain

If this is enough, I remove the NS lines in hosts.

Right! In the various registered domains they point to the name server with IPV4 and there is no NS record with IPV6.
This row should certainly be eliminated in any case.

if you use IPv6, then you need references for IPv4 and IPv6, although you can get away with just IPv4.

Your name server NS is different to your hostname, I would never use ns1 for my hostname it would just comfuse things. NS is just an entry and can point to your servers IP no matter what you call your server.

I agree, that’s why I was wondering if it made sense to have a reference in the hosts file about ns1.
I also don’t like having too many confusing things.

Now in the hosts file I have:

  • commented out the IPV4 row referring to ns1
  • removed IPV6 row referring to ns1
  • left only those with the hostname that correspond to the V4 and V6 IP addresses.

I have:

  • two A and AAAA records that point to these two addresses
  • two NS records (ns1 and ns2) that point to the IPV4 addresses of the two servers

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.