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

Error adding network: failed to add route '{0.0.0.0 00000000} via 191.168.1.1 dev eth0': network is unreachable #129

Closed kcalmond closed 3 years ago

kcalmond commented 3 years ago

Describe the bug Not able to complete installation and successful start of pihole in podman. UDMPro, 1.8.6 FW. I think maybe there is an implied step in modifying either 10.dns.sh or 20-dns.conflist that I'm missing...? (Do we have to change {"dst": "0.0.0.0/0"} line in 20-dns.conflist?)

To Reproduce Steps to reproduce the behavior: Followed these steps: 1 - Installed boot script: https://github.com/boostchicken/udm-utilities/blob/master/on-boot-script/README.md#steps 2 - Installed container-common: https://github.com/boostchicken/udm-utilities/tree/master/container-common#steps Then followed steps in Pihole Setup... 3 - Added a new Corp network: GW IP/Subnet: 192.168.1.1/24; VLAN ID=5; DHCP disabled (default UDM LAN network = 192.168.0.1/24) 4 - Used this 20-dns.conflist:

{
  "cniVersion": "0.4.0",
  "name": "dns",
  "plugins": [
    {
      "type": "macvlan",
      "mode": "bridge",
      "master": "br5",
      "mac": "e0:63:da:9e:d4:36",
      "ipam": {
        "type": "static",
        "addresses": [
          {
            "address": "192.168.1.15/24",
            "gateway": "191.168.1.1"
          }
        ],
        "routes": [
          {"dst": "0.0.0.0/0"}
        ]
      }
    }
  ]
}

5 - Made these changes to 10.dns.sh:

## configuration variables:
VLAN=5
IPV4_IP="192.168.1.15"
IPV4_GW="192.168.1.1/24"

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

6 - Create and run the pihole container: (this is where it fails...)

# 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.1 \
>     --dns=8.8.8.8 \
>     --hostname pi.hole \
>     -e VIRTUAL_HOST="pi.hole" \
>     -e PROXY_LOCATION="pi.hole" \
>     -e ServerIP="192.168.1.15" \
>     -e IPv6="False" \
>     pihole/pihole:latest
ERRO[0000] Error adding network: failed to add route '{0.0.0.0 00000000} via 191.168.1.1 dev eth0': network is unreachable
ERRO[0000] Error while adding pod to CNI network "dns": failed to add route '{0.0.0.0 00000000} via 191.168.1.1 dev eth0': network is unreachable
ERRO[0000] Error removing timer for container c37fffb606916bce7efed914171d4417184cc29588015ba9d49e63225f672d4e 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 c37fffb606916bce7efed914171d4417184cc29588015ba9d49e63225f672d4e: failed to add route '{0.0.0.0 00000000} via 191.168.1.1 dev eth0': network is unreachable

Expected behavior No errors encountered and pihole up and running in podman on my UDMP

UDM Information

kcalmond commented 3 years ago

Update

Cleaned things up:

ip link del dev br5.mac rm /etc/cni/net.d/20-dns.conflist podman rm pihole

Recreated a new Corp network, using this config instead: GW IP/Subnet: 192.168.1.254/24; VLAN ID=5; DHCP disabled

Used this version of 20-dns.conflist:

{
  "cniVersion": "0.4.0",
  "name": "dns",
  "plugins": [
    {
      "type": "macvlan",
      "mode": "bridge",
      "master": "br5",
      "mac": "e0:63:da:9e:d4:36",
      "ipam": {
        "type": "static",
        "addresses": [
          {
            "address": "192.168.1.15/24",
            "gateway": "191.168.1.254"
          }
        ],
        "routes": [
          {"dst": "0.0.0.0/0"}
        ]
      }
    }
  ]
}

Used this version of 10.dns.sh:

## configuration variables:
VLAN=5
IPV4_IP="192.168.1.15"
IPV4_GW="192.168.1.254/24"

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

Ran 10-dns.sh again in debug mode:

# sh -x ./debug_10-dns.sh
+ set -x
+ trap read debug
./debug_10-dns.sh: trap: line 4: debug: invalid signal specification
+ VLAN=5
+ IPV4_IP=192.168.1.15
+ IPV4_GW=192.168.1.254/24
+ IPV6_IP=
+ IPV6_GW=
+ FORCED_INTFC=
+ CONTAINER=pihole
+ CNI_PATH=/mnt/data/podman/cni
+ '[' '!' -f /mnt/data/podman/cni/macvlan ]
+ mkdir -p /opt/cni
+ rm -f /opt/cni/bin
+ ln -s /mnt/data/podman/cni /opt/cni/bin
+ '[' -f /mnt/data/podman/cni/20-dns.conflist ]
+ basename /mnt/data/podman/cni/20-dns.conflist
+ ln -s /mnt/data/podman/cni/20-dns.conflist /etc/cni/net.d/20-dns.conflist
+ ip link set br5 promisc on
+ ip link add br5.mac link br5 type macvlan mode bridge
+ ip addr add 192.168.1.254/24 dev br5.mac noprefixroute
+ '[' -n  ]
+ ip link set br5.mac promisc on
+ ip link set br5.mac up
+ ip route add 192.168.1.15/32 dev br5.mac
+ '[' -n  ]
+ grep -qxF 'interface=br5.mac' /run/dnsmasq.conf.d/custom.conf
+ podman container exists pihole
+ logger -s -t podman-dns -p ERROR 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
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 create and run the pihole container. Stll failing:

# 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.1 \
>     --dns=8.8.8.8 \
>     --hostname pi.hole \
>     -e VIRTUAL_HOST="pi.hole" \
>     -e PROXY_LOCATION="pi.hole" \
>     -e ServerIP="192.168.1.15" \
>     -e IPv6="False" \
>     pihole/pihole:latest
ERRO[0000] Error adding network: failed to add route '{0.0.0.0 00000000} via 191.168.1.254 dev eth0': network is unreachable
ERRO[0000] Error while adding pod to CNI network "dns": failed to add route '{0.0.0.0 00000000} via 191.168.1.254 dev eth0': network is unreachable
ERRO[0000] Error removing timer for container a73982e189cc019d1ada37320ac1451a324f9654231095c71e2789141cc5eaf3 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 a73982e189cc019d1ada37320ac1451a324f9654231095c71e2789141cc5eaf3: failed to add route '{0.0.0.0 00000000} via 191.168.1.254 dev eth0': network is unreachable
kcalmond commented 3 years ago

With enough eyeballs all typos are shallow. Especially ones appearing in the subject line of the issue 😄