偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

3種方式限制IP訪問(wèn)Oracle數(shù)據(jù)庫(kù)

數(shù)據(jù)庫(kù) Oracle
分享3種限制某個(gè)ip或某個(gè)ip段訪問(wèn)Oracle數(shù)據(jù)庫(kù)的方式,希望對(duì)大家有幫助。

 

 

[[340416]]

 

01概述

本文將給大家介紹如何限制某個(gè)ip或某個(gè)ip段才能訪問(wèn)Oracle數(shù)據(jù)庫(kù)

  1. 通過(guò)sqlnet.ora
  2. 通過(guò)/etc/hosts.deny和/etc/hosts.allow
  3. 通過(guò)iptables

 

02正式實(shí)驗(yàn)

本次實(shí)驗(yàn)環(huán)境是Centos6.10 + Oracle 11.2.0.4單實(shí)例,數(shù)據(jù)庫(kù)服務(wù)器ip地址為192.168.31.71

1. 通過(guò)sqlnet.ora

a. 關(guān)閉數(shù)據(jù)庫(kù)服務(wù)器上的防火墻,修改sqlnet.ora文件該文件放在$ORACLE_HOME/network/admin下,如果沒(méi)有就在該目錄下創(chuàng)建一個(gè)即可添加以下兩行

 

  1. tcp.validnode_checking = yes  
  2. tcp.invited_nodes = (192.168.31.71, 192.168.31.77) 

 

這里需要注意的是必須把本機(jī)ip地址加進(jìn)來(lái)(不能寫成localhost和127.0.0.1),否則監(jiān)聽(tīng)啟動(dòng)會(huì)報(bào)錯(cuò)。

b. 重啟監(jiān)聽(tīng),讓sqlnet.ora的修改生效

 

  1. lsnrctl stop  
  2. lsnrctl start 

 

設(shè)置之后就只有這兩個(gè)ip地址192.168.31.71, 192.168.31.77能訪問(wèn)數(shù)據(jù)庫(kù),其它ip地址訪問(wèn)會(huì)報(bào)ORA-12547: TNS:lost contact錯(cuò)誤

tcp.invited_nodes的意思是開(kāi)通白名單,不在白名單中的一律拒絕訪問(wèn),它也可以寫成(192.168.31.*, 192.168.31.0/24)等方式,表明這個(gè)網(wǎng)段都能訪問(wèn)。

另外還有個(gè)參數(shù)tcp.excluded_nodes,表示黑名單,這里不做介紹,有興趣的可以自己去做做實(shí)驗(yàn)。

2. 通過(guò)/etc/hosts.deny和/etc/hosts.allow

sqlnet.ora屬于數(shù)據(jù)庫(kù)層面的限制,但如果一個(gè)ip能夠使用root或者oracle,ssh到這臺(tái)數(shù)據(jù)庫(kù)服務(wù)器的話,那么它依然能夠訪問(wèn)數(shù)據(jù)庫(kù)。為了避免這種情況,這時(shí)就需要通過(guò)/etc/hosts.allow和/etc/hosts.deny去限制某個(gè)ip或者ip段才能ssh訪問(wèn)數(shù)據(jù)庫(kù)服務(wù)器先刪除前面實(shí)驗(yàn)添加的sqlnet.ora,然后重啟監(jiān)聽(tīng)

 

  1. lsnrctl stop
  2. lsnrctl start 

a. 修改/etc/hosts.deny

在文件尾部添加一行

 

  1. all:all:deny 

第一個(gè)all表示禁掉所有使用tcp_wrappers庫(kù)的服務(wù),舉例來(lái)說(shuō)就是ssh,telnet等服務(wù)。

第二個(gè)all表示所有網(wǎng)段。

b. 修改/etc/hosts.allow

在前面一步中我禁掉所有的網(wǎng)段,所以在這一步中要開(kāi)通指定的網(wǎng)段。

修改/etc/hosts.allow,在文件尾部添加

 

  1. all:192.168.31.71:allow 
  2. all:192.168.31.47:allow 

格式與hosts.deny一樣,第一行表示把本機(jī)放開(kāi),第二行表示給.47開(kāi)通白名單

下面用我另外一臺(tái)機(jī)器(即不在allow中的)ssh或telnet連接71這個(gè)機(jī)器,就會(huì)出現(xiàn)如下報(bào)錯(cuò)

 

  1. [oracle@oracle19c1 ~]$ ssh 192.168.31.71 
  2. ssh_exchange_identification: readConnection reset by peer 
  3.  
  4. [oracle@oracle19c1 ~]$ telnet 192.168.31.71 22 
  5. Trying 192.168.31.71... 
  6. Connected to 192.168.31.71. 
  7. Escape character is '^]'
  8. Connection closed by foreign host. 

連數(shù)據(jù)庫(kù)卻不受影響,因?yàn)閿?shù)據(jù)庫(kù)服務(wù)不歸hosts.deny和hosts.allow管

 

  1. [oracle@oracle19c1 ~]$ sqlplus sys/xxxxx@192.168.31.71:1521/orcltest as sysdba 
  2.  
  3. SQL*Plus: Release 19.0.0.0.0 - Production on Sun Aug 16 23:12:49 2020 
  4. Version 19.3.0.0.0 
  5.  
  6. Copyright (c) 1982, 2019, Oracle.  All rights reserved. 
  7.  
  8. Connected to
  9. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 
  10. With the Partitioning, OLAP, Data Mining and Real Application Testing options 

其中ip地址也可以換成以下的寫法

通配符的形式 192.168.31.*表示192.168.31這個(gè)網(wǎng)段

網(wǎng)段/掩碼 192.168.31.0/255.255.255.0也表示192.168.31這個(gè)網(wǎng)段

3. 通過(guò)iptables

sqlnet.ora能夠限制數(shù)據(jù)庫(kù)的訪問(wèn),/etc/hosts.deny和/etc/hosts.allow能夠限制ssh的訪問(wèn),那有沒(méi)有辦法既能限制數(shù)據(jù)庫(kù)的訪問(wèn),也能限制ssh的訪問(wèn)呢,答案就是linux自帶的防火墻功能了。為了實(shí)驗(yàn),將前面做的修改全部清除。

使用root執(zhí)行以下命令

 

  1. service iptables start  # 打開(kāi)防火墻服務(wù)iptables -I INPUT -s 192.168.31.0/24 -p tcp --dport 1521 -j ACCEPT  # 允許192.168.31網(wǎng)段的ip訪問(wèn)本機(jī)1521端口iptables -I INPUT ! -s 192.168.31.0/24 -p tcp --dport 22 -j DROP  # 拒絕非192.168.31網(wǎng)段的ip訪問(wèn)本機(jī)22端口service iptables save  # 規(guī)則保存到配置文件/etc/sysconfig/iptables中 

這樣就同時(shí)限制了其它ip對(duì)服務(wù)器的ssh和數(shù)據(jù)庫(kù)訪問(wèn)一些擴(kuò)展知識(shí):

  1. iptables -L -n --line-numbers  # 查看當(dāng)前系統(tǒng)中的iptablesiptables -D INPUT 2  # 刪除input鏈中編號(hào)為2的規(guī)則,編號(hào)數(shù)字可以通過(guò)上一個(gè)命令得到 

 

03總結(jié)

  1. 如果只是限制其它ip對(duì)數(shù)據(jù)庫(kù)的訪問(wèn),使用sqlnet.ora
  2. 如果要限制其它ip對(duì)數(shù)據(jù)庫(kù)所在服務(wù)器上的ssh連接,使用/etc/hosts.deny和/etc/hosts.allow
  3. 前面兩個(gè)配合起來(lái),基本上就能保證你的數(shù)據(jù)庫(kù)安全了。但是如果你對(duì)linux的iptables很熟悉,那么直接使用iptables去限制。
  4. 使用/etc/hosts.deny和iptables時(shí)一定要保證自己的操作機(jī)能連到服務(wù)器,不然很容易就把自己鎖死在外面了。 

 

責(zé)任編輯:龐桂玉 來(lái)源: ITPUB
相關(guān)推薦

2010-04-15 15:52:12

Oracle數(shù)據(jù)庫(kù)

2010-04-07 18:26:43

Oracle數(shù)據(jù)庫(kù)

2011-03-14 13:33:32

Oracle數(shù)據(jù)庫(kù)啟動(dòng)

2010-04-06 10:52:06

Oracle數(shù)據(jù)庫(kù)

2010-10-26 14:06:43

oracle連接遠(yuǎn)程數(shù)

2010-04-19 16:08:31

Oracle數(shù)據(jù)庫(kù)

2010-04-28 16:23:18

Oracle數(shù)據(jù)庫(kù)

2010-10-26 13:33:08

Oracle自動(dòng)備份

2011-03-21 12:51:16

Oracle數(shù)據(jù)庫(kù)表連接

2011-04-13 14:07:17

OracleSybase數(shù)據(jù)庫(kù)

2010-04-29 11:53:42

Oracle數(shù)據(jù)庫(kù)

2010-04-14 15:45:49

Oracle 數(shù)據(jù)庫(kù)

2011-08-30 17:48:48

Oracle數(shù)據(jù)庫(kù)日期to_char方式to_date方式

2011-04-13 14:38:17

2010-04-06 11:02:30

Oracle 數(shù)據(jù)庫(kù)

2010-10-26 16:07:45

連接oracle數(shù)據(jù)庫(kù)

2010-11-15 10:30:04

Oracle數(shù)據(jù)庫(kù)啟動(dòng)

2009-08-26 16:56:49

Oracle訪問(wèn)Syb

2010-04-22 17:36:51

Oracle數(shù)據(jù)庫(kù)

2011-03-17 15:16:38

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)