Page 1 of 1

Hostname changes when booting Windows

PostPosted: Mar 30th, '14, 18:41
by Parckwart
On my laptop I dual boot Windows 7 and Mageia 4 using GRUB2. Everytime I boot into Windows the hostname of Mageia changes to localhost.localdomain. That's annoying. How can I make it stop? :)

Re: Hostname changes when booting Windows

PostPosted: Mar 30th, '14, 19:16
by madeye
What does the contents of /etc/hostname show?

Run the following in a terminal and include the result in a message here in the forum.
Code: Select all
cat /etc/hostname

Re: Hostname changes when booting Windows

PostPosted: Mar 30th, '14, 19:24
by Parckwart
That's the file I edit to change the hostname. Currently it's NB3422 which is the hostname I want. But after I once booted Windows, it's localhost.localdomain again.

Re: Hostname changes when booting Windows

PostPosted: Mar 30th, '14, 19:33
by doktor5000
Please show the output of
Code: Select all
cat /etc/hostname
cat /etc/hosts
cat /etc/sysconfig/network
grep -i -e dhcp -e dns /etc/sysconfig/network-scripts/ifcfg-*

Re: Hostname changes when booting Windows

PostPosted: Mar 30th, '14, 19:58
by Parckwart
Code: Select all
[parckwart@localhost ~]$ cat /etc/hostname
NB3422
[parckwart@localhost ~]$ cat /etc/hosts
127.0.0.1               localhost
[parckwart@localhost ~]$ cat /etc/sysconfig/network
HOSTNAME=localhost.localdomain
NETWORKING=yes
CRDA_DOMAIN=US
[parckwart@localhost ~]$ grep -i -e dhcp -e dns /etc/sysconfig/network-scripts/ifcfg-*
/etc/sysconfig/network-scripts/ifcfg-enp0s25:BOOTPROTO=dhcp
/etc/sysconfig/network-scripts/ifcfg-enp0s25:DHCP_CLIENT=dhclient
/etc/sysconfig/network-scripts/ifcfg-enp0s25:PEERDNS=yes
/etc/sysconfig/network-scripts/ifcfg-wlp3s0:BOOTPROTO=dhcp
/etc/sysconfig/network-scripts/ifcfg-wlp3s0:DHCP_CLIENT=dhclient
/etc/sysconfig/network-scripts/ifcfg-wlp3s0:PEERDNS=yes

Interesting. So do I have to change the HOSTNAME in /etc/sysconfig/network?

Re: Hostname changes when booting Windows

PostPosted: Mar 30th, '14, 21:08
by doktor5000
Parckwart wrote:
Code: Select all
[parckwart@localhost ~]$ cat /etc/hosts
127.0.0.1               localhost
[parckwart@localhost ~]$ cat /etc/sysconfig/network
HOSTNAME=localhost.localdomain


Interesting. So do I have to change the HOSTNAME in /etc/sysconfig/network?

Yes, and also for good measure in /etc/hosts (add a new line for 127.0.0.1 with your hostname)
AFAIK /etc/hostname is only used by systemd (hostnamectl)

Re: Hostname changes when booting Windows

PostPosted: Mar 30th, '14, 21:46
by madeye
That's very Interresting. I don't even have HOSTNAME= in /etc/sysconfig/network
Maybe that's why my /etc/hostname is never overwritten.

Re: Hostname changes when booting Windows

PostPosted: Mar 30th, '14, 21:55
by doktor5000
Well, it all depends how you set the hostname initially.