LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-27-2013, 07:05 AM   #1
plisken
Member
 
Registered: Dec 2001
Location: Scotland
Distribution: Slackware 9.1-15 RH 6.2/7, RHEL 6.5 SuSE 8.2/11.1, Debian 10.5
Posts: 518

Rep: Reputation: 32
does PING resolve only once or each count to same address?


I've tried to find an answer to this and got quite a few different responses or opinions so thought I'd come by here for some more.

My question is simply really, when I ping a domain is the domain resolved and then the IP address pinged the number of times or does the domain name get resolved before each ping?

example: ping somedomain.com -c4
Does this result in somedomain.com getting resolved into an IP address once or four times?

Thanks in advance...
 
Old 09-27-2013, 07:51 AM   #2
anon237
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
I do believe that this will be resolved 4 times.

If you use strace to look at what's going on you'll see this block (shortened for easy reading) 4 times (using www.xs4all.nl)
Code:
stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=65, ...}) = 0
socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.0.100.1")}, 16) = 0
recvfrom(4, "\240P\201\200\0\1\0\1\0\0\0\0\3www\6xs4all\2nl\0\0\1\0\1\300"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.0.100.1")}, [16]) = 47
connect(4, {sa_family=AF_INET, sin_port=htons(1025), sin_addr=inet_addr("194.109.6.92")}, 16) = 0
write(1, "PING www.xs4all.nl (194.109.6.92"..., 56) = 56
Each block references /etc/resolv.conf, a connect to port 53 (typical DNS port) and returns the IP number.
 
Old 09-27-2013, 08:51 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,340

Rep: Reputation: 4177Reputation: 4177Reputation: 4177Reputation: 4177Reputation: 4177Reputation: 4177Reputation: 4177Reputation: 4177Reputation: 4177Reputation: 4177Reputation: 4177
I don't like to argue with druuna, but not on my system.
I started out by thinking - "why the hell would anyone check more than once" - given the latency in DNS updates.

On this Fedora system I see only one check - as I envisioned.

So, as always, "it depends". Check your own system.
 
1 members found this post helpful.
Old 09-27-2013, 09:06 AM   #4
anon237
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by syg00 View Post
I don't like to argue with druuna,
Then don't

Seriously;
Quote:
I started out by thinking - "why the hell would anyone check more than once" - given the latency in DNS updates.
That was my train of thought, but I can come up with at least one situation were resolving for each ping would be a good thing.

Quote:
On this Fedora system I see only one check - as I envisioned.

So, as always, "it depends". Check your own system.
You are right about that, just checked on a RHEL 6 and Slackware 13.37 box and it only solves just once.

Ping -V on
- Debian: ping utility, iputils-sss20100418
- RHEL 6.2: ping utility, iputils-sss20071127
- Slackware 13.37: ping utility, iputils-sss20101006

Sorry I jumped the gun on this one. As correctly stated by syg00: It depends on the ping version.
 
Old 09-27-2013, 09:59 AM   #5
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 665

Rep: Reputation: Disabled
it should with 4 attempts because every time it pings it sends out an icmp request and when the request is going 4 times the reply will come for sure..
 
Old 09-27-2013, 10:01 AM   #6
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Sliping through the legs of the two giants I just drop of "more than one A record for a hostname". So it should resolve more then one time. The rest was already said.
 
Old 09-27-2013, 03:57 PM   #7
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,295

Rep: Reputation: 3673Reputation: 3673Reputation: 3673Reputation: 3673Reputation: 3673Reputation: 3673Reputation: 3673Reputation: 3673Reputation: 3673Reputation: 3673Reputation: 3673
Good discussion, good question.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How I can resolve the error Postfix? warning: hostname does not resolve to address kanzer Linux - Server 1 03-22-2013 09:56 AM
I cannot ping with command 'ping IP' address but can ping with 'ping IP -I eth0' sanketmlad Linux - Networking 2 07-15-2011 06:32 AM
[SOLVED] ping www.google.co.in gives unknown host error ,ping to LAN address works fine aspiring_stellar Linux - Newbie 10 05-24-2011 04:26 PM
ping failures resolve external public dns/ip address dkeller626 Linux - Networking 2 06-29-2006 10:20 PM
windows 98 m/c ping to ip address of red hat server but fails to ping hostname ravilohot Linux - Networking 2 09-07-2004 05:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration