unifi-utilities / unifios-utilities

A collection of enhancements for UnifiOS based devices
GNU General Public License v3.0
3.86k stars 415 forks source link

Can't get pihole to work - CNI network not found #112

Closed timrsnbckr closed 3 years ago

timrsnbckr commented 3 years ago

Hello,

at first: Thank you for this great package of utilities! :)

Unfortunately I can't get Pihole to work on my new UDM Pro (firmware 1.8.6).

I created a VLAN:

grafik My Pihole should get 192.168.3.254 as IP address.

I sshed into UDM pro and ran the commands:

unifi-os shell curl -L https://udm-boot.boostchicken.dev -o udm-boot_1.0.4_all.deb dpkg -i udm-boot_1.0.4_all.deb exit

Then I created 20-dns.conflist in /mnt/data/podman/cni. (I had to create the cni folder). The mac address is a random address generated on onlinerandomtools.com

{ "cniVersion": "0.4.0", "name": "dns", "plugins": [ { "type": "macvlan", "mode": "bridge", "master": "br5", "mac": "23:5f:07:e9:15:bb", "ipam": { "type": "static", "addresses": [ { "address": "192.168.3.254/24", "gateway": "192.168.3.1" } ], "routes": [ {"dst": "0.0.0.0/0"} ] } } ] }

Now I created the 10-dns.sh file in /mnt/data/on_boot.d and changed the variables:

... VLAN=10 IPV4_IP="192.168.3.254" IPV4_GW="192.168.3.1/24" ... CONTAINER=pihole ...

After that I made the script executeable with chmod a+x 10-dns.sh. I executed the script and it showed:

podman-dns: Container pihole not found, make sure you set the proper name, you can ignore this error if it is your first time setting it up

After that I tried to run the pihole docker with this command:

podman run -d --network dns --restart always \ --name pihole \ -e TZ="local" \ -v "/mnt/data/etc-pihole/:/etc/pihole/" \ -v "/mnt/data/pihole/etc-dnsmasq.d/:/etc/dnsmasq.d/" \ --dns=127.0.0.1 \ --dns=1.1.1.1 \ --dns=8.8.8.8 \ --hostname pi.hole \ -e VIRTUAL_HOST="pi.hole" \ -e PROXY_LOCATION="pi.hole" \ -e ServerIP="192.168.3.254" \ -e IPv6="False" \ pihole/pihole:latest

It returned:

Trying to pull docker.io/pihole/pihole:latest... Getting image source signatures Copying blob eb774076c2a1 done Copying blob bd9775ce5c98 done Copying blob 54c4151dfd78 done Copying blob 1ad4e80be597 done Copying blob f218d23b8e43 done Copying blob aceecb32d1c3 done Copying blob f09a3462cef2 done Copying blob 33df9ce656ad done Copying config b537a7cd0e done Writing manifest to image destination Storing signatures ERRO[0033] CNI network "dns" not found ERRO[0033] Error removing timer for container 6e8b967bc1e463ca84f282a9637a692a0d74817767c461050f9140dbbdc76cbf healthcheck: unable to get systemd connection to remove healthchecks: dial unix /run/systemd/private: connect: no such file or directory Error: error configuring network namespace for container 6e8b967bc1e463ca84f282a9637a692a0d74817767c461050f9140dbbdc76cbf: CNI network "dns" not found

That's were I stuck now and I can't figure out where I could have done something wrong.

Would be great if someone could help me or maybe fix the issue, if there is a bug in the software.

Thank you :)

sondercoder commented 3 years ago

You need to change br5 to br10, since you are using vlan 10 in the 20-dns.conflist.

timrsnbckr commented 3 years ago

Hey @sondercoder ,

thank you for your fast answer but unfortunately it wasn't the solution. I changed "master": "br5", to "master": "br10", in the 20-dns.conflist file. I tried a reinstall too, when I execute 10-dns.sh it says

RTNETLINK answers: File exists RTNETLINK answers: File exists RTNETLINK answers: File exists podman-dns: Container pihole not found, make sure you set the proper name, you can ignore this error if it is your first time setting it up

Then I tried to start the docker and it shows

Trying to pull docker.io/pihole/pihole:latest... Getting image source signatures Copying blob bd9775ce5c98 done Copying blob eb774076c2a1 done Copying blob 1ad4e80be597 done Copying blob f218d23b8e43 done Copying blob 54c4151dfd78 done Copying blob aceecb32d1c3 done Copying blob f09a3462cef2 done Copying blob 33df9ce656ad done Copying config b537a7cd0e done Writing manifest to image destination Storing signatures ERRO[0033] CNI network "dns" not found ERRO[0033] Error removing timer for container db4e4f41550e2e16f00c0afa92f464fddc56d88605bb63533e4ea96b049ed74d healthcheck: unable to get systemd connection to remove healthchecks: dial unix /run/systemd/private: connect: no such file or directory Error: error configuring network namespace for container db4e4f41550e2e16f00c0afa92f464fddc56d88605bb63533e4ea96b049ed74d: CNI network "dns" not found

again. :(

HideTheMonkey commented 3 years ago

Hey @timrsnbckr,

I ran into a similar issue and it turned out, at least in my case, that the mac address needed to have a prefix from a known registered company. I used https://macaddress.io/mac-address-generator (be sure to check "Registered only" in the prefix section) and that got me up and running.

Good luck!

alawSD commented 3 years ago

Having the same issue (running on vlan5) on a DreamMachinePro version 1.8.6.

# cat /mnt/data/on_boot.d/10-dns.sh

!/bin/sh

## configuration variables: VLAN=5 IPV4_IP="10.0.5.3" IPV4_GW="10.0.5.1/24"

# set this to the interface(s) on which you want DNS TCP/UDP port 53 traffic # re-routed through the DNS container. separate interfaces with spaces. # e.g. "br0" or "br0 br1" etc. FORCED_INTFC="br5"

# container name; e.g. nextdns, pihole, adguardhome, etc. CONTAINER=pihole

# /mnt/data/on_boot.d/10-dns.sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 640 100 640 0 0 2831 0 --:--:-- --:--:-- --:--:-- 2831 100 35.3M 100 35.3M 0 0 14.2M 0 0:00:02 0:00:02 --:--:-- 17.4M ln: /etc/cni/net.d/20-dns.conflist: File exists RTNETLINK answers: File exists RTNETLINK answers: File exists RTNETLINK answers: File exists ERRO[0000] CNI network "dns" not found
ERRO[0000] Error removing timer for container b57f6da444c9846bee49cf24f41a6ff7ae469f92d147fe71fb5bfb679f2f2092 healthcheck: unable to get systemd connection to remove healthchecks: dial unix /run/systemd/private: connect: no such file or directory Error: unable to start container "pihole": error configuring network namespace for container b57f6da444c9846bee49cf24f41a6ff7ae469f92d147fe71fb5bfb679f2f2092: CNI network "dns" not found

# podman run -d --network dns --restart always \ --name pihole \ -e TZ="America/Los Angeles" \ -v "/mnt/data/etc-pihole/:/etc/pihole/" \ -v "/mnt/data/pihole/etc-dnsmasq.d/:/etc/dnsmasq.d/" \ --dns=127.0.0.1 \ --dns=1.1.1.2 \ --dns=1.0.0.2 \ --hostname pi.hole \ -e VIRTUAL_HOST="pi.hole" \ -e PROXY_LOCATION="pi.hole" \ -e ServerIP="10.0.5.3" \ -e IPv6="False" \ pihole/pihole:latest ERRO[0000] CNI network "dns" not found
ERRO[0000] Error removing timer for container b57f6da444c9846bee49cf24f41a6ff7ae469f92d147fe71fb5bfb679f2f2092 healthcheck: unable to get systemd connection to remove healthchecks: dial unix /run/systemd/private: connect: no such file or directory Error: error configuring network namespace for container b57f6da444c9846bee49cf24f41a6ff7ae469f92d147fe71fb5bfb679f2f2092: CNI network "dns" not found

tillh commented 3 years ago

I had the same problem. To check if the network was created, I ran "podman network ls". I got a "too many levels of symbolic links" exception. So I copied the file "20-dns.conflist" to the directory "/etc/cni/net.d/" instead of creating a symbolic link.

MichielOtten commented 3 years ago

Did you also do the following step:

Create directories for persistent Pi-hole configuration

mkdir -p /mnt/data/etc-pihole mkdir -p /mnt/data/pihole/etc-dnsmasq.d

see: https://github.com/boostchicken/udm-utilities/tree/master/run-pihole

timrsnbckr commented 3 years ago

Sorry for the late reply. It's working for me now!

The main problem was something with the .conf and .sh file. When I created them with touch and vim it gave me that error which I posted here. I had to download the files via curl and then edit them with vim - after that it worked.

adrienbrault commented 3 years ago

@HideTheMonkey Thank you, using a mac address from https://macaddress.io/mac-address-generator solved that specific issue for me.