Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Advanced customized digital monitoring host (Debian+UBNT Unifi-V)

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1 introduction part

1.1 Preface

My younger brother's shop wants to install monitoring, so I recommend the enterprise-level monitoring UBNT product Unifi-Video (the author recommends UBNT because it always insists on free software, and UBNT is very conscientious compared to some manufacturers' bad practice of charging licensing fees by points).

Because the Unifi NVR configuration of the official monitoring host is relatively low (in fact, the hard disk is too small), the price is relatively expensive, so the 6-port industrial computer is customized as the monitoring host (it can be used as both routing and switch ^ _ ^, saving money). The following is a screenshot of the hardware.

1.2 functional introduction

1) it has the function of digital monitoring host

2) acts as a routing function (1 port automatically obtains IP address, 2 ports to be determined)

3) act as a switch function (3 to 6 connectable cameras)

1.3 system architecture diagram

Note: the following practice part is the configuration process of customized soft routing (industrial control host).

2 practice part

2.1 Environment configuration

2.1.1 system environment

Hostnanme=ubnt.cmdschool.org

Eth0=dhcp

Br0=10.168.1.1

Eth [2-5] = 10.168.1.x/24

OperatingSystem=Debian8.6

If readers are beginners of Debian like me, you can refer to the following system-level configuration tutorials:

Http://cmdschool.blog.51cto.com/2420395/1877915

2.1.2 download the installation package

Download the installation package from the web page

Https://www.ubnt.com/download/unifi-video

Command line download

Wget http://dl.ubnt.com/firmwares/unifi-video/3.5.2/unifi-video_3.5.2~Debian7_amd64.deb

2.1.3 configuring apt feeds

Vi / etc/apt/sources.list

Comment out the following lines

# deb cdrom: [Debian GNU/Linux 8.6.0 _ Jessie_-Official amd64 DVD Binary-1 20160917-14:25] / jessie contrib main

Run the following command after saving and exiting:

Echo "deb http://ftp.cn.debian.org/debian Debian8.6 main" | tee / etc/apt/sources.list.d/debian.listecho "deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen" | tee / etc/apt/sources.list.d/mongodb-10gen.listecho "deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti" | tee / etc/apt/sources.list.d/unifi.listapt-key adv-- keyserver keyserver.ubuntu.com-- recv C0A52C50 Apt-key adv-keyserver keyserver.ubuntu.com-recv 7F0CEB10

Update the source repository:

Apt-get update

2.1.4 install package management tools and update libraries

Apt-get install aptitude; apt-get install-f; apt-get cleanaptitude update

2.1.5 configure time zone

Cp / usr/share/zoneinfo/Asia/Shanghai / etc/localtime

2.1.6 time synchronization

1) install time synchronization related packages

Aptitude install chrony

2) synchronization time

Chronyc sources

2.2 install the unifi-video program

2.2.1 install unifi-video and resolve dependencies and clean up the package cache

Dpkg-I unifi-video_3.5.2~Debian7_amd64.deb; apt-get install-f; apt-get clean

2.2.2 Command Line check Service start

Netstat-antp | grep unifi-video

The display is as follows:

Tcp6 0 0: 7080: * LISTEN 7381/unifi-videotcp6 0 0 127.0.0.1 LISTEN 7381/unifi-videotcp6 0 0: 7443:: * LISTEN 7381/unifi-video [...]

2.2.3 browser confirms that the service is normal

2.3 modify data storage location

2.3.1 determine the location of video storage

Find /-name\ * .mp4\ *

Note: gun recording video needs to be configured first (not detailed in the interface section)

The display is as follows:

[...] / var/lib/unifi-video/videos/e7219371-8d34-3744-a4b5-89acba09907c/2016/12/03/1480745255035_1480745257035_1480737512125_9603951.mp4/var/lib/unifi-video/videos/e7219371-8d34-3744-a4b5-89acba09907c/2016/12/03/1480743257037_1480743259037_1480737512125_7605951.mp4 [...]

Based on the above, you can determine the storage directory (the hard disk of 2TB should be hung to this directory):

/ var/lib/unifi-video

2.3.2 confirm that the installed hard drive is detected by the system

Fdisk-l

The display is as follows:

[...] Disk / dev/sdb doesn't contain a valid partition table [...]

2.3.3 hard disk Partition

Fdisk / dev/sdb

The display is as follows:

[...] Command (m for help): n [...] Select (default p): pPartition number (1-4, default 1): [...] Command (m for help): W [...]

New partition found:

Partx / dev/sdb

2.3.4 create PV

Pvcreate / dev/sdb1

2.3.5 create VG

Vgcreate dataStore / dev/sdb1

2.3.6 create LV

Lvcreate-L 1999 g-n data dataStore

2.3.7 formatting Partition

Mkfs.ext4 / dev/mapper/dataStore-data

2.3.8 get the UUID that has been formatted

Blkid / dev/mapper/dataStore-data

The display is as follows:

/ dev/mapper/dataStore-data: UUID= "0d1dc121-7bd0-46bd-8d85-5577ab322efc" TYPE= "ext4"

2.3.9 stop the unifi-video service

/ etc/init.d/unifi-video stop/etc/init.d/mongodb stop

2.3.10 data migration

Mount / dev/mapper/dataStore-data / mnt/mv / var/lib/unifi-video/* / mntumount / mnt

2.3.11 Mount Volume

Echo 'UUID= "0d1dc121-7bd0-46bd-8d85-5577ab322efc" / var/lib/unifi-video ext4 defaults 12' > > / etc/fstabmount-a

2.3.12 start the unifi-video service

/ etc/init.d/mongodb start/etc/init.d/unifi-video start

2.4 install the desktop environment

2.4.1 minimum installation of lxde

1) install related packages

Aptitude install xinit slim lightdmaptitude install-without-recommends lxde-core

2) configure the startup mode

Echo 'exec startlxde' > ~ / .xinitrcupdate-alternatives-- config x-session-manager

3) configure automatic login

Vi / etc/slim.conf

Modify the configuration as follows:

Default_user ubntauto_login yes

2.4.2 install Google browser

1) download the installation package

Download page:

Http://www.google.cn/chrome/browser/desktop/index.html

Downloaded command:

Https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

2) start the installation

Dpkg-I google-chrome-stable_current_amd64.deb;apt-get install-f

2.4.3 support for Chinese

Aptitude install fonts-droid

2.5 Integrated routing and switching

2.5.1 add Bridges

1) install the bridge kit

Aptitude install bridge-utils

2) create bridge interface

Brctl addbr br0

Note, please use the

Brctl delbr br0

2.5.2 assign specific functions to the Nic interface

Vim / etc/network/interfaces

Add the following configuration:

Auto eth0allow-hotpulg eth0iface eth0 inet dhcpauto br0iface br0 inet static address 10.168.1.1 netmask 255.255.255.0 bridge_ports eth3 eth4 eth5 eth6 up / usr/sbin/brctl stp br0 on

Note: eth0 automatically acquires IP,eth3-5 bridge mode (equivalent to switch)

Restart the service to make the configuration effective:

/ etc/init.d/networking restart

2.5.3 enable route forwarding

1) temporarily enable routing forwarding

Echo 1 > / proc/sys/net/ipv4/ip_forward

2) permanently enable routing forwarding

Vim / etc/sysctl.conf

Remove the comments for this trip:

Net.ipv4.ip_forward = 1

2.5.4 configure firewall rules with SNAT function

1) create firewall rules

Vim / etc/iptables.up.rules

Enter the following configuration:

# Generated by iptables-save v1.4.21 on Mon Dec 5 07:48:46 2016*filter:INPUT DROP [40 icmp 2032]: FORWARD ACCEPT [100631 FORWARD ACCEPT 98411806]: OUTPUT ACCEPT [61262 FORWARD ACCEPT 3785634]-An INPUT-I lo-j ACCEPT-An INPUT-I br0-j ACCEPT-An INPUT-I eth0-p icmp-j ACCEPT-An INPUT-m state-- state RELATED ESTABLISHED-j ACCEPT-An INPUT-p tcp-m tcp-- dport 7080-j ACCEPT-An INPUT-p tcp-m tcp-- dport 7443-j ACCEPT-An INPUT-p tcp-m state-- state NEW-m tcp-- dport 22-j ACCEPTCOMMIT# Completed on Mon Dec 5 07:48:46 2010s Generated by iptables-save v1.4.21 on Mon Dec 5 07:48:46 2016*nat:PREROUTING ACCEPT [1094V127184]: INPUT ACCEPT [11212VH 7768]: OUTPUT ACCEPT [53Rv 3815]: POSTROUTING ACCEPT [77 eth0 13304]-A POSTROUTING-s 10.168.1.0 take 24-o eth0-j MASQUERADECOMMIT# Completed on Mon Dec 5 07:48:46 2016

2) configure boot automatic loading

Echo'#! / bin/sh' > / etc/network/if-pre-up.d/iptablesecho'/ sbin/iptables-restore

< /etc/iptables.up.rules' >

> / etc/network/if-pre-up.d/iptableschmod + x / etc/network/if-pre-up.d/iptables

2.5.5 configure DHCP service

1) install DHCP service

Aptitude install isc-dhcp-server

2) modify the main configuration file

Cp / etc/default/isc-dhcp-server / etc/default/isc-dhcp-server.defaultvi / etc/default/isc-dhcp-server

The configuration parameters are as follows:

DHCPD_CONF=/etc/dhcp/dhcpd.confINTERFACES= "br0"

3) configure loaded sub-configuration files

Cp/ etc/dhcp/dhcpd.conf / etc/dhcp/dhcpd.conf.defaultvi / etc/dhcp/dhcpd.conf

The configuration is as follows:

Ddns-update-style none;option domain-name "cmdschool.org"; option domain-name-servers 202.96.128.86202.96.128.166; default-lease-time 100.168.86202.96.128.166; default-lease-time 7200; option routers 10.168.1.0; option routers 255.255.255.0 {range 10.168.1.51, 10.168.1.199; option broadcast-address 10.168.1.255; default-lease-time 600

4) start the service

/ etc/init.d/isc-dhcp-server start

2.5.6 configure Peanut Shell Domain name Resolution

1) install the software package

Aptitude install curl

2) create a parsing script

Mkdir ~ / script/vim ~ / script/pusoray.sh

Enter the following configuration (assuming the domain name is cmdschool.org):

#! / bin/bashdomain= "cmdschool.org" user= "username" pwd= "password" / usr/bin/curl "http://$user:$pwd@ddns.oray.com/ph/update?hostname=$domain"

3) automatically call the parsing script

Crontab-e

Enter the following configuration:

* / 3 * sh ~ / script/pusoray.sh

Refer to the documentation

=

Installation of unifi-video:

Https://help.ubnt.com/hc/en-us/articles/205146160-UniFi-Install-the-UniFi-controller-software-on-the-UniFi-Video-NVR

Https://help.ubnt.com/hc/en-us/articles/209754018-UniFi-Video-How-to-Install-UFV-version-3-x-on-a-Legacy-airVision-NVR

Debian source address:

Https://www.debian.org/mirror/list

Installation of Mongodb:

Https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/

Installation source for Mongodb:

Http://downloads-distro.mongodb.org/repo/debian-sysvinit/

UBNT official source address:

Https://help.ubnt.com/hc/en-us/articles/220066768-UniFi-How-to-Install-Update-via-APT-on-Debian-or-Ubuntu

Other references:

Https://my.oschina.net/u/2000604/blog/304171

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report