[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,在这
-- 个过程中不能断开. 总之问题多多,不是很实用.适合开发内部使用.