LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   IP address translation? (https://www.linuxquestions.org/questions/linux-software-2/ip-address-translation-21675/)

mikeshn 05-23-2002 09:17 PM

IP address translation?
 
I’m looking for a program or for some command that allow translating the domain name to IP address. For example, I want to enter the www.ars.com === 255.255.255.255(the ip address).

JMC 05-23-2002 10:34 PM

for an easy way to do it then do a

Code:

  whois domainname.whatever
I have a c++ program on my puter somewhere that does what you are asking. I'll see if I can locate it and paste the code here.

JMC 05-23-2002 10:44 PM

/*
** getip.c -- a hostname lookup demo
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

int main(int argc, char *argv[])
{
struct hostent *h; if (argc != 2) { // error check the command line
fprintf(stderr,"usage: getip address\n");
exit(1);
} if ((h=gethostbyname(argv[1])) == NULL) { // get the host info
herror("gethostbyname");
exit(1);
} printf("Host name : %s\n", h->h_name);
printf("IP Address : %s\n", inet_ntoa(*((struct in_addr *)h->h_addr)));

return 0;
}


I didnt write the code. I got it from a tutorial site about network programming. Beej's site or something like that.

sewer_monkey 05-24-2002 12:41 PM

host 1.2.3.4
host www.example.com

Will do both forward (domain name to IP) and reverse (IP to domain name) lookups.

Noerr 05-25-2002 02:14 AM

Or you can use traceroute www.hostname.com and even get all hops in between with hostnames and ip addresses

mikek147 05-25-2002 05:51 AM

How about using either one of the programs nslookup, host or dig. -mk


All times are GMT -5. The time now is 11:13 PM.