December 07, 2012 01:22AM
maybe this one's better:

12/07 06:19[root@proxy2-prod-ue1 ~]# cat gethostbyname.c
#include <stdio.h>
#include <netdb.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>

int main(int argc, char *argv[])
{
if (argc < 2) {
fprintf(stderr, "usage: %s hostname\n", argv[0]);
return 1;
}

// skip 0 because that is the program name
for (int i = 1; i < argc; ++i) {

struct hostent *lh = gethostbyname( argv[i] );

if (lh) {
struct in_addr **addr_list;
addr_list = (struct in_addr **) lh->h_addr_list;

printf("%-14s %s\n",
inet_ntoa( *addr_list[0] ),
lh->h_name
);
}
else {
herror("gethostbyname");
}
}

return 0;
}
12/07 06:20[root@proxy2-prod-ue1 ~]# gcc -std=c99 gethostbyname.c -o gethostbyname.bin
12/07 06:20[root@proxy2-prod-ue1 ~]# ./gethostbyname.bin webapp02c.prod.romeovoid.com
10.51.23.17 webapp02c.prod.romeovoid.com
12/07 06:21[root@proxy2-prod-ue1 ~]# ./gethostbyname.bin webapp06c.prod.romeovoid.com
10.195.76.80 webapp06c.prod.romeovoid.com


our DNS does work..
Subject Author Posted

nginx reload fails with [emerg] host not found in upstream

groknaut December 06, 2012 09:37PM

Re: nginx reload fails with [emerg] host not found in upstream

姚伟斌 December 06, 2012 11:26PM

Re: nginx reload fails with [emerg] host not found in upstream

groknaut December 07, 2012 12:33AM

Re: nginx reload fails with [emerg] host not found in upstream

groknaut December 07, 2012 01:22AM

Re: nginx reload fails with [emerg] host not found in upstream

Ruslan Ermilov December 07, 2012 02:24AM

Re: nginx reload fails with [emerg] host not found in upstream

groknaut December 07, 2012 05:11PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 231
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready