Reputation: 552
I wrote a small script to get the ip address for a list of hostnames. However when I try to ping the ip address I get request time outs. Why can this happen?
import csv
import socket
path = 'Clients.csv'
with open(path) as fopen:
rows = csv.reader(fopen)
for row in rows:
try:
resp = socket.gethostbyname(row[0])
print(row[0], resp)
except:
continue
Upvotes: 1
Views: 591
Reputation: 1642
The answer is in the question: the DNS server you are requesting knows about the name, so it gives you the matching IP.
It does not mean that the machine that does the ping can actually find a network path to ping the destination. For example, there could be a firewall between the originated server and the pinged server, networks between source and destination are not necessarily routed together, etc.
Timeouts are probably the sign of a blocking firewall.
Upvotes: 4