This paper is participating in theNetwork protocols must be known and must be known”Essay campaign
Introduction to the
Existence is reasonable, SOCKS5 is to solve the problem of SOCKS4 does not support authentication, after all, we pay more and more attention to the security of the network. The Internet without authentication is like living under a camera, with no privacy at all. It’s terrible.
Today I will give you an in-depth explanation of SOCKS5 and its application.
Why use SOCKS
SOCKS is a proxy service protocol. Why should there be a proxy service protocol?
In modern networks, it is often difficult for us to directly access each other’s networks due to network or firewall reasons, so a proxy mechanism is needed to act as a gateway between the local network and the larger network.
A proxy server works by intercepting the connection between sender and receiver. All incoming data enters through one port and is forwarded to the target network through another port.
Of course, traffic forwarding is the most basic function of the proxy server. The proxy server can also hide the IP address of the client or server to ensure network access security. In addition, because the proxy server acts as the proxy of the target server, the proxy server can be used as the cache server of the target server to improve network access efficiency.
In addition, the proxy server can intercept data and perform special operations, such as encrypting data, to ensure data transmission security. In addition, the proxy server can control client access, for example, it can prevent the client from accessing a certain IP address or website.
SOCKS is a proxy protocol standard. Through this protocol, standard proxy services can be implemented.
On an enterprise network, firewalls are usually installed to ensure the security of the enterprise network. This ensures the security of the enterprise network, but prevents clients from accessing the external network. Therefore, a SOCKS proxy server is required to establish the connection and data communication between the client and the target site.
A SOCKS proxy can bypass the firewall to relay the user’s TCP and UDP sessions.
SOCKS5
SOCKS is the fifth session layer in the OSI seven-layer protocol, so it can process multiple request types including HTTP, HTTPS, POP3, SMTP, and FTP. Therefore, SOCKS can be used for email, web browsing, and file transfer.
In contrast to SOCK4, SOCKS5 has an authentication mechanism, so that a complete TCP connection can be established through authentication. SOCKS5 is usually used with SSH to relay traffic by using SSH encrypted tunnel methods.
So why do we need SOCKS5?
First we can use SOCKS5 to access the service behind the firewall.
Generally, servers are kept behind firewalls for security purposes, but there are two ways for outsiders to access the server. The first option would be to remove the firewall and open the service to the public, but that would pose a security risk. The second method is to filter out illegal access requests by setting the CLIENT IP address whitelist. But the IP address of the client usually sends changes, so this is also not feasible.
If you use the SSH proxy of SOCKS5, you can access the services behind the firewall through the proxy server to ensure service security.
In addition, an SSH tunnel can be established to route VARIOUS TCP and UDP traffic to their respective services using SOCKS5. In this way, only SSH is required and other VPN networks are not required. So it’s relatively simple to use.
Finally, because SOCKS5 simply forwards data, there is less chance of errors and higher performance.
The use of SOCKS5
We have introduced the advantages of SOCKS5, so how to use SOCKS5? Next, we will introduce a simple SOCKS5 proxy server using SSH command.
SSH/SOCKS/SOCKS/SOCKS/SOCKS
ssh -f -C -N -D bindaddress:port name@server
Copy the code
-f Indicates that the SSH is executed as a daemon process in the background.
-n indicates that no remote command is executed and only port forwarding is used.
-d indicates dynamic forwarding on a port. This command supports SOCKS4 and SOCKS5.
-c Compresses data before sending.
Bindaddress Binding address of the local server.
Port Specifies the listening port of the local server.
Name Indicates the login name of the SSH server.
Server Indicates the ADDRESS of the SSH server.
The above command means that port bindings are set up locally and then forwarded to a remote proxy server.
For example, we can open a port of 2000 on this machine and forward it to the remote 168.121.100.23 machine:
Ssh-f-n -d 0.0.0.0:2000 [email protected]Copy the code
Using the curl command, you can use the SOCKS proxy.
We want to access www.flydean.com through a proxy server. How do we do that?
curl -x socks5h://localhost:2000 -v -k -X GET http://www.flydean.com:80
Copy the code
To detect a connection for SOCKS, use the netcat command as follows:
Ncat -proxy 127.0.0.1:2000 -proxy-type socks5 www.flydean.com 80-nvCopy the code
conclusion
SOCKS5 is a very useful proxy protocol that you can use whenever you need it. You know!
This article is available at www.flydean.com/10-socks5-m…
The most popular interpretation, the most profound dry goods, the most concise tutorial, many tips you didn’t know waiting for you to discover!
Welcome to pay attention to my public number: “procedures those things”, understand technology, more understand you!