2

I've been doing it for a while and it seems to work ok, but I thought I'd check what good practice is as far as FQDN. Right now my server is setup with (lets pretend) the hostname myhostname and I have a domain registered as myhostname.com and I the domain A records for www and @ pointing to my public IP. My hosts file looks like:

127.0.0.1 localhost localhost.local my.static.ip.ex myhostname.com myhostname

Is it wrong to set your FQDN to a second-level domain name?

mijac
  • 21
  • 1

2 Answers2

2

There's nothing directly wrong with using the parent domain as a hostname, e.g. example & example.com. It's rather a convention to have hostname.example.com, and it's more intuitive when separating different services to different servers, like www.example.com and mail.example.com. Also, it certainly makes things a lot more easy when adding or switching servers later.

However, non of the above are fully qualified domain names (FQDN). An FQDN also contains the top-level domain of the internet, the ., e.g. host.example.com.. (See Hostname article on Wikipedia.)

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129
1

you should do following:

man 5 hosts

EXAMPLE
       127.0.0.1       localhost
       192.168.1.10    foo.mydomain.org       foo
       192.168.1.13    bar.mydomain.org       bar
       146.82.138.7    master.debian.org      master
       209.237.226.90  www.opensource.org

you can use FQDN and/or just domain if you want, but then why? assuming you're already have DNS entry then it's becomes redundant, and in case if something changes in future you'd re point DNS entry to another IP AND you'd need to maintain same record in yet another place /etc/hosts to reflect that change...

alexus
  • 13,112
  • 32
  • 117
  • 174