Pre Summary:
- [Raspberry Pi - Network Monitoring (1) Analysis Preparation] visual remote control can be set up based network monitoring Raspberry Pi - engineering analysis and preparation
- [Raspberry Pi - Network Monitoring (2)] picture transmission based on a transmission mjpg-stream to achieve the monitor screen
- [Raspberry Pi - Network Monitoring (3) Remote] angle imaging angle based on the two degree of freedom control servo python3 achieve remote camera
- - [Network Monitoring (4) data exchange Raspberry Pi] data binding interaction and the front and rear end of the python-based asynchronous io framework Tornado, implement and monitor remote command trigger event Web page
- [Raspberry Pi - Network Monitoring (5)] to build a front-end based on iframe tags, integrated real-time monitoring and remote control function screen to complete the build and debug network monitoring
In previous chapters, we realized the front and rear ends of the interaction data to complete the build and commissioning of the network camera LAN environment. But only a support LAN access "network" camera far enough to become a true sense of 网络
the camera, there is no practical purpose of the project, as the series finale, we will use the network penetration technology, achieve the public network remote access and remote monitoring, network cameras create a real sense, the project is drawing to a successful conclusion.
The basic idea:
Frp selected internal network monitoring through air, penetrating objects are monitored 控制页面
(after penetration Address: [web]) and a control page in the iframe tags 摄像头实时监控画面
(after penetration address: [web2]), both of which are We need to separately operate, during penetration should not be confused. Finally, the index.html
change in the link files iframe tag is [web2] , by accessing the [web] achieve external network access to network monitoring.
A, Frp configuration
Frp more about the principle and method of use scenarios, see bloggers column: Click here to go
Progress:
sudo apt-get update
wget https://github.com/fatedier/frp/releases/download/v0.17.0/frp_0.17.0_linux_amd64.tar.gz
tar -zxvf frp_0.17.0_linux_amd64.tar.gz
cd frp_0.17.0_linux_amd64
sudo vim ./frps.ini
添加以下内容:
[common]
bind_addr = 0.0.0.0
bind_port = 7000
vhost_http_port = 8080
#放行端口
iptables -I INPUT -i eth0 -p tcp --dport 7000 -j ACCEPT
iptables -I OUTPUT -o eth0 -p tcp --sport 7000 -j ACCEPT
iptables -I INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
iptables -I OUTPUT -o eth0 -p tcp --sport 8080 -j ACCEPT
#后台保持启动 需要在frp_0.17.0_linux_amd64目录下操作
nohup ./frps -c ./frps.ini &
Frpc:
sudo apt-get update
wget https://github.com/fatedier/frp/releases/download/v0.17.0/frp_0.17.0_linux_arm.tar.gz
tar -zxvf frp_0.17.0_linux_arm.tar.gz
cd frp_0.17.0_linux_arm
sudo vim ./frpc.ini
[Web] console penetration, [web2] penetration monitor screen, [SSH] As an option for detecting a connection failure when the penetration is smooth (REMOTE_PORT need to release the server side).
[common]
server_addr = your_server_ip
server_port = 7000
[web]
type = http
local_ip = 127.0.0.1
local_port = 80
custom_domains = p.***.com
[web2]
type = http
local_ip = 127.0.0.1
local_port = 8080
custom_domains = c.***.com
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 21
remote_port =6000
# 在frp_0.17.0_linux_arm目录下,测试:
./frpc -c ./frpc.ini
Two, index.html configuration
The index.html
LAN monitor screen iframe tag within the file, change the link after link of penetration. c. ***. com
<style type="text/css">
.warpper { overflow-x: auto;overflow-y:hidden; -webkit-overflow-scrolling: touch; width: 100%; height: 300px; margin: 2px auto; border: 0.1px solid black; }
</style>
<div class="warpper">
<iframe src="http://c.***.com:8080/stream_simple.html" style="height:500px;width:100%;" scrolling="yes" frameborder="0"></iframe>
</div>
Since only the 50M bandwidth of the test environment, so that the iframe tags in alternative network address with penetration link monitor screen, while an outer div an iframe original size width: 100%; height: 505px
change order width: 100%; height: 300px
to ensure that the picture transmission network through a remote access environment continuity and stability (also ancillary mjpg-stream parameters need to be adjusted, the detailed operation method Click here to view ). ( The final size can be determined according to the family after the actual network test )
Third, DNS
Fourth, test access
(1) to penetrate the network service is set to automatically boot
In all projects, a total of three ( 摄像头
, 监控控制页面
and 内网穿透
) involves boot from Kai settings to ensure ease of ongoing maintenance, uniform selection systemctl method, implementation requirements.
sudo vim /etc/systemd/system/frpc.service
[Unit]
Description=frpc daemon
After=syslog.target network.target
Wants=network.target
[Service]
Type=simple
ExecStart=/home/pi/frp_0.17.0_linux_arm/frpc -c /home/pi/frp_0.17.0_linux_arm/frpc.ini
Restart= always
RestartSec=1min
[Install]
WantedBy=multi-user.target
#启动frpc
su
systemctl daemon-reload
systemctl start frpc
#查看是否成功开启
systemctl status frpc.service
#设置为开机启动
systemctl enable frpc
(2) can be accessed under the external network environment http://p.***.com:8080
landed network monitoring mode
Engineering requirements | Duration | Completion (reaching \ not reached) |
---|---|---|
Raspberry Pi-based remote control can build visual network monitoring | Six chapters | Accomplish |
#工程后期维护、故障测试常用命令:
#摄像头:
cd /home/pi/mjpg-streamer-master/mjpg-streamer-experimental/
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"
nohup ./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www" &
#内网穿透
cd frp_0.17.0_linux_arm/
nohup ./frpc -c ./frpc.ini &
#控制页面
cd 111/
nohup sudo python3 index.py &
So far, we have penetrated through the intranet technology, the public network remote access and remote monitoring of raspberry pie, completed all work to build and deploy network cameras under public network environment. Create a complete control of their own network monitoring real sense, to achieve the desired objectives and results of the project!
TELL: expand the development example - to create a remote visual air conditioning remote control:
The basic idea:
By the installation of the infrared tubes, infrared or direct external programming module, "clone" air conditioner remote control infrared signal emitted, if necessary slavishly This signal is emitted, for air conditioning of the remote start.
If you have any questions or good suggestions, comments and look forward to your comments!