Three types of xshell tunnel forwarding

There are three types of xshell tunnel forwarding

  • Local (Outgoing)
  • Dynamic(SOCKS4/5)
  • Remote incoming Remote (Incoming)

Application Scenario 1

Use the XShell tunnel to connect to the intranet machine through the springboard machine. The springboard machine can be accessed from the public network or through the local area network, but the internal network node public network or local area network cannot be directly accessed.

In this case, access can be achieved by establishing a tunnel through Local (Outgoing) and Dynamic (SOCKS4/5) methods.

Local (Outgoing)

Select "Tunnel" in "SSH" in "Connection" in "Category" in the properties of the session.

Two commonly used methods Local (Outgoing) and Dynamic (SOCKS4/5)

Take access to the openstack dashboard on the intranet as an example:

(http) Source Host: localhost Listening Port: xx Destination Host: xx.xx.xx.xx Destination Port: 80 (novnc) Source Host: localhost Listening Port: xx Destination Host: xx.xx.xx.xx Destination Port : 6080 There is no need to set up a proxy when the browser accesses, just enter http://localhost:listening port in the address bar

Dynamic(SOCKS4/5)

Listening port: xx

You need to set SOCKS4 or SOCKS5 proxy when accessing the browser, and you need to enter the url address of the intranet in the address bar

Higher versions of IE directly support SOCKS4/5 proxy, Chrome recommends using Chrome's Proxy SwitchyOmega plug-in

The two tunnel forwarding methods have their own characteristics, and the latter is recommended because there are few settings. If you want to access other ports or other nodes, you only need to set up one bastion host. If you use the Local (Outgoing) method, you need to configure a forwarding for each LAN IP and each port number.

Application Scenario 2

一个公司连接到另外一个公司的网络,或者一个地点的笔记本要连接一个封闭网络的电脑(一个城市的办公地点连接另一个城市的封闭的数据中心),可以通过远程传入Remote(Incoming) 的方式建立隧道实现访问。 当然第二种应用场景,往往采用teamviewer软件来实现,用teamviewer有很多弊端,收费软件,费流量,且要100%占用一台电脑的屏幕资源。使用远程传入Remote(Incoming) 的方式建立隧道,免收费,省流量,后台运行,电脑可以用于其他工作,缺点是不如teamviewer那么全面,隧道建立的连接,主要用于ssh用途。

远程传入Remote(Incoming)

‘Local’用于把服务器上的服务映射到本机的某端口上,’Remote’则相反,它将本地的端口映射到服务器的某一端口上,在服务器上访问该端口,实际是访问本机的服务。与此类似的是:防火墙的端口映射模式,与之不同的是:前者是在公司防火墙上开了一个洞,是合法的操作;后者是凿了一个洞,是非法操作,无须经过网管人员。后者可能为公司企业带来泄密的风险,尤其是做了到ssh端口映射,就可从外部服务器上就可访问公司整个内部网络!

通过远程传入Remote(Incoming) 的方式建立隧道后,公司A的电脑就可以访问公司B的资源。

具体步骤:

  1. 隧道建立 1)从公司B的电脑,ssh到两公司的办公电脑都可达的云主机或物理机上 2)配置隧道

10.144.85.93是公司B局域网中的某一个节点

  1. 访问过程 1)从公司A的电脑,ssh到两公司的办公电脑都可达的云主机或物理机上 2)登陆成功后,再执行ssh 127.0.0.1 -p 2345,就完成了从公司A电脑登陆公司B局域网的全过程

应用场景三

数据中心。该场景和场景二类似,只是公司B换成了数据中心。 只是可能数据中心的条件不如公司办公环境,网络不可能随便拉。所以这个时候可以借助笔记本(笔记本的角色相当于场景二中的公司B的办公电脑)。利用笔记本的双网卡,无线网卡连手机热点,有线网卡接入数据中心的机房。其他步骤和场景二完全一样。就可以实现在其他地区或其他公司远程连入数据中心的目的。

笔记本双网卡的配置

需要修改windows的路由 route add 10.220.0.0 mask 255.255.0.0 192.168.1.1 -p route delete 0.0.0.0 mask 0.0.0.0 192.168.1.1 以上两条命令是删除经过有线网卡的默认路由,默认路由走无线网卡;访问10.220.*.*(数据中心的服务器的网段)走有限网卡

这样笔记本就可以同时连接互联网和数据中心,但在使用中发现经过有线网卡的默认路由会隔段时间就自动加上,导致不能访问互联网。将下面的内容复制到新创建的文件中,文件名的后缀用bat,然后执行bat文件(用于定期删除有线网卡的默认路由)

@echo off

route delete 10.220.0.0 mask 255.255.0.0 route add 10.220.0.0 mask 255.255.0.0 192.168.1.1 :start route delete 0.0.0.0 mask 0.0.0.0 192.168.1.1 choice /t 5 /d y /n >nul goto start

THE

END

本文分享自微信公

Guess you like

Origin blog.csdn.net/shark1357/article/details/108700856