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
1
vote
0 answers

Memcpy and hostent struct on C

So gethostbyaddr() returns a hostent. struct hostent { char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* host address type */ int h_length; /*…
Loperena
  • 11
  • 1
  • 2
1
vote
1 answer

PHP malformed IP address and host. What is this?

I track downloads from my website by adding a database entry for each download that contains the IP address and host of the downloading person. I use this PHP code to retrieve the IP address isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ?…
A. D.
  • 728
  • 1
  • 9
  • 27
1
vote
0 answers

PHP gethostbyaddr: does not return computer name from the live server?

I want to get the computer name that access a page. So this question has been asked. I tested on my localhast, $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); echo $hostname; I get my computer name, such as, lau-pc But when I run this code on…
Run
  • 54,938
  • 169
  • 450
  • 748
1
vote
2 answers

How to split the return of socket,gethostbyaddr and write to file?

I have a script that reads addresses from a file and looks up its hostname with socket.gethostbyaddr, however the return of this function is messy and doesn't look right. The line where it writes to the destination file…
mchandx
  • 13
  • 1
  • 3
1
vote
1 answer

gethostbyaddr error Unknown host

#include #include #include #include #include int main () { in_addr ip; ip.s_addr = inet_addr("173.194.71.94"); // www.google.fr IP hostent* hostnames = gethostbyaddr(&ip,…
Félix Faisant
  • 191
  • 1
  • 1
  • 11
0
votes
0 answers

Multithreading gethostbyaddr causes wifi to drop

So I'm writing a python script that takes a large amount of IPs in a set (~20k) and the goal is to resolve the hostname of each IP using gethostbyaddr. In an attempt to make the script run as fast as possible I implemented multithreading. Note that…
0
votes
0 answers

How to get hostname from an IPv6 address in Python using socket.gethostbyaddr

I am currently trying to get host information from a user's IP address. I need my program to work with both IPv6 and IPv4. My understanding is that socket.gethostbyaddr(my_ip) should work with both IPv6 and IPv4, but with my code: host_name =…
0
votes
0 answers

How to make a reverse DNS lookup on CloudFlare in PHP?

I have a website, but it is parsed as fake googlebot useragent. I want to filter out fake googlebot by doing reverse DNS lookup. On a regular hosting, I could do this with gethostbyaddr ($ _ SERVER ['REMOTE_ADDR']) and was getting something like…
0
votes
0 answers

Socket.gethostbyaddr() return empty aliaslist in linux but not in windows

Python's socket.gethostbyaddr() return empty aliaslist on linux I've tried with Python2 and Python3 on both Windows and Linux. It works in windows but not on Linux (both Ubuntu and RedHat) using the same IP to resolve of course. I also did a…
0
votes
1 answer

Does gethostbyaddr reveals my server's IP address?

I use CloudFlare, so my server's IP address is hidden, and I want to keep it that way. When I make an HTTP request obviously my IP will be revealed. But does gethostbyaddr reveals my IP address? I want to get the user's IP host, so I do: $hostname =…
HTMHell
  • 5,761
  • 5
  • 37
  • 79
0
votes
3 answers

When would multiple calls to gethostbyname be unsafe?

From gethostbyname(3) - Linux manual The functions gethostbyname() and gethostbyaddr() may return pointers to static data, which may be overwritten by later calls. Copying the struct hostent does not suffice, since it contains pointers; a deep copy…
DeepDeadpool
  • 1,441
  • 12
  • 36
0
votes
2 answers

Why can I run a python server on 127.0.0.2 but not on 127.0.0.1? UnicodeDecodeError

I got a simple example server file from my lecturer. It is working fine for the other students, but when I am trying to run it I get this error: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 2: invalid start byte The error…
user9322425
0
votes
4 answers

Python - How to take input from command line and pipe it into socket.gethostbyaddr("")

I have been scouring the internet looking for the answer to this. Please not my python coding skills are not all that great. I am trying to create a command line script that will take the input from the command line like this: $python GetHostID.py…
betzelel
  • 1
  • 2
0
votes
1 answer

Invalid IP Address with multi-line IP Address

I am stuck with this error while trying to read a file which holds IP addresses separated by a new line. What I want to do, is to read my file that holds bunch of IP's and check does they have proper record. This is my code: $file = "test.sh"; if…
fugitive
  • 357
  • 2
  • 8
  • 26
0
votes
0 answers

Python 2.7 socket.gethostbyaddr timeout before throwing socket.herror

I have the following code sample import socket try: sock=socket sock.setdefaulttimeout(1) for result in sock.gethostbyaddr("165.139.149.169"): if result and "[" not in str(result): print str(result) except…
stumped221
  • 89
  • 4
  • 18