[SOLVED] I'm getting "Unknown host name" when i try to ping <hostname>
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
>ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=0 ttl=128 time=40.6 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=36.9 ms
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
You need to put two DNS server addresses in /etc/resolv.conf. I looks like you're using Google's freely available DNS servers, so, open a terminal, and to this:
Code:
su - <or sudo>
cat > /etc/resolv.conf
search com
nameserver 8.8.8.8
nameserver 8.8.4.4
^D
^D means Ctrl-D
You could also use a text editor; e.g., vi, vim.
Hope this helps some.
[edit]
Forgot to mention: read the manual page for resolv.conf for a complete explanation
Please don't try to ping any external domain like google.com. As far as I know it's illegel & not allowed and it's against IT ethics. For illustration purpose you could have changed original names with some dummy ones.
Anyway, here in your case, your system isn't able to resolve hostnames against IP adresses.
Use following commands to check hostnaems, and then make appropriate entries of hostname against IP in /etc/resolv.conf file (as shown in above response).
# nslookup 8.8.8.8
OR,
# dig -x 8.8.8.8
Please don't try to ping any external domain like google.com. As far as I know it's illegel & not allowed and it's against IT ethics. For illustration purpose you could have changed original names with some dummy ones.
I'm pretty sure pinging is fine, as long as it's not a flood ping - though if you said 'nmap' or something like that, then I would agree with you wholeheartedly. If you're pinging google (say) 5 times, that's putting less load on their servers than bringing it up in a browser. That said, I could be utterly wrong
""-c count - Stop after sending count ECHO_REQUEST packets. With deadline option, ping waits for count ECHO_REPLY packets, until the timeout expires.""
-c5 pings = five times. -c10 pings = ten times. You can always control the amount of pings.
You might want to check your nsswitch.conf to see if dns is used for name resolution. If not, this would explain why nslookup is working properly (implements dns itself) and ping is not (uses system name resolution). For more information check
You might want to check your nsswitch.conf to see if dns is used for name resolution. If not, this would explain why nslookup is working properly (implements dns itself) and ping is not (uses system name resolution). For more information check
Code:
man 5 nsswitch.conf
Regards, Heraton
Hi Heraton,
Thanks for your reply.After re-correcting one entity pertaining to the dns lookup in the nsswitch.conf now everything is going good. Thanks for all your replies..
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.