1

I'm trying to make an easy headless install image using this -> https://github.com/nmcclain/raspberian-firstboot

I've included

raspi-config nonint do_hostname myhostname

in the firstboot.sh script.

It does change the hostname on the Pi, but in my router when I look at the client list it still shows up as "raspberrypi", even after I reboot the pi, restart networking, etc. I had this pi previously assigned to a static IP from the router but I've removed the entry and disabled the manual assignment. My router is ASUS RT-AC1200. I'm starting to think the problem is in my router like there's some sort of cache or something that keeps assigning the "old" hostname because:

hostname

returns myhostname

  • In etc/hostname I have "myhostname", nothing else.
  • In etc/hosts I have "127.0.1.1 myhostname" as the last line.
  • I've tried to install Samba as someone suggested that on a StackExchange thread I found. That didn't work.
  • I've also tried to include numerous other commands (that I do not remember anymore), none of them worked. I've also tried another method of executing code on first boot -> https://gitlab.com/JimDanner/pi-boot-script/tree/master, but it caused a kernel panic.

I've been at this for like 6 hours today and a couple yesterday. I would really appreciate some help.

Mohi Rostami
  • 4,434
  • 1
  • 20
  • 39
Joseph
  • 11
  • 2

1 Answers1

2

I assume you are using a dhcp client on the RasPi to get an ip address and configuration from a DHCP server on your network. DHCP clients have options to ask for a hostname on the network connection and depending on its configuration it may differ from the contents of /etc/hostname. It is possible to get a hostname from the DHCP server so you are able to manage hostnames at one place.

If you use default dhcpcd then you should have a look atman dhcpcd and search for keyword hostname. I had a glance at it but don't follow it in detail. You will find many hints what could manipulate the hostname. There are options and there are even hook scripts to manage the hostname.

Ingo
  • 42,961
  • 20
  • 87
  • 207