hostname not in /etc/hosts by default

I just installed OpenSUSE Leap 42.1 on a Virtualbox Windows 10 Host to identify an issue that some users have with a software i build.

The default hostname is “linux-4e98”.
By default the hostname are not in /etc/hosts. Only the line “127.0.0.1 localhost”.
So, a “ping $HOSTNAME” fail.

This cause issues with some software, for example Mono (as example: https://bugzilla.xamarin.com/show_bug.cgi?id=42249).

It’s a correct behiavour that hostname MAY not be resolved, or something was wrong, or is a user work update their /etc/hosts ?
Exists a command that i can execute to ‘force’ the OS to update correctly the /etc/hosts ?

Thanks for any feedback.

That’s normal, and normally there should be no need for that.

There is an option in YaST though to automatically write the hostname to /etc/hosts too:
System->Network Settings->Hostname/DNS->Assign hostname to loopback device (or similar).

Just give the box a hostname:


sudo yast lan

#Go under the NIC and assign a name where applicable
#do the same under Hostnames/DNS


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…