SSH port forwarding to achieve socket5 proxy Internet access

background

Recently, the company's network is unstable, and the environment for local computers to access the company's intranet is always overtime. I consulted the seniors in the next group and learned that it can be passed through the tunnel by using the socket5 proxy of ssh.

As shown in the figure, the delay of my local machine to ServerA is low, but the delay of direct access to ServerB is high (the network structure relationship between A and B is unknown), so that socket5 proxy can be realized between A and B through ssh to realize tunnel forwarding Features. As long as I install the Socket5 proxy provided by A in my browser, I can easily access B.

Operation process

help

Command parameters related to ssh tunnel:

-f: Enter the background mode after entering the password

-N: Do not execute any commands, used for port forwarding

-D: Use socket5 proxy

-L: Forward TCP protocol data, you need to specify host and port

-C: Use data compression to increase the Internet speed when the network is slow; it will affect the Internet speed when the network is fast

Establish ssh tunnel

Establish SSH mutual trust between A and B (relatively simple, omitted here)

We execute on machine A:


#Execute this command ssh -f -N -D bindaddress:bindport username@address 
#bindaddress: refers to the open and accessible ip of serverA, for example, the ip of serverA is 192.168.20.22 (the local computer can ping this ip) 
# bindport: refers to the ip that serverA is open to the outside world, just fill in one at will (such as 7070) 
#username@address: the username and address of serverA, write [email protected] here (ServerA needs to establish mutual trust with itself)

So the execution command is: ssh -f -N -D 192.168.20.22:7070 [email protected]

In this way, a SOCKS5 proxy is established.

Browser configuration SOCKS5 proxy

Open the firefox setting interface and set the following:

Configuring the socket5 connection of machine A is equivalent to machine A acting as a proxy to access machine B.

 In this way, the speed of reopening the website address on the B server is significantly improved.


Blogger: Test to make money

Motto: Focus on testing and automation, and strive to improve R&D efficiency; through testing and diligence to complete the original accumulation, through reading and financial management to financial freedom.

csdn:https://blog.csdn.net/ccgshigao

Blog Park: https://www.cnblogs.com/qa-freeroad/

51cto :https://blog.51cto.com/14900374




Guess you like

Origin blog.51cto.com/14900374/2554274