No route to host

Brian Bruns camber at
Tue Dec 14 21:00:04 EST 1999

On Tue, 14 Dec 1999, Adam Haberlach wrote:

> On Tue, Dec 07, 1999 at 11:37:50AM +0000, Allyn Craig wrote:
> > By the way, as a side issue...
> > 
> > Is there a way to set up FreeTDS so you don't need an interfaces file at 
> > all? It is nice sometimes to be able to specify an IP address/port number 
> > for testing purposes without having to modify interfaces.
> > 
> > Maybe the functionality is already there and I just don't know about it?
> > 
> > Just a thought.
> 	Well, it should be possible to set the CS_HOSTNAME property and have
> freetds honor that, but it doesn't seem to be implemented.
The CS_HOSTNAME refers to the host name of the client, not the server. It
gets stored in master..sysprocesses and shows up in the sp_who.

I just put it in and checked it into CVS anyway.  It was there for dblib,
just had to be added for ctlib.

The current scheme for determining IP and port goes something like this:

1.  If tds_set_port() has been called then we assume the CLI is using a
    method other than the interfaces file to connect. So consider
    tds_login->server_name to be a hostname and tds_login->port to be the
2.  If no server was specified look for the DSQUERY environment variable
    for the server name, otherwise server name is "SYBASE"
3.  If dbsetifile() or the equivalent has been called, look up the entry
4.  Otherwise, look for $HOME/.interfaces and use it.
5.  Otherwise, look for $SYBASE/interfaces and use that.
6.  If no interfaces files exist use the specified server name as the
    hostname.  If DBLIB_PORT environment variable exist use that as the 
    port number, else use the default port 1433 or 4000 for TDS 4.2 and
    5.0 respectively. This should probably be updated for 7.0 as well.

Note: DBLIB_PORT is a misnomer since it also works with ctlib, but that's
because it preceeds a working ctlib :-) 

So, a few of options: A. set the port programatically like:

dbproc = dbopen(login, <hostname>);

Which is kinda ugly using a mixture of tds layer and dblib calls.

Option B, set the DSQUERY/DBLIB_PORT environ vars.

Option C, if you are using MS SQL and it is set on the default port,
simply specify the server name as its hostname.


More information about the FreeTDS mailing list