UnraidUnraid
Unraid OS Bug Reports

Muti Nic Macvlan host enabled relapse ip added docker rc script issue

B
bmartino1inUnraid OS Bug Reports
9 months ago

Expected Behavior

What did you expect to happen?

When running this script on a single nic sytem Unraid docker shim bridge re creation gets creation static ip or if no static ip line is given it corectly gets an assigned IP… Instead of curent incroect duplcates of the eth0 interface due to br0 creation on urnaid ip either via dhcp/static ip… This has been a long running bug and issue… instead of grabbing a new dhcp IP… you have the script hard coded to reuse the br0 assinged ip…

with the runign of the ipdve flush on a muti nic system (as there are no issues on a sinble port sytems) the static ip is asigned and not adding a secondary…

Actual Behavior

What actually happened?

docker rc shim bridge/vhost0 creation should be geting there own ip like a seperate service…
when the scipt is run it works the interface is flushed the static ip is asigned.

Steps to Reproduce

  1. https://forums.unraid.net/topic/178033-bmartino1-user-scripts/#findComment-1492333

  2. Folwing the script edit here…

  3. user script run with docker auto start, sleeps 30 secds array is on a docker in macvlan is on hoste custm enabled is on…

  4. script runs shimbr0 goes down scirpt runs flsuh remving what the docker rc does set static ip. brings interface up.

  5. User happ / network happ. no unifi Log/notfiaction/ayonace…

  6. (on muti nic sytem after its up a few secods latter) we get
    inet 192.168.2.248/24 scope global secondary shim-br0 valid_lft forever preferred_lft forever

  7. This is a bug as in previos run of this work aroud script due to unfi networks duplace ip warning seeing mutiple nics… this rasies the quesiton why doe s sinalge nic sytem work when a 2 nic sytem get every sec secondary added inet..

    1. watch -n 1 ip addr show dev shim-br0

    2. ip addr del 192.168.2.248/24 dev shim-br0

    3. ps aux | grep -E 'docker|emhttp|inet'

  8. runnigin the above you can see that the docker rc script is rewrite and over laping bad code… again only seen in muti nic sytems…

    1. single nic sytem / vm sytme no issues. used this scirpt in version 6 for years…

    2. muti nic sytem v6.9+ some known problems araound the macvlan trace bug and issues… v7 + didn’t noitce until now when updating unfi hafrdware and test saw the vhost/shimbr0 flip flping in unifi and a investigation shown 2 nics assinged…

      1. the flush comand should stic and ther is no reason on a muti nic sytme to get the same ip address (the web ui should also edtis and netowrk contorl in teh web ui interface for all interfaces! (including docekr br0 nets…)

Additional Context

Anything else we should know? (recent upgrades, hardware changes, plugins, etc.)

n/a onging issue new persitence of bad docker rc script code…

Workarounds

Have you found any workaround or temporary fix?

Replace your dcoker rc script…

Screenshots / Videos / Diagnostics

Please attach the diagnostics and any videos or screenshots to demonstrate the issue
atempteed to will add as a coment…

per ai with solutions:

This is the exact block (your file): it literally does ip -4 addr add $IPV4 dev $SHIM metric 0.

docker rc

So if you want shim-br0 to keep your IP (192.168.2.247) and not get br0’s IP (192.168.2.248), the right fix is:

✅ If shim already has an IPv4 address, do NOT copy $IPV4 to it.
(and also: don’t try to delete $IPV4 later on stop unless you were the one who added it)

Below is a clean patch approach that won’t “add/delete/add/delete” in a tight loop.


Patch logic (what we change)

Current Unraid behavior (bad for you)

  • Create shim interface

  • Always add br0 IPv4 to shim:

    • ip -4 addr add $IPV4 dev $SHIM metric 0

      docker rc

Desired behavior

  • Create shim interface

  • If shim already has a primary IPv4 (like your 192.168.2.247), keep it

  • Only add $IPV4 if shim has no IPv4 at all

  • Track what we added so stop removes only what Unraid added (not your static)


Minimal diff you can apply to /etc/rc.d/rc.docker

1) Add a small helper (near the other functions is fine)

# get first primary global IPv4 CIDR on iface
iface_ipv4(){
  ip -4 -br addr show scope global primary dev "$1" 2>/dev/null | awk '{print $3; exit}'
}

2) Replace the “copy parent IPv4 address to shim interface” block

Find this section in your TYPE == br shim code:

docker rc



(it’s right under: # copy parent IPv4 address to shim interface)

Replace:

# copy parent IPv4 address to shim interface
run ip -4 addr add $IPV4 dev $SHIM metric 0
add_entry "$SHIM $IPV4 metric 0"

with:

# If user already assigned an IP to shim, do NOT copy parent's IP (prevents duplicate IP)
SHIMV4=$(iface_ipv4 "$SHIM")

if [[ -n "$SHIMV4" ]]; then
  log "shim $SHIM already has IPv4 $SHIMV4; skipping parent copy of $IPV4"
  USEIP="$SHIMV4"
else
  USEIP="$IPV4"
  run ip -4 addr add "$USEIP" dev "$SHIM" metric 0
  echo "$USEIP" > "/var/tmp/${SHIM}.added_ip"
fi

add_entry "$SHIM $USEIP metric 0"

3) Fix the “stop/remove shim assignment” path

In docker_network_stop() (and also the elif [[ -e $SYSTEM/$SHIM ]] removal path in start), Unraid currently does:

run ip -4 addr del $IPV4 dev $SHIM metric 0

That’s wrong once we stop blindly using $IPV4. Replace with:

DELIP=
[[ -f "/var/tmp/${SHIM}.added_ip" ]] && DELIP=$(cat "/var/tmp/${SHIM}.added_ip")

if [[ -n "$DELIP" ]]; then
  run ip -4 addr del "$DELIP" dev "$SHIM" metric 0
  rm -f "/var/tmp/${SHIM}.added_ip"
fi

This ensures Unraid only removes what it added, and it won’t touch your 192.168.2.247.

Closed
Loading content, please wait...
Loading content, please wait...
Loading content, please wait...
Loading content, please wait...
Loading content, please wait...
Loading content, please wait...
Loading content, please wait...
Loading content, please wait...
Loading content, please wait...
Loading content, please wait...
Loading content, please wait...
Loading content, please wait...