So this isn’t like a very big problem, but I just noticed when I run the commands
$ hostname -i
hostname: Name or service not known
$ hostname -d
hostname: Name or service not known
I get the error “hostname: Name or service not known”, but when I give just
$ hostname
hostname.domain
I get the get my “hostname.domain”, just wondering whats going on, I recently installed Hamachi VPN (Beta 64-Bit Version 2), but thats working fine and so is services like SSH and so, just these commands give me the not desired error, can anyone tell me whats going on. Oh also couple days back I changed the random hostname that openSuSE gave me upon installation, that went well too, no problem. I’m using openSuSE 12.1 64-Bit, if that’s of help.
$ hostname -iv
gethostname()=`hostname.domain'
Resolving `hostname.domain' ...
hostname: Name or service not known
I see the gethostname function is doing ok…but something wrong with the next step? ie, Resolving… ?
PS: “hostname.domain” is a generic name I’m giving while posting in the forums. My actualy host and domain “openSUSElaptop.site” , but I guess that doesn’t make difference, so incase any one wonders, “openSUSElaptop.site” is what i get in place of “hostname.domain”
I am really not sure to what service hostname refers here (I never used
it with -i). Seems something it expects is not started on your machine?
You have to wait for someone with more insight into that.
If you have the package bind-utils installed you can fake the same
functionality with
dig +short $(hostname)
–
PC: oS 12.2 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.8.4 | GeForce GT 420
ThinkPad E320: oS 12.1 x86_64 | i3@2.30GHz | 8GB | KDE 4.8.5 | HD 3000
eCAFE 800: oS 12.1 i586 | AMD Geode LX 800@500MHz | 512MB | KDE 3.5.10
Well I just want to know the ip address, so I use hostname -i, it been long since I used that command, but since I was trying personal VPNs with Hamachi, I used it only to find that error I was getting, is there any other command that would do the job? “apropos ip” isn’t very helpful, not to mention my awful "grep"ing skills! Just want a command that tells me my ip. I know there are lots of non-terminal ways, but just curious.
Ah yes I hope someone tells me what’s going with that “hostname -i” command though, I’m very sure it was working well before, not sure what happened suddenly.
It appears to be looking up the hostname in “/etc/hosts” (and perhaps also in DNS nameservers, but it won’t find my hostname in the nameservers).
When I manually assigned a hostname via Yast, I checked the box to add a line to “/etc/hosts”. That’s how the “127.0.0.2” entry shows up. The other entry shows up because I edited “/etc/hosts” (as root) and also added that. I use “sendmail” for email, and sendmail complains if it cannot find a fully qualified hostname.
Resolvolving mean to find the IP address whe the hhosname (better the QDN) is known. So it consults /etc/nsswitch.conf and /etc/host.conf to decide whether to read information in /etc/sysconfig/network or /etc/hosts. Is you hotcrrectluy mentioned in /etc/hosts?
The second “addr” is something to do with VPN I guess, but yeah this is not easy to remember, and also you need to be root, oh well this works, you think its good idea to alias this or run the whole thing as some script? And about the “hostname -i” , I also tried it on my other openSuSE on a VM and that gave the same error, I hope nothing of these errors are pointing to my router for a mistake?!
Yes and I do have the “dig” command, but unfortunately
Hmmmm but you know I also tried that as mentioned above on my VM , that I’m running inside Win7, it failed. Oh and I dont have Hamachi/VPN on there. But strange, at least I’m not alone. I’m just concerned because it was something working normally and now it doesn’t. :\
Well thanks first of all of that info and I did check /etc/host file, and I do see there 127.0.0.1, what would in my case be the output for “hostname -i” I guess? So yeah I do see in that file, 127.0.0.1, but you say the command “hostname -i” refers to that? But it still doesnt give me 127.0.0.1
I remember that was the output “hostname -i” gave me long time back, when it used to work.
Am 13.08.2012 21:56, schrieb havock07:
> and also you need to be root
No - never, you run it as a normal user, not as root, if it does not
work as normal user your Linux boxes are heavily screwed up!
So run it again as your normal user.
Forget the dig and hostname in combination with the vpn connection for
the moment, both of them work for me at any time with the exception when
a vpn connection to my company is established (since I cannot influence
how that works and what features it provides I did not investigate further).
If both of them do not work for you even without the vpn connection then
I’ld guess that something in your network setup is not as it should be,
but to find out what or how to diagnose that is beyond me and maybe
worth another thread where you describe your network setup and your
network related settings on your machines.
–
PC: oS 12.2 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.8.4 | GeForce GT 420
ThinkPad E320: oS 12.1 x86_64 | i3@2.30GHz | 8GB | KDE 4.8.5 | HD 3000
eCAFE 800: oS 12.1 i586 | AMD Geode LX 800@500MHz | 512MB | KDE 3.5.10
Am 13.08.2012 22:36, schrieb havock07
> Yes sorry, my mistake, you’re right you need not be root, it works
> fine for normal users! I just got confused because early yesterday I
> tried
That works for a bunch of commands in /sbin and /usr/sbin, as long as
you retrieve only information and do not use them to set something they
will work as normal user, you just have to call them with the absolute
path, /sbin/lspci would be another example.
Some others do not even allow information retrieval when you are not
root like “fdisk -l”.
So it is not completely self evident
–
PC: oS 12.2 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.8.4 | GeForce GT 420
ThinkPad E320: oS 12.1 x86_64 | i3@2.30GHz | 8GB | KDE 4.8.5 | HD 3000
eCAFE 800: oS 12.1 i586 | AMD Geode LX 800@500MHz | 512MB | KDE 3.5.10