0

Strange thing is happening. System hostname get changed evey minute or so in our web server. Here's an output from journalctl --since 09:00 | grep hostname:

May 15 10:45:37 bbbbbb.example.com NetworkManager[711]: <info>  Setting system hostname to 'bbbbbb.example.com' (from address lookup)
May 15 10:45:37 bbbbbb.example.com nm-dispatcher[18819]: Dispatching action 'hostname'
May 15 10:46:22 aaa.example.com NetworkManager[711]: <info>  Setting system hostname to 'aaa.example.com' (from address lookup)
May 15 10:46:22 aaa.example.com nm-dispatcher[18991]: Dispatching action 'hostname'
May 15 10:47:07 bbbbbb.example.com NetworkManager[711]: <info>  Setting system hostname to 'bbbbbb.example.com' (from address lookup)
May 15 10:47:07 bbbbbb.example.com nm-dispatcher[19112]: Dispatching action 'hostname'
May 15 10:47:52 aaa.example.com NetworkManager[711]: <info>  Setting system hostname to 'aaa.example.com' (from address lookup)
May 15 10:47:52 aaa.example.com nm-dispatcher[19362]: Dispatching action 'hostname'
May 15 10:53:37 bbbbbb.example.com NetworkManager[711]: <info>  Setting system hostname to 'bbbbbb.example.com' (from address lookup)
May 15 10:53:37 bbbbbb.example.com nm-dispatcher[20372]: Dispatching action 'hostname'
May 15 10:54:22 aaa.example.com NetworkManager[711]: <info>  Setting system hostname to 'aaa.example.com' (from address lookup)
May 15 10:54:22 aaa.example.com nm-dispatcher[20495]: Dispatching action 'hostname'
May 15 10:55:07 bbbbbb.example.com NetworkManager[711]: <info>  Setting system hostname to 'bbbbbb.example.com' (from address lookup)
May 15 10:55:07 bbbbbb.example.com nm-dispatcher[20596]: Dispatching action 'hostname'
May 15 11:01:37 aaa.example.com NetworkManager[711]: <info>  Setting system hostname to 'aaa.example.com' (from address lookup)
May 15 11:01:37 aaa.example.com nm-dispatcher[21988]: Dispatching action 'hostname'
May 15 11:02:22 bbbbbb.example.com NetworkManager[711]: <info>  Setting system hostname to 'bbbbbb.example.com' (from address lookup)
May 15 11:02:22 bbbbbb.example.com nm-dispatcher[22116]: Dispatching action 'hostname'
May 15 11:03:07 aaa.example.com NetworkManager[711]: <info>  Setting system hostname to 'aaa.example.com' (from address lookup)
May 15 11:03:07 aaa.example.com nm-dispatcher[22248]: Dispatching action 'hostname'
May 15 11:10:22 bbbbbb.example.com NetworkManager[711]: <info>  Setting system hostname to 'bbbbbb.example.com' (from address lookup)
May 15 11:10:22 bbbbbb.example.com nm-dispatcher[23507]: Dispatching action 'hostname'

And this is going on for thelast few weeks at this rate! What should I do?

/etc/hosts was like this:

127.0.0.1   localhost localhost.localdomain
127.0.0.1   www.example.com
127.0.0.1   adm.examplegroup.com

// I removed these 2 lines
127.0.0.1   aaa.example.com 
127.0.0.1   bbbbbb.example.com


127.0.0.1   example.com
0

I believe you fixed the problem by removing those two lines.

They never should have been there in the first place.

In the Windows world this never would have happened, because the kernel fixes the hostname and it does not need to be declared in its hosts file.

But in unix or Linux, the host domain must be declared, and cannot be multiply defined at the same level (i.e., multiple subdomain definitions as you show above). The one at the bottom is proper and does not conflict with the one that includes www.

So what to do next: At the very least the hosts file needs to be protected against unauthorized changes.

Perhaps this was a mistake. Or maybe a test of some kind. But the hosts file is not a place for experimentation, especially in a production server.

I am assuming you already have the proper domain set in /etc/hostname

Glad you found the problem.

| improve this answer | |
  • Removing those 2 lines didn't work. But hostnamectl set-hostname www.example.com worked. I wonder why. – Zolbayar May 15 '17 at 7:21
  • I had assumed you already did that. That is usually done at installation time. What did that do to the hosts file? I know it put it into /etc/hostname. – SDsolar May 15 '17 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.