Register hostname with dhcp

Hello all, Sam,

I am looking for the option to configure osmc to send its hostname to the DNS server by dhcp.
I know this was possible in XBMC. But maybe the option hasn’t made it in osmc settings.
Or am I overlooking something. I also searched for the old nm_util.py script. But wasn’t able to find it anymore.
Related, It would be great if I could set the hostname from a gui, or it it linked to the system name in kodi.

Is there still a way to configure this?

Kind regards,

Bert Haverkamp

P.S. Sam, I was finally able to subscribe to this forum. Turned out to be an issue of not having SPF on my email domain… grr

Not sure what you mean there, XBMC is a mediacenter application, not a DHCP client.

If by XBMC you really mean the operating system Raspbmc, then Raspbmc and OSMC use very different DHCP clients - Raspbmc used dhclient (with network manager as the network manager) while OSMC uses connman both as the network manager and DHCP client.

I’m not actually sure whether connman sends a hostname with it’s DHCP requests - it’s quite possible that it doesn’t but I have not seen a configuration option to enable or disable this.

As for changing hostname via the GUI that is something that we are working on adding, probably in the next month or two but currently the option isn’t there.

At the moment you would want to edit both /etc/hostname and /etc/hosts and replace occurances of osmc with your new hostname then reboot.

My bad, brainfog I guess:-) . Indeed, I meant raspbmc, the predecessor of osmc.

Thanks for your reply.
On the hostname, I would be fine if it takes the system name of kodi and just mirrors that.

On the dhcp, I will dig into connman to see if there is some config for that.

Regards,

Bert

To add here, I checked on the connman forum and they confirmed that connman does send the hostname in a dhcp request. So I have no idea why it doesn’t work for me.

can someone confirm/deny if it works on their side? i.e. is this a problem for my specific setup, or is it an OSMC related problem.

Hello DBMandrake, all,

A repeated request: Does anyone have the dns-registration of the hostname via dhcp working?
I got a confirmation from the connman mailinglist that it is included. But somehow it doesn’t work for me in OSMC. I’m stil unsure if this is a local issue for me or a general issue for OSMC.
Can anyone confirm/deny if this is working at his/her install?

Much appreciated,

Bert

Hello all,

I found my error. I boot from nfs root, in order to be safe from SD card mishaps.
But in that case the dhcp is done at kernel boot level as specified in cmdline.txt.
Fortunately the boot level dhcp also allows to send the hostname.
After some trial and error I found that ip=::::hostname::dhcp does the trick. Mind the number of colons.
they are needed to signify the empty options.

But this is a corner case for setting the hostname with the gui. It would be great if the nfs-root case and above option format was taken into account!

Problem solved, case closed:-)

Regards,

Bert

Thanks for this. It’s on my todo list.

Sam

I may have cheered to early. It works, but only for 12 hours… which is about the lease time for the dhcp lease
Seems that that at a lease refresh the hostname is lost again.
I’m not sure where to look now. Does anyone know how the boot time ip=dhcp works? Is there dhcp code internally in the kernel, or is it passed on to something outside the kernel?
I read in main.c that any parameter the kernel doesn’t understand is passed on to init. But not sure which parameters that are.

Regards,

Bert

No initramfs at the moment, so kernel is handling NFS mount and initial IP lease. I do not think that Linux kernel is renewing the lease however…

This is a known bug in OSMC’s implementation of nfsroot. The solution will be to move to initramfs system and use this to perform the filesystem setup. We then use a lightweight DHCP client like udhcpc to handle renewals and pass any interface != eth0 to ConnMan

Sam

Hi Sam,

I expected renewing the lease would be a hard requirement for any dhcp client. Otherwise your IP addres could be leased to some other client, no?
I could try to find out if I roughly knew where to look.

On your other solution, moving to intramfs. Is this a theoretical solution, or are you planning this somewhere in the future? If so, I can temporarily fix my own IP problem for the moment by setting fixed addresses for the OSMC clients in my dhcp server. But it would be nice to have it fixed properly as well.

Regards,

Bert

Yes – but I think kernel is expecting userland to ‘take over’ the device. eth0 is ignored by ConnMan as it will break nfsroot, but perhaps we should run udhcpc. I have a patch if you want to apply it which may help.

diff --git a/package/network-osmc/files/usr/bin/start-network b/package/network-osmc/files/usr/bin/start-network
index 4aa9581..9aa83a7 100755
--- a/files/usr/bin/start-network
+++ b/files/usr/bin/start-network
@@ -28,6 +28,7 @@ then
                        fi
                done
        fi
+        udhcpc -i eth0& # Temporary, and certainly ugly hack.
        exec /usr/sbin/connmand -n -I eth0 --nodnsproxy --noresolvmodify --config=/etc/connman.conf
 else
        if echo "$dnsproxy" | grep -iqw no; then

I want to get the initramfs in for around November as part of OSMC’s November update.

Sam

Hi Sam,

Tried the patch for start-network. But it freezes the Rpi during boot.
I made a picture of the screen, attached (I hope)


I reverted the patch again and it boots as of old.

But on my side I added the IP addresses and hostnames in openWRT on the router, so I have a temporary workaround here till November. So please don’t spend too much time on this one.

Regards,

Bert

This definitely needs fixing.

I wonder if ‘capturing’ the eth0 is breaking the nfsroot (which is why we ignore eth0 with connman)

Sam