Oracle控制ip的串連(我們也可以用資料庫觸發器記錄使用者的登入情況,但是不能記錄dba許可權的使用者),單純的設定允許的IP 和 禁止的IP,在oracle9i以前有文檔說增加或修改protocol.ora檔案,在9i及以後版本中真正起作用的是sqlnet.ora檔案,我們修改sqlnet.ora其實是最好最快的方法
sqlnet.ora檔案的功能:
1. Specify the client domain to append to unqualified names
2. Prioritize naming methods
3. Enable logging and tracing features
4. Route connections through specific processes
5. Configure parameters for external naming
6. Configure Oracle Advanced Security
7. Use protocol-specific parameters to restrict access to the database
我在這裡用的就是第7個功能
在sqlnet.ora中增加如下部分
-----------------------------
tcp.validnode_checking=yes
#允許訪問的IP
tcp.invited_nodes=(ip1,ip2……)
#禁止訪問的IP
tcp.excluded_nodes=(ip1,ip2……)
之後重新啟動監聽器即可
eg:
# sqlnet.ora Network Configuration File: E:\oracle\product\10.2.0\db_3\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.
# This file is actually generated by netca. But if customers choose to
# install "Software Only", this file wont exist and without the native
# authentication, they will not be able to connect to the database on NT.
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
#skate modify
tcp.validnode_checking=yes
tcp.invited_nodes=(192.168.0.103)
tcp.excluded_nodes=(192.168.0.10)
需要注意的問題:
1、 需要設定參數為YES,這樣才能啟用。
2、 建議設定允許訪問的IP,因為IP地址有可能被隨意修改,就不能起到自己的目的。
3、 TCP當參數TCP.INVITED_NODES和TCP.EXCLUDED_NODES設定的地址相同的時候將覆蓋TCP.EXCLUDED_NODES設定。
4、 需要重啟監聽器才會生效。
5、 這個方式只是適合TCP協議。
6、 這個配置適用於9i以上版本。在9i之前的版本使用檔案protocol.ora。
7、 在伺服器上直接連接資料庫不受影響。
8、 這種限制方式事通過監聽器來限制的。
9、 這個限制只是針對IP檢測,對於使用者名稱檢測事不支援的。