# Network manager changes hostname?

## Princess Nell

I'm normally working off a wired ethernet connection. Today, I had occasion to use wireless and noticed some strange things going on. First of all, nearly every command run from the command line (e.g. vi) resulted in

```

_IceTransSocketUNIXConnect: Cannot connect to non-local host foo

_IceTransSocketUNIXConnect: Cannot connect to non-local host foo

```

As root, the equivalent is

```

No protocol specified

No protocol specified

```

Then I found that the hostname was changed from "foo" to "foo-3945" (I have an Intel 3945abg NIC), and this bit added to /etc/hosts:

```

127.0.0.1       foo-3945     localhost.localdomain   localhost

```

Looking at recent emerges, I believe this is networkmanager's doing (networkmanager-0.8.1-r1).

This behaviour is unexpected, and the IceTransSocketUNIXConnect errors quite annoying. Can anyone explain what's going on and how to stop the hostname from changing? The hostname is defined in /etc/conf.d/hostname, period, and no software has any business fiddling with it. Yes, I'm getting different IP addresses via dhcp on eth0 and wlan0, but that's no reason to change the hostname and break a lot of other stuff in the process.

----------

## Dagger

If your DHCP server provides not only IP address but also hostname - NetworkManager will change it accordingly.

If you want, you can try gentoo-specyfic plugin for NM - which will honor all your Gentoo settings.

Bear in mind it's GSoC work-in-progress and there might still be some bugs. It's already part of of NM-0.8.1-r1 shipped by us. Very shortly I'll be pushing updated version (the one which we presented for upstream integration).

To enable it, please change the following:

edit /etc/NetworkManager/nm-system-settings.conf

Add ifnet to plugin list - it should look like:

```
plugins=keyfile,ifnet

```

----------

## Princess Nell

I'll revisit this at a later point. The latest NetworkManager is horribly broken. I set up an x86_64 system on a new partition and found after an update that I would not get any network connections at all. Also found out that Networkmanger (or nm-applet) overwrites /etc/conf.d/net, which is *not* nice. So I went back to my old, 32-bit system and realised it is broken here, too. I removed everything nm and re-emerged 0.7.2, i.e. masking the 0.8.x versions. All back to normal, and luckily I was able to recover my original conf.d/net - it's handy to have a network configuration around that works. Will do the same on the 64-bit system.

I think I had nm unmasked originally because nm-vpnc was masked.

I don't think the dhcp server is involved, the hostname I ended up with was foo-3945 - the dhcp server

doesn't know this laptop has a 3945 nic.

Thanks  :Smile: 

----------

## Princess Nell

I'm wondering if anything else is at play. Now, under networkmanager 0.7.2, the hostname situation is

still broken. In disregard of the /etc/conf.d/hostname setting, after boot my machine ends up with a

hostname of localhost.localdomain. Despite the real hostname being set in /etc/hosts for 127.0.0.1.

Now I've dumped networkmanager completely.

----------

## Princess Nell

I'm a sucker, I just can't let it go ...

Back to networkmanager-0.8. Enabling wireless while leaving the wired interface connected, the hostname remains unchanged. Enabling the wireless NIC with the wired NIC unplugged, the hostname changes to hostname-3945. So far so bad - this is pretty much the same behaviour as https://bugs.gentoo.org/176873, first reported 3 years ago, and supposedly fixed in 0.8. Regression?

Following http://live.gnome.org/NetworkManager/SystemSettings, I can work around it by setting the hostname explicitly in /etc/NetworkManager/nm-system-settings.conf, but that's kinda ugly. And I haven't tested whether it works across a reboot, i.e. wireless NIC enabled and wired NIC unplugged.

----------

## axisofadvance

My apologies if I'm committing a faux-pas by exhuming this thread, but I'm experiencing an (almost) identical issue.

I'm not running NetworkManager per se, but in a 2-day-old switch from wired to wireless networking, I did recently go through the motions of configuring the wpa_supplicant and dhcpcd. 

I started experiencing the issue noted by OP in the first post, namely while in KDE, every time I start vi and exit it, I see this on the command line:

```
_IceTransSocketUNIXConnect:Cannot connect to non-local host <myhostname>

_IceTransSocketUNIXConnect:Cannot connect to non-local host <myhostname>

No protocol specified

No protocol specified

No protocol specified
```

I think the issue is somewhere with dhcpcd, and specifically revolves around a conflict in hostname assignment/management, however I'm not really sure how to go about resolving this. How can I ensure that it or another network manager isn't creating conflicts with what's in say /etc/hosts and what should be present at boot time? Should I be adding wpa_supplicant as a boot runlevel service (i.e. ensuring it's present in /etc/init.d)?

Any pointers are greatly appreciated. 

Thank you!

----------

## mirekm

You can try to create a file:

/etc/dhcp/dhclient.conf

with following contents:

```

send host-name = "yourHostName";

```

This should help.

----------

