UnraidOS host access to custom networks [Fix]
So quick little post about my favorite operating system, UnraidOS. A lot of my processes are hosted on this beautiful little machine but a major issue I had was communicating between the host (My UnraidOS operating system) and a container running on that host.
By default the setting 'Host access to custom networks:" in the Settings > Docker tab is set to false as this allows any docker container running on the host to be able to reach out and communicate with the host. This does go against the concept of containers and best-practices, but I swear I had a valid reason... so therefore we turned this setting on!
The way that the UnraidOS does this is by creating a shim-br0 network to connect all of my devices on the custom network (in my case br0) to the host system. What I decided to do was create a custom user script which checks to see if the network is created on startup, if it fails (which it often does) it will then create the network for you. The basic usage of this is just a command you can run in the UnraidOS console, which can be found below.
ip link add shim-br0 link br0 type macvlan mode bridge
ip link set shim-br0 up
One of the other fixes which I found on the forum is to turn off "Docker" by setting Settings > Docker "Enable Docker" to false, applying it, changing it back to true, and applying it again. Usually toggling the "Host access to custom networks" will force the system to re-create the network
Once installed, go to your Settings > User Scripts and create a new script, copy and paste the below script (which checks to see if the network exists, and if it doesn't create it).
#!/bin/bash
#!/bin/bash
ip link | grep 'shim-br0' &> /dev/null
if [ $? != 0 ]; then
echo "No shim br0 found, creating it!"
ip link add shim-br0 link br0 type macvlan mode bridge
ip link set shim-br0 up
ip route add 192.168.1.0/25 dev shim-br0
ip route add 192.168.1.128/25 dev shim-br0
else
echo "shim-br0 network was found!"
fi
Once saved go to the frequency and choose "At Startup of Array", which means this script will run whenever you start up your array (IE a restart or manually starting/stopping it). Even if the network was created correctly, this will still run and make sure.
Hopefully this helps you out and saves you many hours of debugging by always ensuring your container can reach the host!
The other way I'd recomend doing this, so you dont ever have to worry about it, is using the User.Scripts plugin. Most users of UnraidOS already have this to begin with, but if not just do the old google of "UserScripts UnraidOS" and you'll get it installed in no time.