Articles

How to enable or disable connection protocols for Firebird on Windows

Firebird on Windows has the following switches to explicitly enable connection protocols:

  1. -i enables INET protocol, it is used when the connection string looks like localhost:Disk\Path\database.fdb or server_name:Disk:\Path\database.fdb, for 3.0 also it can be inet://servername:disk:\path\bd.fdb
  2. -x enables XNET protocol. On 2.5 and earlier the connections string is the simple local path Disk:\Path\database.fdb, on 3.0+ it is xnet://Disk:\Path\database.fdb
  3. -w enables WNET (NetBEUI) protocol, for connections strings like \\servername\disk:\path\database.fdb. Don't use such connection strings (it is a subject of another article why it is bad)!
By default, all protocols are enabled.
However, if some switch is explicitly specified, non-specified protocols are disabled!

Let's take a look at the following example

The default behavior - all 3 protocols are enabled:
C:\HQbird\Firebird30>firebird  -a

C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey  localhost:o:\OLTP30.V20190415.FDB
Database: localhost:o:\OLTP30.V20190415.FDB, User: SYSDBA
SQL> exit;

C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey  xnet://o:\OLTP30.V20190415.FDB
Database: xnet://o:\OLTP30.V20190415.FDB, User: SYSDBA
SQL> exit;

C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey  \\Win-0u7pnfkg57p\o:\OLTP30.V20190415.FDB
Database: \\Win-0u7pnfkg57p\o:\OLTP30.V20190415.FDB, User: SYSDBA
SQL>exit;

Only XNET (local connection) is allowed:

C:\HQbird\Firebird30>firebird  -a  -x

C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey  localhost:o:\OLTP30.V20190415.FDB
Statement failed, SQLSTATE = 08006
Unable to complete network request to host "localhost".
-Failed to establish a connection.
Use CONNECT or CREATE DATABASE to specify a database
SQL> exit;

C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey  xnet://o:\OLTP30.V20190415.FDB
Database: xnet://o:\OLTP30.V20190415.FDB, User: SYSDBA
SQL> exit;

C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey  \\Win-0u7pnfkg57p\o:\OLTP30.V20190415.FDB
Statement failed, SQLSTATE = 08006
Unable to complete network request to host ".".
-Failed to establish a connection.
-The system cannot find the file specified.
Use CONNECT or CREATE DATABASE to specify a database
SQL> exit;

Only INET (TCP connection) is allowed:

C:\HQbird\Firebird30>firebird  -a  -i

C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey  localhost:o:\OLTP30.V20190415.FDB
Database: localhost:o:\OLTP30.V20190415.FDB, User: SYSDBA
SQL> exit;

C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey  xnet://o:\OLTP30.V20190415.FDB
Statement failed, SQLSTATE = 08006
Unable to complete network request to host "xnet://Global\FIREBIRDHQBIRD".
Use CONNECT or CREATE DATABASE to specify a database
SQL> exit;

C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey  \\Win-0u7pnfkg57p\o:\OLTP30.V20190415.FDB
Statement failed, SQLSTATE = 08006
Unable to complete network request to host ".".
-Failed to establish a connection.
-The system cannot find the file specified.
Use CONNECT or CREATE DATABASE to specify a database
SQL> exit;

INET and XNET connections, but don't allow WNET:
C:\HQbird\Firebird30>firebird  -a  -i -x

C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey  localhost:o:\OLTP30.V20190415.FDB
Database: localhost:o:\OLTP30.V20190415.FDB, User: SYSDBA
SQL> exit;

C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey  xnet://o:\OLTP30.V20190415.FDB
Database: xnet://o:\OLTP30.V20190415.FDB, User: SYSDBA
SQL> exit;
​
C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey  \\Win-0u7pnfkg57p\o:\OLTP30.V20190415.FDB
Statement failed, SQLSTATE = 08006
Unable to complete network request to host ".".
-Failed to establish a connection.
-The system cannot find the file specified.
Use CONNECT or CREATE DATABASE to specify a database
SQL> exit;

These switches can be used to manage Firebird in the application mode and in the service mode.

For example, if you need to restrict connections to the Firebird server through the network, you can use switch -x.

Another good application of switches: if you see WNET errors in firebird.log, it means that somebody uses WNET connection string. Specify -i -x, and you will easily identify users with WNET connection string by their loud screams :)
 

Did you like it? Want more Firebird tips, tricks, and jokes? Subscribe to FirebirdSQL telegram channel!