[20160510]ssh埠隧道與轉發.txt

lfree發表於2016-05-10

[20160510]ssh埠隧道與轉發.txt

--生產環境要實現一種特殊需求,B能連通A,C不能連通A,但是C可以連通B,要求實現C透過B來訪問A.
--想到了SSH隧道或者埠轉發,自己做一個測試:

1.環境:

A: 192.168.100.78  linux
B: 192.168.101.115 linux
C: 192.168.101.6   windows

2.測試:
--在A機器(192.168.100.78)上建立表TX,方便測試:

create table tx ( cr_date date);
insert  into tx values (sysdate);
commit;

SCOTT@book> select * from tx;
CR_DATE
-------------------
2016-05-09 16:08:09

-- 在C機器上的putty上配置機器B(192.168.101.116)的連線,在
-- connection=>ssh=>tunnels=>加入如下:

L1521 192.168.100.78:1521
R1529 192.168.100.78:1521

--連上B機器(192.168.101.115)後,注意不要退出.

--在c機器(192.168.101.6)上執行:
d:\tools\rlwrap>sqlplus scott/book@127.0.0.1:1521/book
sqlplus scott/book@127.0.0.1:1521/book
SQL*Plus: Release 12.1.0.1.0 Production on Tue May 10 08:02:25 2016
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SCOTT@127.0.0.1:1521/book> select * from tx;
CR_DATE
-------------------
2016-05-09 16:08:09

--測試透過C建立到A.

--另外我也啟動遠端埠1529,這樣我可以在B機器(192.168.101.115)上執行:
$ rlsql scott/book@127.0.0.1:1529/book
SQL*Plus: Release 11.2.0.3.0 Production on Tue May 10 08:06:27 2016
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SCOTT@127.0.0.1:1529/book> select * from tx ;

CR_DATE
-------------------
2016-05-09 16:08:09


-- 這樣雖然能實現連線,但是存在許多問題,首先c機器僅僅1臺,其他機器無法連線,而且要先使用putty配置在連線192.168.101.115,在這
-- 個過程中不能斷開. 總之問題多多,不是很實用.適合開發內部使用.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2096814/,如需轉載,請註明出處,否則將追究法律責任。

相關文章