2

I was wondering if I am editing a file such as /etc/hosts or /etc/sysconfig/network should I put a . at the end of the name. such as test.example.com.

Is there a difference? Would anything break either way.

Boop
  • 113
  • 4
PHGamer
  • 430
  • 1
  • 4
  • 7

4 Answers4

6

According to man hosts:

Host names may contain only alphanumeric characters, minus signs ("-"), and periods ("."). They must begin with an alphabetic character and end with an alphanumeric character.

dunxd
  • 9,632
  • 22
  • 81
  • 118
2

Entries in /etc/hosts are never expanded with a domain, it's a simple table lookup, and hence, trailing dots are meaningless and likely to cause issues. Also as mentioned in another answer, the specification for /etc/hosts rules them out (for this reason).

EightBitTony
  • 9,311
  • 1
  • 34
  • 46
2

Trailing dot is not meaningless. If you try to access a host with FQDN(which includes trailing dot), your application will lookup the name from DNS not /etc/hosts if the hostname in /etc/hosts does not have trailing dot.

Minsuk Song
  • 878
  • 5
  • 6
1

I have never seen anyone use a trailing dot there, so you probably shouldn't. Even though nothing might break right now, it's just tempting fate, as something might not expect it.

Teddy
  • 5,204
  • 1
  • 23
  • 27