On 9 Jun 2017, at 19:05, Brian Kantor
<Brian(a)UCSD.Edu> wrote:
I don't really know how the portal gets its IP addresses from the
gateway dynamic hostname. Perhaps Chris could enlighten us.
Once an hour a script is run by crontab, it gets a list of all the gateway entries that
have the ‘hostname’ field populated from the database.
The script then does a ‘gethostbyname’ call to resolve the hostname to an IP address.
If this call fails it does nothing more with this gateway and moves on to the next one.
If it successfully resolves the hostname it does the following regexp check:
/^(0\.|10\.|127\.|169\.254\.|192\.168\.|224\.|255\.255\.255\.255)/
and if a match is found it ignores this gateway and moves onto the next one.
This eliminates any “bad” IP addresses getting into the encap file.
If no match is found it looks up the current IP address for the gateway in the database,
if it’s the same as the resolved hostname it does nothing more and moves onto the next
gateway. If however the two IP's are different it updates the database with the new IP
then increments the encap serial.
There is another script run from crontab every 5 minutes that emails the encap file (to
those that have the “when changed” flag set on the portal) and also updates the FTP encap
file, if the encap serial has changed.
The ‘gethostbyname’ call uses the local resolver on the machine to lookup the IP address,
so this effectively comes from our company recursive nameservers, rather than any public
nameservers.
Hope that helps.
Regards,
Chris