Return all known FQDNs for the system by enumerating all interfaces and
    then trying to reverse resolve them (excluding 'lo' interface).

def fqdns():
    '''
    Return all known FQDNs for the system by enumerating all interfaces and
    then trying to reverse resolve them (excluding 'lo' interface).
    '''
    # Provides:
    # fqdns

    grains = {}
    fqdns = set()

    addresses = salt.utils.network.ip_addrs(include_loopback=False, interface_data=_get_interfaces())
    addresses.extend(salt.utils.network.ip_addrs6(include_loopback=False, interface_data=_get_interfaces()))
    err_message = 'Exception during resolving address: %s'
    for ip in addresses:
        try:
            name, aliaslist, addresslist = socket.gethostbyaddr(ip)
            fqdns.update([socket.getfqdn(name)] + [als for als in aliaslist if salt.utils.network.is_fqdn(als)])
        except socket.herror as err:
            if err.errno == 0:
                # No FQDN for this IP address, so we don't need to know this all the time.
                log.debug("Unable to resolve address %s: %s", ip, err)
            else:
                log.error(err_message, err)
        except (socket.error, socket.gaierror, socket.timeout) as err:
            log.error(err_message, err)

    return {"fqdns": sorted(list(fqdns))}