Prevent hostname from changing after VPS restart

Every time I reboot the vps,  it comes as hostname “defaulthostname”.  How to prevent this?

 

1. You can change its hostname with the command ‘hostname

# hostname

without parameter it will output the current hostname.

# hostname your-hostname

will set the hostname of the system to your-hostname

2. Login to SSH as root and navigate to etc/sysconfig then type: chattr +i network.

cd ..
cd etc/sysconfig
chattr +i network