Questions tagged [gethostbyaddr]

A command in a few different langauges (i.e. Python, PHP) to perform a Reverse-DNS lookup

gethostbyaddr is a built in command to the Python programming language. It resides in the socket module. Taking an IP address as an input, it performs a reverse-DNS lookup to retrieve a list of strings. Among the outputs is the host name corresponding to that IP address.

43 questions
19
votes
2 answers

InetAddress.getCanonicalHostName() returns IP instead of Hostname

I looked for how to do IP lookup in Java on Stack Overflow but the answers match what I am already doing and do not resolve my problem. Here is my code: public void printHostname( String ip ) { System.out.println( InetAddresses.forString( ip…
Prim
  • 2,880
  • 2
  • 15
  • 29
14
votes
15 answers

How do I retrieve the visitor's ISP through PHP?

How do I find out the ISP provider of a person viewing a PHP page? Is it possible to use PHP to track or reveal it? If I use something like the following: gethostbyaddr($_SERVER['REMOTE_ADDR']); it returns my IP address, not my host name or ISP.
isp_org
14
votes
1 answer

Difficulty using Python's socket.gethostbyaddr()

I am trying to reverse dns a list of IPs using socket.gethostbyaddr() in python, which returns 'Unknown Host' for some values, but using dig for the same ip returns the Hostname. Also, dig seems to be significantly faster than using python module,…
bilkulbekar
  • 327
  • 2
  • 3
  • 10
3
votes
2 answers

In Python, Getting More Info About An IP Address

I know about gethostbyaddr in Python and that is somewhat useful for me. I would like to get even more info about an ip address like one can find at various websites such as who hosts that ip address, the country of origin, ..., etc. I need to…
demongolem
  • 9,474
  • 36
  • 90
  • 105
3
votes
1 answer

gethostbyname fails with hostname from gethostbyaddr, which succeeded

I have following script: #include #include #include #include #include const char *ip="190.162.1.2"; int main(int argc, const char * argv[]) { in_addr host_addr; hostent *addr=0; …
user704565
3
votes
1 answer

Should gethostbyaddr() work in a NAT environment?

If I ask gethostbyaddr() to look up a NAT-generated IP address, such as 192.168.0.4, should I expect it to work? Background: I'm running tests at home on some control code intended for a networked environment. At times, this code does a…
KeithS
  • 113
  • 1
  • 7
3
votes
1 answer

Will gethostbyname_r leak memory if the pointers in the hostent is not freed?

The prototype of gethostbyname_r is: int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop); To avoid the non-reentrant gethostbyname, I wrote up these stuff: int…
felix021
  • 1,936
  • 3
  • 16
  • 20
3
votes
1 answer

herror deprecated

Answering another question, I stumbled upon the man page of a function called herror. It appears to be very much like perror except it prints errors related to some host lookup problem. The man page states that this function is “obsolete”. A…
MvG
  • 57,380
  • 22
  • 148
  • 276
2
votes
3 answers

How to know domain name from IP address in PHP

As we know about PHP has an inbuilt function to get IP address of a domain name But is there any way to know domain name from Ip address? I have tried using gethostbyaddr but it din't…
sukhjit dhot
  • 353
  • 2
  • 5
  • 18
2
votes
1 answer

Python Sockets: gethostbyaddr : Reverse DNS Lookup Failure

I've been having a problem with getting the host name while using socket.gethostbyaddr(ip_addr) on specific sites. I will not go into detail about which site this is not working for. so getting the host by name works fine for every site I've tried…
Brandon Nadeau
  • 3,568
  • 13
  • 42
  • 65
2
votes
1 answer

Resolving a large amount of IP addresses with PHP

I need to resolve a large amount of IP addresses. I'm using gethostbyaddr() for it. I just recently read about using pcntl_fork() and that if you do fork, you don't have to wait for a timeout. Since gethostbyaddr will take a long time (30 seconds,…
Steve
  • 2,936
  • 5
  • 27
  • 38
2
votes
3 answers

Django get client's domain name/host name

What is the easiest way to obtain the user's host/domain name, if available? Or is there a function to lookup the IP address of the user to see if it is bound to a named address? (i.e. gethostbyaddr() in PHP) HttpRequest.get_host() only returns the…
1
vote
1 answer

python3: socket.gethostbyaddr(): "Unknown host" vs "Host name lookup failure"

I am using socket.gethostbyaddr() in python3 to resolve IP to hostname. I need to distinguish between 3 cases: 1) success (IP resolved to hostname) 2) IP address has no DNS record 3) DNS server is temporarily unavailable I am using simple…
400 the Cat
  • 266
  • 3
  • 23
1
vote
2 answers

Python Socket - getting lan connected server host names

I am trying to get LAN connected server's host names, so I can run query over these servers with hostname: import socket IP_RANGE = 10 hostNamesList = [] socket.setdefaulttimeout(0.1) for i in range(IP_RANGE): try: …
MS.
  • 145
  • 1
  • 10
1
vote
0 answers

Filter by Domain or Word using python

Hello, im searching for some help. I want to filter a print results in python. I use this code: import socket addr_range = "192.168.1.%d" ip_address_up = [] ip_dns = [] s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.settimeout(2.0) for i…
1
2 3