/etc/hosts problem when choosing other hostname then osmc

During regular installation of osmc version feb 2016. the /etc/hosts/ file does not get updated if you choose another hostname then osmc.

This causes problems with samba and ssh connections to other osmc devices in the network.
Please fix :smiley:

PRETTY_NAME=“Open Source Media Center”
NAME=“OSMC”
VERSION=“February 2016”
VERSION_ID=“2016.02-4”

/etc/hosts does not need to be updated. We use nss-myhostname

Have you tried rebooting before reporting problems ? What “problems” do you see exactly, if you still see any after a reboot ?

Ive reinstalled osmc and rebooted about 60 times this week, as I have extensivly tested
stuff ive been doing on osmc :smiley:

The problems I am experiencing are that since the last updates the my other OSMC boxes do not connect to my original one (called) osmc via ssh.

When I connected from my server called naspberry (osmc feb 2016) I got resolved to localhost by /etc/hosts/ so that.

But Ill test it 20 more times and then get back to you about it…
Maybe I am missing something …

Have I tried rebooting before reporting… have you checked your own /etc/hosts/ ?

Thanks! :smiley:

Tried it again … on a virgin install:

If I want to connect on the command line from an osmc-box renamed to naspberry during installation, to an osmcbox called osmc. The naspberry box will standard only resolve to it self.
because this is in the /etc/hosts file:

::1 osmc localhost6.localdomain6 localhost6
127.0.1.1 osmc

127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

So unless you change the /etc/hosts/ to this

::1 naspberry localhost6.localdomain6 localhost6
127.0.1.1 naspberry

127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

During installation when the installer is asking you, if you want to change the hostname.
the hostname only is changed in /etc/hostname. and not in /etc/hosts
So if you want to: ping, ssh, nfs, from the command line of the naspberry box to a box called osmc it does not work it loops back to 127.0.1.1 (ipv4) or ::1 (ipv6)

Also not after a reboot,

Or am I missing something?

Did you read the nss-myhostname page I linked to, to see how it works ?

It automatically resolves the hostname set in /etc/hostname. For example if I change my hostname to ‘vero’ then from the same machine ping vero it will resolve to 127.0.0.1 automatically - no changes to /etc/hosts needed.

Yes, that is because there is still a default entry for ‘osmc’ in /etc/hosts, so ‘osmc’ will still resolve to the localhost as well. I would recommend that if you have multiple devices you don’t call any of them ‘osmc’ to avoid this.

The whole reason for using nss-myhostname is so that we don’t have to programatically go parsing and modifying the users /etc/hosts file, as doing a truly robust parser that will seek out and change only the correct hostname entries is non-trivial. Unfortunately a side effect is that the original redundant osmc entry remains.

It may be possible for us to completely leave out the osmc /etc/hosts entry now that we use nss-myhostname to avoid this problem in future.

cc @sam_nazarko

Do not get me wrong … So you clearly do not intend it to be a multi user system.
And only want it to be what you’ve created a jukebox…

It is not a problem for me that the installer does not do it. I can do it myself.

It just brings expectations the moment the installer suggests that one can change the hostname, one would think that it would also resolve correctly from the command line one would even expect that the installer will change the nsswitch.conf. in which you refer to

hosts: files myhostname mdns4_minimal [NOTFOUND=return] dns mdns4 …

Does the average user even care that you use nss-myhostname?
They would probably not even care about this issue either.

For some what ever reason I have not seen it work yet … What kind of a nameserver are you running on your network? Probably one that is setup perfectly …

I am looking at this from a user friendly non-bug point of view , how hard is it to append adding the new host name to the /etc/hosts/ properly from the installer? probably less work then not including it all together…

:smiley:

As someone who has just been reading this thread in passing, I’m slightly confused …

Just change the hostname from osmc to something else and it will all work, E.g.:

The problem you are having is because the current installation leaves behind a single “/etc/hosts” file entry called “osmc”. I’m sure, if it’s considered a problem, that will be fixed, but as @DBMandrake also pointed out:

And he’s right - it is; your question:

Shows that you don’t realise what’s actually involved in doing that correctly (you can’t just append like that …).

So what is the problem with just not calling your osmc box “osmc”? You’ve changed the name of one, just change the name of the other as well and it will all work correctly.

Why is that an issue?

Then why suggest the name OSMC during installation all together …

From a user friendly point of view , Its should say Pick any name but not OSMC ,

Read back this entire thread … I am not attacking you … From the get go I was basically told to stfu

"Have you tried rebooting before reporting problems ? What “problems” do you see exactly, if you still see any after a reboot ? " as if the issue does not ecxist.

As if my suggestion did not matter and how dare I even write it up …

So what would you suggest it pick?

OSMC is a perfectly sensible default name.
If you’ve only got one OSMC system, it’s a perfectly good name.
If you want to have more than one OSMC system, you’d change the name anyway - you can’t have “osmc” and “osmc” and expect anything to be able to differentiate between them.

So for the one specific case where you want more than one machine, still insist on calling one “osmc”, and want to be able to resolve that name from the command line, you might want to make one simple edit to one text file.
Since that’s the only circumstances under which this would be any sort of issue, probably not worth changing installation messages, is it …

OSMC is a super name and I think you guys do great work!! I want to be able to use the name osmc…
But its you that suggested I can not or one could not … Please read back

If someone decides to use another hostname … next to this default “osmc” hostname… on his network.

You suggest this name by default so its safe to say that atleast the first box in a network of multiple is called OSMCin 80% of cases.

But say then if you call another box “something-else” … Reboot …

And then…
want to get some stuff from host “osmc” you can not because on the commandline of
host “something-else” you get resolved to localhost.(instead of “something-else”).
and there is no nsswitch.conf. which is going to stop it from doing so …

So please say you understand now … I want to use OSMC as a host name

Then how can you stand by this answer:

Yes, that is because there is still a default entry for ‘osmc’ in
/etc/hosts, so ‘osmc’ will still resolve to the localhost as well. I
would recommend that if you have multiple devices you don’t call any of
them ‘osmc’ to avoid this.

What on earth does multi-user have to do with the hostname ?

You’re getting a bit muddled up. If you check /etc/nsswitch.conf you’ll see that it already has ‘myhostname’ there. We don’t expect anyone to need to edit that file manually.

The “installer” is actually the walkthrough process, which runs once after installation. One of the things it offers to do is change the hostname. You can change the hostname via Kodi at any time - the normal location of the setting is “Device name” in Settings->Services->General.

Normally this setting only changes Kodi’s idea of the device name, (for Airplay for example) however we have gone out of our way to patch Kodi so that changing the name here also changes the system hostname at /etc/hostname for you automatically. So no manual editing of /etc/hostname is required either.

It doesn’t matter what nameserver I’m using - the myhostname entry is the second entry in nsswitch.conf - it is higher priority than everything except /etc/hosts. This is partly done for security reasons.

I’ve explained already what your problem is - the new name that you select will resolve correctly from that device however because there is still a manual entry for ‘osmc’ in /etc/hosts this will prevent any OSMC install from being able to correctly resolve another osmc install that is still called osmc.

To fix this we would need to remove the osmc entry from /etc/hosts completely. Now that we have nss-myhostname (it was only added a couple of months ago) we can probably do this - but we won’t be retroactively editing the users /etc/hosts file (that’s why we added nss-myhostname in the first place) so that change would only be for new installs.

In the meantime my suggestion is if you have multiple installs, don’t name any of them osmc, or edit /etc/hosts yourself.

The main purpose of these hosts entries is that some software that runs on the system needs to be able to resolve its own hostname, regardless of what that might be. (sudo is a good example) that is where nss-myhostname provides a nice clean, automated solution.

1 Like

OSMC is a super name and I think you guys do great work!! I want to be able to use the name osmc…
But its you that suggested I can not or one could not … Please read back

If someone decides to use another hostname … next to this default “osmc” hostname… on his network.

You suggest this name by default so its safe to say that atleast the first box in a network of multiple is called OSMCin 80% of cases.

But say then if you call another box “something-else” … Reboot …

And then…
want to get some stuff from host “osmc” you can not because on the commandline of
host “something-else” you get resolved to localhost.(instead of “something-else”).
and there is no nsswitch.conf. which is going to stop it from doing so …

So please say you understand now … I want to use OSMC as a host name

Then how can you stand by this answer:

Yes, that is because there is still a default entry for ‘osmc’ in
/etc/hosts, so ‘osmc’ will still resolve to the localhost as well. I
would recommend that if you have multiple devices you don’t call any of
them ‘osmc’ to avoid this.

Please say you understand my responses.

I’ve explained twice now what is causing your problem, why it is currently the way it is, how you can easily solve your problem (by editing one file) and have said twice now that we will look into changing the /etc/hosts file on a fresh install to prevent this happening in the future. This is an issue that we are well aware of but like any bug it has to come somewhere on our priority list…

So I don’t know what more you expect ?

1 Like

I already wrote I can do that myself …

I am sorry I think I missed/ am missing the point here.

Lets maybe trim back the topic a bit then no need to let others suffer …

Thanks

I’ve not seen anybody (you or the OSMC developers - of which I’m not one, BTW, just another user trying to help …) being “attacked”; neither did I read any response as telling you to ST*U.

I think perhaps there might be some misinterpretation of tone due to the language difference - although your English is very good, the “,” quotation marks are usually an indication :slight_smile:

You said you had problems, but didn’t explain what they were.
Now it is clear what the problem is, you’ve been told:

  1. Two work-arounds for the issue (edit 1 line in 1 text file, or don’t call both boxes “osmc”)
  2. That the developers are aware of it and will consider a fix at some point.
  3. Exactly why it is currently being done that way, and how any fix would resolve it.

Your suggestion has been ruled out as impractical (it is considerably more complex than you seem to understand), and unnecessary if the developers fix it as they seem to intend to.

So your issue is understood; you have 2 alternative work-arounds for it; a proper fix will be considered for a future release. Seems you should have everything you could want …?

Fantastic!!

Indeed I think the issue is mostly communication!
Your reply is absolutly fantastic :smile_cat: !!

Thanks!

1 Like

In the past we have recommended that to change the hostname completely, you edit both /etc/hostname and update the loopback references in /etc/hosts as well.

However to greatly simplify the process we set up a callback in Kodi so that changes to the Device Name always update the hostname, and that changes to /etc/hostname also update Kodi’s Device Name. This allows users to change their system hostname without any command line interaction. Additionally, it reduces confusion (some users may have believed in the past that modifying this Kodi setting was changing their hostname) and offers a greater level of persistence (deleting Kodi’s user data will not erase the previously configured device name).

Modifying /etc/hosts when this is done would have been inappropriate, as there are a few issues that can occur. The most obvious challenge is that we need to know the previous hostname. However if a user edits /etc/hostname manually, then we would be unable to assess how /etc/hosts should be structured without knowin the previous hostname, and without knowing whether the previous hostname had also been reflected in /etc/hosts.

Using libnss-myhostname lets us resolve those gethostname() calls which can occur when you edit /etc/hostname, but not /etc/hosts and then run any command with a privileged context (i.e. sudo)

Sam

2 Likes