Control Web Panel

WebPanel => CentOS 7 Problems => Topic started by: crazyeyes19877 on February 23, 2018, 09:28:00 AM

Title: Hostname changes on every reboot
Post by: crazyeyes19877 on February 23, 2018, 09:28:00 AM
Hostname changes on every reboot I want the hostname to be "server1.domain.com" it changes like it should but when I reboot it goes back to "server1" I dont have a clue what to do I type in hostname it responds with "server1" and then hostname -f "server1.domain.com" that does not change even after reboot I am bit new to this... :'(
Title: Re: Hostname changes on every reboot
Post by: Jamshed Datori on February 23, 2018, 09:42:37 AM
Are you using AWS ec2 or Google cloud?
Title: Re: Hostname changes on every reboot
Post by: crazyeyes19877 on February 23, 2018, 09:44:57 AM
I am using a VPS from vpscheap.net
Title: Re: Hostname changes on every reboot
Post by: Jamshed Datori on February 23, 2018, 10:05:51 AM
Kindly change the hostname through Change Hostname option in CWP admin panel.
Title: Re: Hostname changes on every reboot
Post by: crazyeyes19877 on February 23, 2018, 10:07:57 AM
I did but when it reboots or updating it reset back to "server1"
Title: Re: Hostname changes on every reboot
Post by: n8v8r on February 23, 2018, 10:19:19 AM
there are couple of places to specify the hostname. You may run a meta search for that string in question and see where it pops up and adjust accordingly.

Code: [Select]
grep --exclude-dir={boot,dev,media,mnt,proc,run,sys,root} -rnw '/' -e "server1"
Title: Re: Hostname changes on every reboot
Post by: crazyeyes19877 on February 23, 2018, 10:48:42 AM
Million things popped up dont know what to do with it really sorry
Title: Re: Hostname changes on every reboot
Post by: n8v8r on February 23, 2018, 11:07:01 AM
more refined search, yielding less results. it may take a few minutes to complete the searcch

Code: [Select]
grep --exclude-dir={boot,dev,media,mnt,proc,run,sys,root,var,postfix,dovecot,lvm} -rnw '/' -e "server1"
Title: Re: Hostname changes on every reboot
Post by: n8v8r on February 23, 2018, 11:12:09 AM
The most likely places where the hostname is stipulated are

Quote
/etc/hosts
/etc/hostname
Title: Re: Hostname changes on every reboot
Post by: crazyeyes19877 on February 23, 2018, 11:28:12 AM
for some reason now all my pages are "HTTP Test Page" so everything is kinda broken and dont know what to do about it :(
Title: Re: Hostname changes on every reboot
Post by: crazyeyes19877 on February 23, 2018, 11:35:56 AM
Ok I sorted out the http test I accidentally changed the shared IP

But still sorting out host name 
Title: Re: Hostname changes on every reboot
Post by: crazyeyes19877 on February 23, 2018, 12:02:52 PM
/etc/hosts
This does not change until I update the hostname from the web interface
Code: [Select]
127.0.0.1 localhost.localdomain localhost
# Auto-generated hostname. Please do not remove this comment.
123.123.123.123 server1.domain.com  server1
::1 localhost
/etc/hostname
This does change when I update or restart
that is what I change it to
Code: [Select]
server1.domain.comafter reboot
Code: [Select]
server1
Title: Re: Hostname changes on every reboot
Post by: crazyeyes19877 on February 23, 2018, 12:07:55 PM
Just want to add one thing its not the vps settings that is set to "server1.domain.com"
Title: Re: Hostname changes on every reboot
Post by: crazyeyes19877 on February 23, 2018, 12:53:57 PM
I am thinking I am getting confused between fqdn and hostnames but still not sure how to sort it out
Title: Re: Hostname changes on every reboot
Post by: crazyeyes19877 on February 27, 2018, 03:47:16 PM
I did some research on this problem and I have sort it out by locking the hostname file and I just did hosts aswell just incase I think its the hosting provider that did this but here i used this code.

To lock

Code: [Select]
chattr +i /etc/hosts /etc/hostname
To unlock

Code: [Select]
chattr -i /etc/hosts /etc/hostname
If there is a problem with this to cwp please some one let me know thank you
Title: Re: Hostname changes on every reboot
Post by: n8v8r on February 27, 2018, 04:28:48 PM
Good that you figured it out and shared your solution! The hosting provider though should not interfere in such manner after the installation of the server completed...