# hostname incorrect (solved)

## mcnutty

Hi,

I was having problems with my system and booted into a Mint live cd I had lying around. After I got everything sorted out, I'm faced with a new issue. The live cd apparently made some change to my networking config because my hostname is set to 'mint'.

However, both /etc/hosts and /etc/conf.d/hostname show the correct hostname. I've basically done a full grep on my entire system looking for where the word mint even shows up and the only place I can find it is in /var/run/user/1000/KSMserver__0 (where 1000 is presumably my user id). If I edit this file things go back to normal, but it is reset back to mint when I reboot.

Can anyone help me fix this.

ThanksLast edited by mcnutty on Sun Feb 19, 2017 11:55 pm; edited 1 time in total

----------

## fcl

I've run into this once. You probably get Mint hostname from the DHCP server. Check your dhcp program's manual how to send Gentoo's hostname.

----------

## mcnutty

I don't know much about configuring dhcp, but there is a line in my /etc/dhcp/dhclient.conf that as far as I can tell should be sending the correct hostname

```

send host-name "mycorrecthostname"

```

Is there something else I need?

----------

## Fitzcarraldo

mcnutty,

I'm using dhclient as well, and I have the following in /etc/dhcp/dhclient.conf, and that works:

```
send host-name "myhostname";

supersede host-name "myhostname";
```

----------

## mcnutty

I have a long running process going so I can't restart, but I tried adding the supersede line in my dhclient.conf and restarting dhcpcd. Unfortunately I'm still getting the incorrect hostname.

----------

## khayyam

 *mcnutty wrote:*   

> I have a long running process going so I can't restart, but I tried adding the supersede line in my dhclient.conf and restarting dhcpcd. Unfortunately I'm still getting the incorrect hostname.

 

mcnutty ... it's quite possible hostname is bound up with the lease, and so the restart doesn't clear that (because the lease isn't renewed). I'm not sure about dhclient but you might find a lease under /var/lib/dhclient/ and if removed, and dhclient restarted, the lease should be renewed.

Personally I prefer not to send the hostname (at least for wireless networks outside of my control), and so have the following in /etc/conf.d/net

```
dhcp_wlan0="nosendhost"
```

HTH & best ... khay

----------

## Logicien

After you boot into Linux Mint, change the hostname:

```
sudo sysctl -w kernel.hostname=desired-hostname
```

Than start or restart your Dhcp service. You should be able to have the good hostname without playing with the dhcp clients configuration files.

Note that when you modify /etc/dhcp/dhclient.conf, it apply only to dhclient and not to dhcpcd who use /etc/dhcpcd.conf as configuration file. The configuration file to modify depend on which dhcp client the dhcp service and you use.

----------

## Fitzcarraldo

 *mcnutty wrote:*   

> I have a long running process going so I can't restart, but I tried adding the supersede line in my dhclient.conf and restarting dhcpcd. Unfortunately I'm still getting the incorrect hostname.

 

dhcpcd does not use dhclient.conf. In your second post you mentioned dhclient.conf (which is used by dhclient) but in your third post you mentioned dhcpcd. Which DHCP client are you actually using? dhclient or dhcpcd?

----------

## mcnutty

 *Quote:*   

> dhcpcd does not use dhclient.conf. In your second post you mentioned dhclient.conf (which is used by dhclient) but in your third post you mentioned dhcpcd. Which DHCP client are you actually using? dhclient or dhcpcd?

 

Good question. I actually hadn't really thought about it since I installed my machine years ago. It's dhcpcd, but that leaves me a little confused why I'd have a dhclient.conf file at all. It does explain why changing that file didn't do anything  :Smile: 

The lease file appears to be binary, but 'mint' was still visible in the garbled output.

It also appears that the bad hostname got baked into my router. I changed it there, removed the lease file and restarted dhcpcd and the lease file now shows the correct hostname, but the hostname command still shows the bad one.

Edit: Actually that seemed to do it. hostname does output the correct host name now.

Thanks for the help!

----------

