Identifying a Remote Machine.
Hi all, Try not to laugh too hard here I have several servers, each with hundreds of IPs on them. I am attempting to write a php script that will connect to each ip and identify the 'hostname' as set in rc.conf. I have been looking at icmp, env etc, and can't find a method. I was also loioking at ping, but it does not show the hostname. The only reply I need from the server is the hostname. That will tell ne that the IP is live and what machine its on. Is there any suggestions? -Grant ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Identifying a Remote Machine.
On 1/14/07, Grant Peel [EMAIL PROTECTED] wrote: Hi all, Hello, The only reply I need from the server is the hostname. That will tell ne that the IP is live and what machine its on. Wouldn't a ping be enough if you just need to know whether the machine is on? -Grant -- Pietro Cerutti ICQ: 117293691 PGP: 0x9571F78E - ASCII Ribbon Campaign - against HTML e-mail and proprietary attachments www.asciiribbon.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Identifying a Remote Machine.
ACtually no, Sory if the question was vauge, What I am looking to do is to create a tool that will identify what MACHINE (not domain) an ip is being used on. -Grant - Original Message - From: Pietro Cerutti [EMAIL PROTECTED] To: Grant Peel [EMAIL PROTECTED] Cc: freebsd-questions@freebsd.org Sent: Sunday, January 14, 2007 9:21 AM Subject: Re: Identifying a Remote Machine. On 1/14/07, Grant Peel [EMAIL PROTECTED] wrote: Hi all, Hello, The only reply I need from the server is the hostname. That will tell ne that the IP is live and what machine its on. Wouldn't a ping be enough if you just need to know whether the machine is on? -Grant -- Pietro Cerutti ICQ: 117293691 PGP: 0x9571F78E - ASCII Ribbon Campaign - against HTML e-mail and proprietary attachments www.asciiribbon.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Identifying a Remote Machine.
What is the configuration of your computer and network? Maybe you could try nbtscan, but there is also a lot of things to do with the result of nbtscan. ACtually no, Sory if the question was vauge, What I am looking to do is to create a tool that will identify what MACHINE (not domain) an ip is being used on. -Grant - Original Message - From: Pietro Cerutti [EMAIL PROTECTED] To: Grant Peel [EMAIL PROTECTED] Cc: freebsd-questions@freebsd.org Sent: Sunday, January 14, 2007 9:21 AM Subject: Re: Identifying a Remote Machine. On 1/14/07, Grant Peel [EMAIL PROTECTED] wrote: Hi all, Hello, The only reply I need from the server is the hostname. That will tell ne that the IP is live and what machine its on. Wouldn't a ping be enough if you just need to know whether the machine is on? -Grant -- Pietro Cerutti ICQ: 117293691 PGP: 0x9571F78E - ASCII Ribbon Campaign - against HTML e-mail and proprietary attachments www.asciiribbon.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Identifying a Remote Machine.
On 1/14/07, Grant Peel [EMAIL PROTECTED] wrote: ACtually no, Sory if the question was vauge, What I am looking to do is to create a tool that will identify what MACHINE (not domain) an ip is being used on. Check out this: #include netinet/in.h #include sys/types.h #include sys/socket.h #include limits.h #include stdio.h #include stdlib.h #include strings.h #define MAX_BUFF 128 #define MAX_NAME 128 int main(int argc, char **argv) { char buf[MAX_BUFF], name[MAX_NAME]; intrecv, sock, addrlen; struct sockaddr_in addr, from; if(argc != 3) { fprintf(stderr, usage: %s ip port\n, argv[0]); return(1); } addrlen = sizeof(struct sockaddr); /* get hostname */ bzero(name, MAX_NAME); if(gethostname(name, MAX_NAME) == -1) { perror(gethostname); return(1); } /* create socket */ if((sock = socket(PF_INET, SOCK_DGRAM, 0)) == -1) { perror(socket); return(1); } /* create addres */ bzero(addr, addrlen); addr.sin_family = AF_INET; addr.sin_port= htons((int)strtol(argv[2], (char **)NULL, 10)); if(inet_aton(argv[1], addr.sin_addr) == 0) { perror(inet_aton); return(1); } /* bind */ if(bind(sock, (struct sockaddr *)addr, addrlen) == -1) { perror(bind); return(1); } /* loop infinitely */ for(;;) { /* receive */ if((recv = recvfrom(sock, buf, MAX_BUFF -1, 0, (struct sockaddr *)from, addrlen)) == -1) { perror(recvfrom); continue; } buf[recv] = '\0'; /* send hostname */ if(sendto(sock, name, MAX_NAME, 0, (struct sockaddr *)from, sizeof(struct sockaddr)) == -1) { perror(sendto); continue; } } return(0); } -Grant - Original Message - From: Pietro Cerutti [EMAIL PROTECTED] To: Grant Peel [EMAIL PROTECTED] Cc: freebsd-questions@freebsd.org Sent: Sunday, January 14, 2007 9:21 AM Subject: Re: Identifying a Remote Machine. On 1/14/07, Grant Peel [EMAIL PROTECTED] wrote: Hi all, Hello, The only reply I need from the server is the hostname. That will tell ne that the IP is live and what machine its on. Wouldn't a ping be enough if you just need to know whether the machine is on? -Grant -- Pietro Cerutti ICQ: 117293691 PGP: 0x9571F78E - ASCII Ribbon Campaign - against HTML e-mail and proprietary attachments www.asciiribbon.org -- Pietro Cerutti ICQ: 117293691 PGP: 0x9571F78E - ASCII Ribbon Campaign - against HTML e-mail and proprietary attachments www.asciiribbon.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Identifying a Remote Machine.
In the last episode (Jan 14), Grant Peel said: I have several servers, each with hundreds of IPs on them. I am attempting to write a php script that will connect to each ip and identify the 'hostname' as set in rc.conf. I have been looking at icmp, env etc, and can't find a method. I was also loioking at ping, but it does not show the hostname. The only reply I need from the server is the hostname. That will tell ne that the IP is live and what machine its on. If they're not jailed, just connect to the SMTP port. sendmail's banner has the hostname in it. Another option, if you have a machine on the same subnet as your targets, would be to ping each one, then compare the MAC addresses to determine which ones are on the same host as each other. Or, if you have login access to the servers, just run ifconfig -a to list the IPs. -- Dan Nelson [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Identifying a Remote Machine.
On 14/01/07, Grant Peel [EMAIL PROTECTED] wrote: ACtually no, Sory if the question was vauge, What I am looking to do is to create a tool that will identify what MACHINE (not domain) an ip is being used on. What about connecting to every domainname and quering the hostname? Something like for ip in domainlist do physicalhostname=`ssh $ip hostname` echo $ip $physicalhostname done This should work for a sh compatible shell script. It should be easy to do something similar in php. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]