The foreword 0.

With the rapid development of science and technology, mobile phones are changed more and more frequently. Many old mobile phones have been eliminated. These old mobile phones are generally useless and cannot be sold.

For most people, these old phones are unusable. Although there are many tutorials on how to use old phones online, many of them are either useless or difficult to operate, requiring strong hands-on skills.

Here’s how to quickly and cheaply turn an old Android phone into a remotely accessible camera.

This article positioning is a more basic tutorial, assuming that you are not familiar with this aspect, so the text is more verbose content, some technical points if you have some understanding, you can skip the content.

1. Set up a LAN camera

Set up local area network (LAN) camera needs a software, that is, IP – webcam, access to the Google store user can directly within the store search “IP – webcam” downloading, to not be able to access the user can go to https://www.appsapk.com/ip-webcam/ to download.

Ip-webcam is free software (the free version is advertised). It has a paid Pro version, which is more powerful, but can only be purchased in the Google Store. If you want to buy it but don’t have a payment card available, you can recharge it with a gift card, which is sold on Taobao. But for the average user, the free version is enough.

The ip-Webcam icon looks like this:

When you open it, it looks something like this:

Since we will put the camera on the public network later, we need to set an account password, otherwise it will be very insecure. However, the password can be left blank if it is only used on the LAN.

Note that if the uplink bandwidth of the home network is low, you can lower the video resolution and frame rate. Otherwise, Internet access may be delayed.

After setting up, turn to the last bar and click open server.

After the service is started, the video connection address will be displayed on the interface as follows:

As shown in the picture above, the address above is the service access address. Enter this address on any computer or mobile phone in the current network to access the camera. Click the browser option to see the content of the video.

As you can see, in addition to viewing video, it has many functions, such as: motion detection (automatic capture), on/off flash, circular recording and so on.

There are more advanced features, such as tasker to develop more features, you can explore.

Note:

If you use a mobile phone as a camera, you need to pay attention to the heating problem. Because of the design problem of some mobile phones, opening the camera for a long time will lead to serious heating of the phone. If the camera is heated for a long time, the equipment may be damaged. Operating at room temperature for more than one or two hours without overheating and shutdown problems can be used as a camera that is always on. But still need to be careful not to place in high temperature or direct sunlight.

If it is always on, it should be placed near the power supply, or buy a long cable to charge it.

2. Connect to the public network

The above enabled camera can only be used in the LAN, if you need to use the public network, then slightly more troublesome. If your broadband has a static public IP address, you can set up a port mapping on the router to access the Internet.

However, most users have access to dynamic public IP addresses or shared public IP addresses, so setting port mapping does not work. Therefore, other solutions need to be considered.

2.1 Free Scheme

If you don’t want to spend money, you can directly search dynamic domain name resolution, Intranet penetration to find relevant software, there are many commercial software can be used, such as peanut shell, NAT123 and so on. These commercial software have detailed use instructions, I will not repeat, there is a need to search for the use of the scheme, for the hands-on ability is not too strong or demand is not the user, directly registered after the use of free packages, relatively easier to install.

However, free generally has many restrictions, such as traffic restrictions, mapping restrictions, domain name restrictions and so on. And real-name authentication is generally required. Therefore, I tried this scheme for a period of time, but I felt uncomfortable with it, so I gave it up.

2.2 Geek solution

First of all, this solution is not free, but all the content can be controlled in their own hands, if you just need a home camera, and do not want to spend too much money, it may be cheaper to directly go to Taobao to buy a finished tape service.

(because the position may involve family camera privacy area, so the individual of some commercial camera directly unencrypted video data uploaded to the company on the server is very distrust, in addition, many commercial cameras in order to facilitate remote debugging installation, has the certain remote control scheme, I believe that the business company employees not to view the video information, But this approach leaves room for malicious hackers, so I’ve built my own service.)

The solution I use requires a public network server as a proxy, because the server does not carry the main computing services, but only does traffic forwarding, so it does not need high performance, nor a large amount of storage space. At present, I use the beggar-level configuration of 1 core 1G, which is rented from Aliyun for more than 300 yuan a year. Part, of course, the server will be cheaper abroad, such as on other platforms I rent the server, the service costs about 200 yuan a year, catch up with the promotion, less than 100 yuan can rent one year of service, but because it is doing traffic forwarding, and mainly in the domestic, abroad server lag a little big, So I bought the more expensive Aliyun service. It should be noted that if you do not want to put on record, you can buy Hong Kong server, of course, foreign CN2 is also acceptable.

Most importantly, a service can do many things, including but not limited to the following: private cloud disk, personal website, Git repository, proxy service, game server, download service, crawler.

2.2.1 Implementation Principle

Here’s how it works:

It uses a proxy-server on the public network as a springboard to access the server from any location on the public network, and then the server forwards the received information to the corresponding proxy client. The proxy client accesses the service on the Intranet. After the Intranet service responds, the proxy client transfers the service back in the reverse path. Finally, the service on the Intranet can be accessed from any location.

Pictures from: https://github.com/ffay/lanproxy/blob/master/README_en.md

2.2.2 Implementation scheme

I found an open source reverse proxy tool on GitHub that has a packaged version and is very simple to deploy: LanProxy.

Making address: https://github.com/ffay/lanproxy

Lanproxy is an Intranet penetration tool that proxies PCS and servers on the LAN to the public network. Currently, lanProxy only supports TCP traffic forwarding and supports any TCP upper-layer protocol (access to Intranet websites, local payment interface debugging, SSH access, remote desktop…). . At present, there are peanut Shell, TeamView, GoToMyCloud and so on that provide similar services in the market. However, if you want to use the public network server of the third party, you have to pay for the third party, and these services have various restrictions. In addition, data packets will flow through the third party, so it is also a big risk to data security.
lanproxy.io2c.com

2.2.3 Downloading software

To https://seafile.io2c.com/d/3b1b44fee5f74992bb17/ to download package good server and client.

2.2.4 Uploading the Server to its Own Server

I myself use aliyun server, CentOS 7.4 system, so I will introduce this system as the base, of course, other systems are also supported (including various Linux and WIndows).

One thing to note here is that you need to be familiar with some basic Linux commands, assuming you know some basic Linux commands.

If you familiar with vi (vim) such as text editing commands, upload the original package to the service server end, after decompression through these commands to the configuration file (proxy server – 20171116 / conf/config. Propertoes) for editing.

Related orders, if you are not familiar with Linux text editor can now extract on their own computers, find the corresponding configuration file (proxy server – 20171116 / conf/config. Propertoes) for editing, and once again after compression can also be uploaded to the server.

The default configuration file is as follows:

Bind =0.0.0.0 server.port=4900 server.ssl.enable=true server.ssl.bind=0.0.0.0 server.ssl.port=4993 server.ssl.jksPath=test.jks server.ssl.keyStorePassword=123456 server.ssl.keyManagerPassword=123456 Server. The SSL. NeedsClientAuth = false config. Server. The bind = 0.0.0.0 config. The server port = 8090 config. Admin. The username = admin config.admin.password=adminCopy the code

Note: Modify the username and password fields.

Then upload the server to the server using the SCP command:

SCP local_file remote_username@remote_ip:remote_folder # Example: SCP lanproxy-server-20171116.zip [email protected]: / home/lanproxyCopy the code

2.1.3 Installing basic Tools

Use SSH command login server, Ali Cloud can be directly logged in the web page, other servers can use SSH command login.

# Login to the server SSH root@ip # Enter the password, the password from the platform to purchase the server, input the password will not display any characters, after entering directly click enter.Copy the code

If you do not have a zip decompression tool on your service, you can install it using the following command:

yum install zip unzip
Copy the code

In addition to these tools, you will need to install the Java runtime environment (OPENJDK 1.7 or 1.8).

Yum install Java - 1.7.0 - its x86_64Copy the code

Decompress the software after installation:

unzip lanproxy-server-20171116.zip
Copy the code

2.2.5 Starting the Service

Go to the bin directory in the decompressed folder and run the following command:

./startup.sh
Copy the code

If the startup is successful, it displays a PID, for example:

./startup.sh Starting the proxy server ... started PID: 19875Copy the code

At this point, the service is officially started, and subsequent content can be set on the web page. Visit http://IP:8090 and you can see the management page (IP is the public IP address of the server).

PS: If no, check whether the port, the firewall of the server, and the security group rules of Aliyun can be pinged through.

The login page is as follows:

Log in with the user name and password configured before. After login, add a client as follows: write a random name and use the randomly generated key.

Then you will see a new entry g-IPcam in config Management. Click this entry and then click Add Configuration to add port mapping (add a camera mapping, and fill in the back-end proxy information with the IP address previously displayed on the camera) :

After clicking Submit, a map is added.

Note:

If the aliyun server is used, you need to set the security group configuration to open port 8080; if the server is on other platforms, you need to set the firewall to open port. The specific setting method needs to be set according to the server system type, and you can search by yourself.

2.2.6 Client Connection

Use any host on the LAN as a springboard to connect to the proxy server on the public network.

The following paragraph is taken from the LanProxy documentation.

As long as the client is successfully connected, it can be accessed through the Internet. Install the client on any computer host in the LAN where the phone is located. There is a Java-based cross-platform client in the distribution package downloaded above, and the configuration is as follows:

The Java Client configuration file is placed in the conf directory and config.properties is configured

The key must be the same as that used to create the client in the proxy-server configuration background. Ssl. key= ssl.enable=true ssl.jksPath=test. JKS ssl.keyStorePassword=123456 Server.host=lp.thingsglobal.org #proxy-server SSL default port 4993 If ssl.enable=true, set this parameter to SSL port. If SSL. enable=false, set this parameter to server.port=4993Copy the code
  • Install java1.7 or later
  • In Linux (MAC), run startup.sh in the bin directory
  • In Windows, run startup.bat in the bin directory

If you don’t want to install a Java environment, you can simply run the client compiled for the platform.

Normal port connection
# MAC 64-bit nohup./client_darwin_amd64 -s SERVER_IP -p SERVER_PORT -k CLIENT_KEY & # Linux 64-bit nohup./client_linux_amd64 Exe -s SERVER_IP -p SERVER_PORT -k CLIENT_KEY & # Windows 64-bit./client_windows_amd64.exe -s SERVER_IP -p SERVER_PORT -k CLIENT_KEYCopy the code
SSL Port Connection
# MAC 64-bit nohup./client_darwin_amd64 -s SERVER_IP -p SERVER_SSL_PORT -k CLIENT_KEY -ssl true & # Linux 64-bit nohup ./ client_linux_AMd64 -s SERVER_IP -p SERVER_SSL_PORT -k CLIENT_KEY -ssl true & # Windows 64-bit./client_windows_amd64  -s SERVER_IP -p SERVER_SSL_PORT -k CLIENT_KEY -ssl trueCopy the code

If no error occurs, the connection status of the client becomes online on the web page, as follows:

As you can see, one of the above clients is connected and the other is offline.

2.2.7 Viewing Information on the Public Network

If all the preceding steps are normal, you can view the camera on the web page when the client is displayed online. Visit http://proxy-server-ip:8080 (for example, http://12.34.56.78:8080) to check whether the display is normal.

If normal, the following screen will be displayed:

If the display fails, check the following problems one by one:

  1. Check whether the server can be pinged.
  2. Check lanproxy

2.2.8 Independent camera

On camera and public communication between the server host USES a local area network as a springboard, need a in an open position in order to ensure the camera connection is normal, but it will cause some other problems, such as host fan noise is too big, more power consumption and so on, after all, we just need a little transit service, it will appear to be wasted. In order to solve this problem, I was going to buy a raspberry PI as a traffic transfer device in the LAN. After all, the power consumption of raspberry PI is much smaller than that of personal PC, and it is much quieter.

I found out that Meefik had developed an application for deploying Linux directly on Android devices, so I thought, well, if you can deploy Linux, why don’t you redirect traffic directly on the phone where the camera is? So again toss and turn, finally confirmed that the scheme is feasible, but the process is more troublesome, the following to share the main process.

  1. Obtain the root permission.
  2. Install the busybox
  3. Installing Linux deploy

As the Android system becomes more and more perfect, root is no longer needed in most cases, resulting in the unusable root tools. After trying almost all root tools, I finally obtained root permissions by swiping. The device I use is an old Huawei mobile phone. I first apply to unlock the bootloader on the official website, and then swipe into the Recovery of a third party. Finally, I find a system with root permission on the Internet and swipe into it. Basic are bundled with some garbage applications, which do pure pack because can not profit, most of the early do not update, so brush machine need to be careful.

Of course, if the phone is almost no longer used, you can do whatever you like, but remember to uninstall all the junk apps as soon as possible. I used Es file browser, and used its root toolbox to uninstall the junk apps in the system. After uninstallation, restart the device.

If you have the root permission properly, the rest is simple. Go to Github·Busybox to download the APK file and install it on your phone. If BubsyBox requests root permission, click Allow.

If you need to install the corresponding version of the system, you can search the relevant tutorials on the Internet, such as “Linux deploy installs CentOS”, because the tutorial is too long, here will not be described more.

After the system is installed, SCP command is also used to upload the corresponding client to the system. For example, I have installed a KAIL system with armV71 architecture and need to upload client_linux_arm7 file. After completion, I use SSH to log in to the system. Start the service in the same way as the previous step. If you can see that the service status is online on the web page, it indicates that the service can be used normally. The subsequent steps are the same as the previous two steps.

In this way, you can save a PC to switch to, open the camera on the same mobile phone, and directly connect to the server on the mobile phone, saving power and avoiding host noise.

3. The other

If you have your own domain name, you can bind the server IP address to your own domain name for easy memory.

Some servers only allow port 80 to be enabled. In this case, nginx or proxyGateway, another software developed by lanProxy authors, can be used to forward services from other ports to port 80. For example, the remote camera service is proxied to port 8080, and we need to access it through this link: Gcssloop.com :8080. However, port 8080 is closed and therefore cannot be accessed. In this case, nginx is used for port forwarding and cat.gcssloop.com is configured to forward port 8080.

server { listen 80; server_name cat.gcssloop.com; location / { proxy_pass http://localhost:8080; }}Copy the code

We can check out the camera by going to cat.gcssloop.com.

If you have multiple cameras, this configuration will allow you to access them by domain name, such as room.gcssloop.com(indoor), door.gcssloop.com(door.gcssloop.com), without having to remember any annoying port addresses.

4. Afterword.

Using this scheme deployment camera basically don’t have to write code, only according to the fixed format to fill some of the configuration file is ok, so do not need to know how deep to programming, the only trouble is likely to be the server selection, and some related Linux command, believe who read this article for Linux to understand somewhat, It’s easy to learn, even if you don’t know much about it, because there are only a few commonly used instructions, and even if you don’t, it’s worth spending an hour or two learning them.

If you like, you are welcome to donate some server fees.

About the author

GcsSloop, a 2.5 dimensional mage.