Skip to Content.
Sympa Menu

freetds - [freetds] default port discovery using 1434

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: TDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: [freetds] default port discovery using 1434
  • Date: Fri, 12 Dec 2008 21:17:36 -0500

It is technically feasible to discover the default port of a modern
Microsoft SQL Server using port 1434.

The protocol is documented in '[MC-SQLR].pdf', available at
http://download.microsoft.com/download/B/0/B/B0B199DB-41E6-400F-90CD-C350D0C14A53/%5BMC-SQLR%5D.pdf.
Google turns it up with "ssrp protocol site:microsoft.com".

I added a -L option to tsql to print the response to message type
CLNT_UCAST_EX, which is a single byte of value "0x3":

$ src/apps/tsql -H 10.20.30.38 -L -U$U -P$P -p9999
locale is "C"
locale charset is "646"
ServerName HARVEY
InstanceName MSSQLSERVER
IsClustered No
Version 9.00.3042.00
tcp 1433
Msg 20002, Level 9, State -1, Server OpenClient, Line -1
Adaptive Server connection failed
There was a problem connecting to the server

(One doesn't need to log in to acquire the port, but tsql doesn't know
we're not trying to log in.)

To determine the port of the default instance, use CLNT_UCAST_INST with an
instance name of "MSSQLSERVER".

For now, a freetds.conf entry like this will work:

[harvey]
host = harvey.example.com
instance = MSSQLSERVER
tds version = 8.0

In the future, FreeTDS could use this feature to look up the default port.
That means we now know how to connect to most servers with no
freetds.conf:

1. Try protocols in descending order (7.2, 7.1, 7.0, 5.0, 4.2).
2. For 7.0+, query port 1434 for MSSQLSERVER, using 1433 if no response.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page