Why is this a problem? Because as a developer or operations staff will encounter such a situation, companies often have some not connected to the Intranet server, work needs to be deployed on the server part of the business, but this part of the business, and need to be connected to the Internet to download some rely on the project to use (offline deployment and cumbersome), how to break?

The above description seems a little convoluted, but in a word: how to solve the network access problem of the Intranet machine? !

Methods a

Some people say that is not easy, find a network cable can be connected to the Internet plug in, configure an IP address, done! This situation is also the simplest and most direct way to hit the nail on the head. You can do this if you can, but it’s usually not allowed, or you can’t find a network port in the machine room. (Remember to plug the network cable back in after operation)

Method 2

If you have access to a server and don’t have a network cable, use the following method. Get your phone and data cable ready. Connect one end of the cable to the server and the other end to your phone. Find a USB network share on your phone and click open. You’ll have a temporary network card in your system that you can use to update your network.

Methods three

Of course, since you can use USB to connect to the Internet, you can also use USB WIFI receiving adapter to connect to the Internet.

Methods four

The first three methods can operate on the premise that the server is beside, but if not beside, and can not fiddle with the IP address, how to network? You can also use a proxy server, which is a tool that sends requests from the original server to a remote server for secondary forwarding. Therefore, it does not matter if the server itself cannot be connected to the Internet, as long as the proxy server can access the Internet and communicate with the server itself.

The proxy server must be able to communicate with the public network as well as the Intranet server. Therefore, two (virtual) network adapters are required, or two IP addresses in different segments are configured using network switching devices.

Proxy server side operation

As a proxy server, it must be supported by proxy service software. Since it is temporary, I use Windows system to build it here. First, install CCProxy software. It is a charging software, but it can be used online by 3 users without purchase, which is enough for our use.

On the home screen, click the Settings button. Check HTTP/RTSP and Secure, as well as other protocols depending on your situation, mainly these two. After checking, click Automatic detection or manually select LAN IP address to ensure that other computers on the LAN can access it.

Return to the main interface and click “Start” to start the service normally. (Remember to temporarily turn off the proxy firewall, or manually open ports in the list)

Client operation

1. In Windows, search for the proxy server. The following page is displayed. Enter the network and IP address of the proxy server, click Save, and enjoy the Internet.

2. In Linux, run the following commands to change the IP address and port number of the proxy server to the IP address and port number of the proxy server.

Export http_proxy = http://192.168.31.3:808 export https_proxy = http://192.168.31.3:808Copy the code

But it needs to be executed again every time you restart the machine, and you can add it to the environment variable.

Echo "export http_proxy=http://192.168.31.3:808" >> /etc/profile echo "export https_proxy=http://192.168.31.3:808" >> /etc/profile source /etc/profileCopy the code

That will do.

In addition, using the above method, when Docker is used to pull the image, it is found that it cannot be pulled normally, because Docker still goes to the default path of the system. Therefore, if you need to pull the Docker image online, you need to perform the following configuration.

mkdir -p /etc/systemd/system/docker.service.d
vim /etc/systemd/system/docker.service.d/http-proxy.conf
Copy the code

Add the following:

[Service] Environment = "HTTP_PROXY = http://192.168.31.3:808/"Copy the code

Restart the Docker

systemctl daemon-reload
systemctl restart docker
Copy the code

Validation:

systemctl show --property=Environment docker
curl www.baidu.com
Copy the code

If the proxy server configuration or access baidu normally occurs, you can arbitrarily pull a Docker image, then the configuration is successful!