servername Lookup

`servername` Lookup
Prev | Chapter 3. Install FreeTDS | Next

## `servername` Lookup

FreeTDS converts the servername to an IP address by following the steps below, stopping when it succeeds.

Name lookup sequence [6]

1. Find `servername` in `freetds.conf`. If a section with that name exists, use the hostname, port, and TDS version specified therein.

2. Attempt to convert `servername` to an IP address with `inet_addr(3)`.

3. Request name-lookup from the operating system via `gethostbyname(3)` or similar.

If the TDS version and port are not read from `freetds.conf`, they are derived from the compiled-in defaults and overridden by applicable environment variables.

As you can see, if most of your servers use the same TDS version and answer to the default port, then you don't need to list them all in `freetds.conf`. You can simply compile in the right defaults — or set the `TDSPORT` and `TDSVER` environment variables — and rely on DNS for name resolution.

[6] This description applies to `DB-Library` and `CT-Library`. ODBC lookup is different.

Prev | Up | Next
Choosing a TDS protocol version | Home | The `freetds.conf` file