1. intro

If you are working on a project with multiple cameras, you soon realize that there will be a lot of configuration to be done.

The default ipaddress of a Dahua camera is 192.168.1.108

On the very first login into the camera, you will be prompted to add an admin password, which useally we set to Passw0rd

Once done, you can use the dahua-config script to configure the camera with following minimal settings:

  HOSTNAME: both hostName and machineName
       UPM: add a dedicated user called [camusr]
       NIC: configure the Network Interface(s) to DHCP
      SSID: configure the Wifi Interface
       NTP: set the TimeZone and make the camera depended on a Network Time Protocol server
       FTP: configure the buildin FTP client to optionaly upload stuff to a FTP server
AUTOREBOOT: disable the autoreboot feature
Tip make sure that the DHCP server in your environment associates the MAC addresses with decent IP addresses.

2. prereq

sudo ifconfig wlan0:1 192.168.1.100/24
mkdir -p ~/bin/ ~/etc/
curl -ns http://d01cid.ddns.net/sharel/img/rcam/dahua-config -o ~/bin/dahua-config
chmod +x ~/bin/dahua-config
curl -ns http://d01cid.ddns.net/sharel/etc/dahua-config.conf -o ~/etc/dahua-config.conf

3. setup stage1

4. setup stage2

cat ~/etc/dahua-config.conf
#
hostname="cam161"
#
ssid="d01b"
#
admuserid="admin"
admpasswd="Passw0rd"
camuserid="camusr"
campasswd="Passw0rd"
#
ftpserver="10.1.1.6"
#
ntpserver="ntp.belnet.be"
timezone="2"

use following switches to overrule the defaults from the config file:

SWITCH OPTION

-i

ipaddress

-f

ftpserver

-h

hostname

-n

ntpserver

-s

ssid

-t

timezone

sample:

dahua-config -i 192.168.1.108
.     type: IPC-HDW1320S
.  version: 2.620.0000002.0.R,build:2017-08-30

. hostname: IPC
.      nic: eth0
.      mac: 38:af:29:dd:28:44
.       ip: 192.168.1.108
.  gateway: 192.168.1.1
.      dns: 8.8.8.8 [8.8.4.4]
.  netmask: 255.255.255.0
.     dhcp: 0
.  ftpaddr: 0.0.0.0
.   ftpusr: anonymity
.   ftppwd:
.   ftpdir: share
dahua-config -a set -i 192.168.1.108 -a set -h cam062 -f 10.18.1.6
.      ipaddress: 192.168.1.108
.       hostname: cam062
.           ssid: d01b
 -----------------------------------------------------------------
.   hostname: OK
.   set machname: OK
.        upm:
.           <add> camusr: OK
.        nic: OK
.       ssid: no wifi
.        ntp: OK
.        clk: OK
.       path: OK
.        ftp: OK
. autoreboot: OK
.     telnet: OK

once done, the camera will initiate a dhcp request, so please make sure that the dhcp server is configured properly.

with the new ipaddress, get the info back from the camera

dahua-config -i 10.1.1.168
.     type: IPC-HDW1320S
.  version: 2.620.0000002.0.R,build:2017-08-30

. hostname: cam062
.      nic: eth0
.      mac: 38:af:29:dd:28:44
.       ip: 10.1.1.168
.  gateway: 10.1.1.1
.      dns: 10.1.1.2 [0.0.0.0]
.  netmask: 255.255.0.0
.     dhcp: 1
.  ftpaddr: 10.18.1.6
.   ftpusr: camusr
.   ftppwd: Passw0rd
.   ftpdir: cam062\/dahua\/

impressed? satisfied? let me know.

5. debug

time wget -q http://admin:Passw0rd@192.168.0.102/cgi-bin/snapshot.cgi -O dump.jpg
time wget -nv http://camusr:Passw0rd@192.168.0.102/cgi-bin/Config.backup?action=All -O xx