Skip to content

Instantly share code, notes, and snippets.

@turingbirds
Created March 27, 2020 09:37
Show Gist options
  • Save turingbirds/6100e48de1d6b0844592744554fd0ed7 to your computer and use it in GitHub Desktop.
Save turingbirds/6100e48de1d6b0844592744554fd0ed7 to your computer and use it in GitHub Desktop.

Connect an IP camera via wired ethernet to an ethernet USB adapter to a Raspberry Pi

Connect the camera to the ethernet USB adapter via a CROSSOVER cable (or via an ethernet switch).

Install DHCP server:

sudo apt install isc-dhcp-server

Edit config:

sudo nano /etc/default/isc-dhcp-server

and bind only to the USB adapter ethernet interface (e.g. "enp1s0"):

INTERFACESv4="enp1s0"
INTERFACESv6=""

Edit config, let's assign to 192.168.185.0/24:

sudo nano /etc/dhcp/dhcpd.conf
subnet 192.168.185.0 netmask 255.255.255.0 {
  option routers 192.168.185.1;
  option subnet-mask              255.255.255.0;
  range   192.168.185.10   192.168.185.200;
  option domain-name-servers ns1.internal.example.org;
  option domain-name "internal.example.org";
}

host ipcam {
  hardware ethernet 00:75:5e:93:7c:92;
  fixed-address 192.168.185.201;
}

Allow through firewall:

sudo ufw allow bootps

Bring up:

sudo ip addr add 192.168.185.1/24 dev enp1s0
sudo ip link set enp1s0 up
sudo systemctl restart isc-dhcp-server

N.B. remove any other addresses from enp1s0 that might be present.

Add route:

sudo ip route add 192.168.185.0/24 dev enp1s0

Troubleshooting:

sudo nano /var/lib/dhcp/dhclient.leases
sudo tcpdump -v -n -i enp1s0 port bootps or port bootpc
tail -f /var/log/syslog

Check assigned IP address from logs and visit camera configurtion panel in the web browser. Grab RTSP port number (554), disable wifi, etc.

wget http://192.168.185.201/snap.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment