---
title: "Resolving hostnames locally"
url: "https://axoflow.com/docs/axosyslog-core/4.28/chapter-examples/examples-dns/example-local-dns/"
last_modified: "2023-07-02T20:37:04+02:00"
---

> For the complete documentation index, see [llms.txt](https://axoflow.com/docs/axosyslog-core/4.28/llms.txt).

# Resolving hostnames locally

## Purpose:

Resolving hostnames locally enables you to display hostnames in the log files for frequently used hosts, without having to rely on a DNS server. The known IP address - hostname pairs are stored locally in a file. In the log messages, AxoSyslog will replace the IP addresses of known hosts with their hostnames. To configure local name resolution, complete the following steps:

## Steps:

1. Add the hostnames and the respective IP addresses to the file used for local name resolution. On Linux and UNIX systems, this is the `/etc/hosts` file. Consult the documentation of your operating system for details.
2. Instruct AxoSyslog to resolve hostnames locally. Set the `use-dns()` option to `persist_only`.
3. Set the `dns-cache-hosts()` option to point to the file storing the hostnames.

   ```shell
       options {
           use-dns(persist_only);
           dns-cache-hosts(/etc/hosts);
       };
   ```

Last modified July 2, 2023: [Change highlight mode of code examples (2f8a9593)](https://github.com/axoflow/axosyslog-core-docs/commit/2f8a95937c6498193e7168ce8b0dc831e9f0f8ad)
