Hello.
Iam not able to use some script which use the command hostname -s.
I have two notebook with 12.3 and I got the same problem
This problem does not appear until 12.3
So I could not finish my install on my server.
And this because I am installing 12.3 on my server that I encountered this problem.
When I tried the command on cli I got this error :
LINUX-TEST-XYZ:~ # hostname --short
hostname: Name or service not known
LINUX-TEST-XYZ:~ # hostname -f
hostname: Name or service not known
LINUX-TEST-XYZ:~ #
Same error before I change host name in yast2 which was linux-kfpw.site
I can reproduce (though currently on an “open” connection in a coffee shop):
laptop:~ # hostname
laptop.knurpht
laptop:~ # hostname -s
hostname: Name or service not known
laptop:~ # hostname --short
hostname: Name or service not known
Could this be related to the “Change hostname through DHCP” setting?
Now these are some wild guesses. It seems that your hostname interpretes the argument quite different from what we expect. Are you executing the correct tool? Check
with
beelden:~ # which hostname
/bin/hostname
beelden:~ #
I do not understand now the consequences, but I started reading more extensive in
man hostname
There it says:
The function gethostname(2) is used to get the hostname. Only when the hostname -s is called will gethostbyname(3) be called. The difference in gethostname(2) and gethostbyname(3) is that gethostbyname(3) is network aware, so it consults /etc/nsswitch.conf and /etc/host.conf to decide whether to read information in /etc/sysconfig/network or /etc/hosts the hostname is also set when the network interface is brought up.
Which means that tinkering with e.g. nsswitch.conf could result in problems. And as nsswitch.conf mentions services (like DNS, NIS) and the error uses that word, that could be the case.
If this does not trigger an Aha from you, you could post the content of /etc/nsswitch.conf /etc/host.conf.
Ah, sorry, didn’t see Knurpht’s post (BTW, what are you doing in a Coffee shop???)
Rereading from the beginning I was wandering why DHCP was in the title of this thread. I saw no connection with the contents of the first post. And then I saw Knurpht’s post.
LINUX-TEST-XYZ:~ # cat /etc/hosts
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server.
# Syntax:
#
# IP-Address Full-Qualified-Hostname Short-Hostname
#
127.0.0.1 localhost
192.168.130.100 LINUX-TEST-XYZ
LINUX-TEST-XYZ:~ #
/etc/host.conf
LINUX-TEST-XYZ:~ # cat /etc/host.conf
#
# /etc/host.conf - resolver configuration file
#
# Please read the manual page host.conf(5) for more information.
#
#
# The following option is only used by binaries linked against
# libc4 or libc5. This line should be in sync with the "hosts"
# option in /etc/nsswitch.conf.
#
order hosts, bind
#
# The following options are used by the resolver library:
#
multi on
LINUX-TEST-XYZ:~ #
/etc/nsswitch.conf
LINUX-TEST-XYZ:~ # cat /etc/nsswitch.conf
#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Legal entries are:
#
# compat Use compatibility setup
# nisplus Use NIS+ (NIS version 3)
# nis Use NIS (NIS version 2), also called YP
# dns Use DNS (Domain Name Service)
# files Use the local files
# [NOTFOUND=return] Stop searching if not found so far
#
# For more information, please read the nsswitch.conf.5 manual page.
#
# passwd: files nis
# shadow: files nis
# group: files nis
passwd: compat
group: compat
hosts: files mdns_minimal [NOTFOUND=return] dns
networks: files dns
services: files
protocols: files
rpc: files
ethers: files
netmasks: files
netgroup: files nis
publickey: files
bootparams: files
automount: files nis
aliases: files
LINUX-TEST-XYZ:~ #
/etc/resolv.conf
LINUX-TEST-XYZ:~ # cat /etc/resolv.conf
### /etc/resolv.conf file autogenerated by netconfig!
#
# Before you change this file manually, consider to define the
# static DNS configuration using the following variables in the
# /etc/sysconfig/network/config file:
# NETCONFIG_DNS_STATIC_SEARCHLIST
# NETCONFIG_DNS_STATIC_SERVERS
# NETCONFIG_DNS_FORWARDER
# or disable DNS configuration updates via netconfig by setting:
# NETCONFIG_DNS_POLICY=''
#
# See also the netconfig(8) manual page and other documentation.
#
# Note: Manual change of this file disables netconfig too, but
# may get lost when this file contains comments or empty lines
# only, the netconfig settings are same with settings in this
# file and in case of a "netconfig update -f" call.
#
### Please remove (at least) this line when you modify the file!
search lan
nameserver 192.168.2.200
LINUX-TEST-XYZ:~ #
Don’t forgot :
1°) This is new for me from 12.3 and because I just reinstall my server with 12.3
2°) I use linux the same way for years. So until I learn something more, I may repeat the same error. I always configure the network device by validating “Change hostname from DHCP” and unvalidating “Assign hostname to loopback IP”
You are correct, I missed that in the long listing and your bold line was not scrolled into visibilaty by me.
In any case, it is logical that it can’t be found through DNS as it is not a correct host-domainname. But I think we have to contemplate what Knurpht found and how it can influence this. Is missing a domain part influentual?
“hostname -s” calls gehostbyname() on result of gethostname() to find FQDN. "Name or service not known" simply means that no name service could provide FQDN, that’s all. It is not an error (and it has absolutely nothing to do with dhcp “error” during startup).
What actual problem are you trying to solve? What does not work except “hostname -s” not returning anything (which is likely the case for most users at home)?
**Sep 18 09:34:23 LINUX-TEST-XYZ dhcpcd[1591]: eth0: Failed to lookup hostname via DNS: Name or service not known**
: I never encountered this problem up to 12.2. So I would like to know why this happens now.
: I have upgrade my server from 12.2 to 12.3.
I use a script which configure nx client and use a lot of hostname command .
Here partial screen output.
+ createNXsession
++ hostname -s
hostname: Name or service not known
+ printf '\033[32;1m - writing nx session file %s.nxs\033[37;0m
'
- writing nx session file .nxs
+ '[' 11945 ']'
+ '' 11945 ']'
+ port=11945
+ port=11945
+ cat
++ hostname -s
hostname: Name or service not known
++ hostname -f
hostname: Name or service not known
++ hostname -f
hostname: Name or service not known
++ hostname -f
hostname: Name or service not known
++ cat /var/lib/nxserver/home/.ssh/client.id_dsa.key
+ NXsessionClientMsg
+ cat
++ hostname -s
hostname: Name or service not known
++ hostname -s
hostname: Name or service not known
A session file for including the client key has been written in
/var/lib/nxserver/home/.nxs. You may copy this file to your client ~/.nx/config
directory and change this session settings in Nomachine client to suit your
needs.
+ '' yes ']'
+ startfreenx
+ '' '' ']'
+ systemd-analyze time
+ '' -f /etc/init.d/freenx-server ']'
linux-1dhl:~ #
There is no output file because hostname -s or hostname -f retrurn nothing.
THis never happens until now.
Why ?
I did an upgrade from 12.2 from 12.3 and indeed something did change in the way the DSN resolving works depending on if you allow or not the changes to resolv.conf.
I see in the log that you get an IP from a DHCP server - who does your DNS-ing? Is it the same server running a DNS service? Which it seems that it does not work currently.
On this site there were no serveur acting as dns server.
It is a local network and dns request are process thru the DSL modem routeur.
The network configuration is the same for years.
The only things that as changed is opensuse version from 12.2 to 12.3
On 2013-09-19 20:06, jcdole wrote:
>
> robin_listas;2585968 Wrote:
>> On 2013-09-18 15:46, jcdole wrote:
>>> Why ?
>>
>> No DNS?
> On this site there were no serveur acting as dns server.
> It is a local network and dns request are process thru the DSL modem
> routeur.
> The network configuration is the same for years.
>
> The only things that as changed is opensuse version from 12.2 to 12.3
Mmm.
I just found out recently that it is terribly easy to setup dnsmasq as
local dns server. Instead of the proper set of domain configuration
files, it simply reads the “/etc/hosts” file (dnsmasq is installed by
default on openSUSE, just not enabled).
The configuration changes are these two:
/etc/resolv.conf: Tell the system to query local DNS server