Articles How to enable or disable connection protocols for Firebird on Windows

emailx45

Местный
Регистрация
5 Май 2008
Сообщения
3,571
Реакции
2,439
Credits
574
How to enable or disable connection protocols for Firebird on Windows
[SHOWTOGROUPS=4,20]
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 :)

[/SHOWTOGROUPS]