I have a strange problem with ma Raspberry Pi, and I'd like to fix it, but I have no idea how.
Normally when running, it will advertise its configured hostname to my router, so that I can access it with that hostname. But sometimes, it will advertise its hostname as $_HOSTNAME
instead. The strange thing is that it doesn't just decide on boot, but when it is just sitting there, suddenly it changes the hostname. I know that it must be the Pi, as it happened with different home routers (Fritzbox and Speedport), and no matter how it is connected (on the Fritzbox it was connected on WiFi only, now it has both WiFi and Ethernet connection, though the WiFi apparently shut down automatically, and it is listed as $_HOSTNAME
on its ethernet connection by the router).
In case it matters: It's a Raspberry Pi 2B running Raspbian. I don't remember the OS version (or how to figure it out), but uname -rv
gives 4.19.66+ #1253 Thu Aug 15 11:37:30 BST 2019
. OTOH, the problem occurred both before and after an OS upgrade, so the version probably doesn't matter too much anyway.
I've grepped for $_HOSTNAME
in /etc, and found this in /etc/wicd/dhclient.conf.template:
# wicd will replace $_HOSTNAME in the following line with
# the appropriate hostname for this system
send host-name "$_HOSTNAME";
So I guess the problem is with wicd not properly doing this replacement sometimes. But I have no idea why (and more importantly, how to fix it).
Edit: Contents of /etc/os-release:
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
UPDATE with info from comments:
Actually the original version came on a SD-card I bought together with the Pi itself (it was some system where you could choose between OSs, but I don't remember the details because it's quite a long time since). Since then I've moved it to a bigger SD card, and at some time did a version upgrade through apt-get by changing repositories, following a guideline found on the internet. Thinking about it, I can't really exclude that the initial install system installed a non-standard configuration of Raspbian. Anyway, I never touched the networking stack myself.
What about earlier versions? Since I at one point upgraded through apt-get, it might still use whatever was used by the previous version (which was quite old, definitely 2016 at latest, as it was unused since then until I reactivated it last year).
wicd
, or just have it installed?dhclient.conf.template
... unlikely a file called*.template
is going to actually have any impact on anything[^A-Z]_HOSTNAME
so I guessed that this might be relevant.cat /etc/os-release
. Edit your question to add the results.