LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I'm getting "Unknown host name" when i try to ping <hostname> (https://www.linuxquestions.org/questions/linux-newbie-8/im-getting-unknown-host-name-when-i-try-to-ping-hostname-4175434764/)

shany 10-30-2012 10:40 AM

I'm getting "Unknown host name" when i try to ping <hostname>
 
It would be more clear if i put up things through command outputs..

>ping www.google.com
ping: unknown host www.google.com

>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

> nslookup www.google.com
Server: 192.168.232.2
Address: 192.168.232.2#53

Non-authoritative answer:
Name: www.google.com
Address: 173.194.38.147
Name: www.google.com
Address: 173.194.38.148
Name: www.google.com
Address: 173.194.38.144
Name: www.google.com
Address: 173.194.38.145
Name: www.google.com
Address: 173.194.38.146

>host www.google.com
www.google.com has address 173.194.38.147
www.google.com has address 173.194.38.148
www.google.com has address 173.194.38.144
www.google.com has address 173.194.38.145
www.google.com has address 173.194.38.146

Some one please explain me what has to be done to rectify this issue.

tronayne 10-30-2012 10:58 AM

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
Code:

man resolv.conf
[/edit]

shivaa 10-30-2012 01:09 PM

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

Snark1994 10-30-2012 01:26 PM

Quote:

Originally Posted by shivaa (Post 4818355)
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 :D

frankbell 10-30-2012 08:31 PM

I think the idea of isolated pings is getting confused with DDoS. http://staff.washington.edu/dittrich/misc/ddos/

Rodebian 10-30-2012 09:05 PM

ping -c5 google.com or www.google.com

""-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.

Pings are not illegal.

Heraton 10-31-2012 01:49 AM

You should check your nsswitch.conf
 
Hello shany!

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

shany 10-31-2012 09:47 AM

Quote:

Originally Posted by Heraton (Post 4818722)
Hello shany!

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..


All times are GMT -5. The time now is 09:20 PM.