EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: gethostbyname and getaddrinfo - multiple DNS entries for a hostname
From: Eric Norum <[email protected]>
To: <[email protected]>
Cc: [email protected]
Date: Sat, 9 Mar 2013 10:04:48 -0800
It sounds like getaddrinfo is a better routine to use.  Will this cause problems for folks on old POSIX platforms?  I suppose that those so affected could use the existing gethostbyname code by copying it from the posix directory to, say, solaris?  
Or should this be a 3.15 change and we'll wave goodbye to those folks?

On Mar 9, 2013, at 2:41 AM, <[email protected]> wrote:

> 
> Hi,
> 
> In the POSIX code in libCom for networking (posix/osdSock.c) there is the use of gethostbyname to map a hostname to IP address. This is what the Asyn function drvAsynIPPort uses to map hostname to IP address (that we use in IOC startup scripts).
> 
> We have a problem at Diamond for a few systems that move around different beamlines. These typically comprise a few ethernet attached devices and an Epics IOC running on Linux. The IP addresses of the device that an IOC can talk to changes depending on which beamline it's running on, but the hostname can stay the same. So in our DNS server we have multiple IPv4 address for a hostname, and we would like to be able to use the hostname in the IOC startup script. 
> 
> The problem is our DNS server can't/doesn't prioritise local subnets, so our hostname to IP address lookup can return any value from the list (and only one value is returned). At least, that's what gethostbyname does in hostToIPAddr in posix/osdSock.c. However, I've found that if I use getaddrinfo instead I always get the correct IP address for the local subnet first (in the list of returned IP address). So getaddrinfo seems to be matching the localhost to the list of possible IP addresses.
> 
> getaddrinfo seems to be the newer POSIX way of doing DNS lookups, and has superseded gethostbyname. From the man page:
> The gethostbyname*() and gethostbyaddr*() functions are obsolete. Applications should use getaddrinfo(3) and getnameinfo(3) instead.
> 
> 
> Has anyone else had this problem with multiple DNS entries? Any one see a problem with changing hostToIPAddr to use getaddrinfo instead of gethostbyname?
> 
> In the meantime we may start doing our own hostname to IP mapping, using getaddrinfo, and only ever pass an IP address into drvAsynIPPort.
> 
> Cheers,
> Matt
> 

-- 
Eric Norum
[email protected]






Replies:
Re: gethostbyname and getaddrinfo - multiple DNS entries for a hostname Michael Davidsaver
Re: gethostbyname and getaddrinfo - multiple DNS entries for a hostname Andrew Johnson
References:
gethostbyname and getaddrinfo - multiple DNS entries for a hostname matthew.pearson

Navigate by Date:
Prev: Area Detector Zenon Szalata
Next: RE: Area Detector Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: gethostbyname and getaddrinfo - multiple DNS entries for a hostname matthew.pearson
Next: Re: gethostbyname and getaddrinfo - multiple DNS entries for a hostname Michael Davidsaver
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·