Re: Seeing full FQDN in chronyc output
Rob Janssen <chrony-users-Cohe+2zZ/ftmR6Xm/[email protected]> Wed, 26 Jun 2024 20:47:06 +0200
| Newsgroups | gmane.comp.time.chrony.user |
|---|---|
| Organization | PE1CHL |
| Message-ID | <[email protected]> |
like many programs, chrony just does a reverse-lookup of the IP address, which
results in a FQDN name (only) when a PTR record for the address is available in DNS.
When you want to have that info you can use the chronyc -n sources command, and
then parse the output to extract the IP addresses and do a reverse lookup on them,
and get the result with the length that you want.
I use this script to perform such lookups. I saved it as /usr/local/bin/ip2host and then
you can use: chronyc -n sources | ip2host
Of course it destroys the layout of the output.
Rob
#!/usr/bin/perl -w
my ($ip,$host);
my @fields;
while (<>) {
chomp;
@fields = split /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/, $_;
foreach $ip (@fields) {
if ($ip =~ m!^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$!) {
if (defined $cache{$ip}) {
$host = $cache{$ip};
} else {
$host = (gethostbyaddr(pack('C4',$1,$2,$3,$4),2))[0] || $ip;
$cache{$ip} = $host;
}
if ($ip ne $host) {
$ip = $host.'['.$ip.']';
}
}
}
print @fields,"\n";
}
On 2024-06-26 20:37, Mike Hall wrote:
> Info in the /etc/chrony.conf file has IP addresses for the time servers.
> "chronyc -n sources" seems to be providing the IP addresses only.
>
> Should have mentioned in initial post that this version is the current
> RHEL 8 version. -- version 4.5 (+READLINE +SECHASH +IPV6 +DEBUG)
>
> On Wed, Jun 26, 2024 at 2:33 PM Josef 'Jeff' Sipek <[email protected]> wrote:
>
> On Wed, Jun 26, 2024 at 14:29:07 -0400, Mike Hall wrote:
> ...
> > Are there any other versions of the command that
> > would provide a full FQDN, and preferably all FQDN names.
>
> Does 'chronyc -n sources' do what you want? See the manpage for a full
> description.
>
> Jeff.
>
> --
> To unsubscribe email chrony-users-request-kWFZVVI9zxvPqho9SqqRMmD2FQJk+8+b@public.gmane.org
> with "unsubscribe" in the subject.
> For help email chrony-users-request-kWFZVVI9zxvPqho9SqqRMmD2FQJk+8+b@public.gmane.org
> with "help" in the subject.
> Trouble? Email [email protected]
>
>
>
> --
> Michael "Mike" Hall, Sr.
> Cell: 410-370-5901