LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Hostname always back to old one after reboot (https://www.linuxquestions.org/questions/linux-general-1/hostname-always-back-to-old-one-after-reboot-4175523583/)

MisterBark 10-28-2014 10:45 AM

Hostname always back to old one after reboot
 
Hi,

My old hostname was "main".

I changed it:
Code:

hostname audio
I also wrote it:
Code:

echo audio > /etc/hostname
And for my ip addresses:
Code:

# cat /etc/hosts
127.0.0.1                localhost
192.168.10.12                audio.example.org audio
192.168.200.1                audio.example.org audio
 
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.12  netmask 255.255.255.0  broadcast 192.168.10.255
        ether 44:8a:5b:9a:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 186  bytes 17511 (17.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 120  bytes 23567 (23.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 18 

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.200.1  netmask 255.255.255.0  broadcast 192.168.200.255
        ether 68:05:ca:27:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  memory 0xf78c0000-f78e0000 

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 0  (Local Loopback)
        RX packets 4  bytes 344 (344.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 344 (344.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

But after rebooting:
Code:

# hostname
main

# cat /etc/hostname
audio

# cat /etc/hosts
127.0.0.1                localhost
192.168.10.12                audio.example.org audio
192.168.200.1                audio.example.org audio

Slackware64 14.1, but very custom built.

How on earth is it possible???
Where is "main" written? I can't find it anywhere with grep...

THANKS!

littleball 10-28-2014 11:06 AM

Hello.

hostname "named" is equivalent to writing the specified name into /proc/sys/kernel/hostname, which means it will not survive reboot, is only "memory temporal". If you want to make this permanent on Slackware, there is no /etc/hostname file but there is /etc/hosts which you can define the hostname of your server, in my case, I have Slack 14.1 (32 bits but this is irrelevant) and her name is "icinga" this is how my /etc/hosts file looks like:

# For loopbacking.
127.0.0.1 localhost
127.0.0.1 icinga.covenco.cl icinga

And it does survive after reboot :) you can edit this manually or you can do it using Slackware "configuration tools" , run in the command prompt pkgtool -> Setup -> netconfig

And there reconfigure your network and hostname, changes will be saved and keep on each reboot.

Regards.

MisterBark 10-28-2014 11:34 AM

Thank you littleball,

Unfortunately, that does not work.
And I'm not surprised because I connect in ssh and I already defined this for my LAN addresses, so it should not consider the localhost address.

PS: note that hostname is the same on local screen without ssh.

littleball 10-28-2014 12:19 PM

I am not very clever with networking, sorry if I cannot explain too much deep into it. If you edit inside Slackware 14.1 Server /etc/hosts file like this:

# cat /etc/hosts
127.0.0.1 localhost audio
192.168.10.12 audio.example.org audio
192.168.200.1 audio.example.org audio

and reboot networking /etc/rc.d/rc.inet1 restart, logout and login and do "hostname" command, do you keep getting the output of "main"?. Slackware won,t read /etc/hostname this is not an standard hostname path for Slack, (it is for other linux distros), Slack reads from /etc/hosts, you need to add hostname there but on localhost.

littleball 10-28-2014 12:29 PM

Just in case you still want to know the default hostname file path of Slackware, edit /etc/HOSTNAME - yes HOSTNAME using caps -. Using /etc/hosts should be enough, or running netconfig as root and making changes, but if you want to edit /etc/HOSTNAME, you should see "main" word there :) . rc.M boot script reads from that file to set Slackware hostname.

regards.

MisterBark 10-28-2014 12:39 PM

AHHH!!! :)
That's it!

It's uppercase HOSTNAME and not hostname!
SOLVED!


Thank you! :)

littleball 10-28-2014 12:43 PM

You,re welcome MisterBark, glad you solved it :)


All times are GMT -5. The time now is 04:00 PM.