nixos/nixos-container: Always apply extraVeth ip configuration
Fixes that `containers.<name>.extraVeths.<name>` configuration was not
always applied.
When configuring `containers.<name>.extraVeths.<name>` and not
configuring one of `containers.<name>.localAddress`, `.localAddress6`,
`.hostAddress`, `.hostAddress6` or `.hostBridge` the veth was created,
but otherwise no configuration (i.e. no ip) was applied.
nixos-container always configures the primary veth (when `.localAddress`
or `.hostAddress` is set) to be the containers default gateway, so
this fix is required to create a veth in containers that use a different
default gateway.
To test this patch configure the following container and check if the
addresses are applied:
```
containers.testveth = {
extraVeths.testveth = {
hostAddress = "192.168.13.2";
localAddress = "192.168.13.1";
};
config = {...}:{};
};
```
This commit is contained in:
@@ -56,9 +56,9 @@ let
|
|||||||
ip -6 route add $HOST_ADDRESS6 dev eth0
|
ip -6 route add $HOST_ADDRESS6 dev eth0
|
||||||
ip -6 route add default via $HOST_ADDRESS6
|
ip -6 route add default via $HOST_ADDRESS6
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
${concatStringsSep "\n" (mapAttrsToList renderExtraVeth cfg.extraVeths)}
|
${concatStringsSep "\n" (mapAttrsToList renderExtraVeth cfg.extraVeths)}
|
||||||
fi
|
|
||||||
|
|
||||||
# Start the regular stage 1 script.
|
# Start the regular stage 1 script.
|
||||||
exec "$1"
|
exec "$1"
|
||||||
@@ -223,8 +223,8 @@ let
|
|||||||
${ipcall cfg "ip route" "$LOCAL_ADDRESS" "localAddress"}
|
${ipcall cfg "ip route" "$LOCAL_ADDRESS" "localAddress"}
|
||||||
${ipcall cfg "ip -6 route" "$LOCAL_ADDRESS6" "localAddress6"}
|
${ipcall cfg "ip -6 route" "$LOCAL_ADDRESS6" "localAddress6"}
|
||||||
fi
|
fi
|
||||||
${concatStringsSep "\n" (mapAttrsToList renderExtraVeth cfg.extraVeths)}
|
|
||||||
fi
|
fi
|
||||||
|
${concatStringsSep "\n" (mapAttrsToList renderExtraVeth cfg.extraVeths)}
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user