Ability to run multiple instances of Ygg router at the same machine #1295
-
|
Hi there! I would like to run multiple instances of Yggdrasil router at the same machine (at the same time). You may wonder: why ever do so? Well, because with Yggdrasil it is so easy to build some overlay network and connect multiple machines that should all have direct connectivity to each other that it is worth creating as many Yggdrasil networks as one could imagine! Particular for my case, I have one instance that joins needed machines to they own private segment, and another instance that is connected to global network and provides others to reach it. I've managed to start multiple instances with this modification to systemd unit: # cp -v /usr/lib/systemd/system/yggdrasil.service /etc/systemd/system/yggdrasil@.service--- /usr/lib/systemd/system/yggdrasil.service 2023-10-27 21:20:44.000000000 +0300
+++ /etc/systemd/system/yggdrasil@.service 2025-11-02 22:41:03.850134670 +0300
@@ -1,5 +1,5 @@
[Unit]
-Description=yggdrasil
+Description=Yggdrasil router on %i interface
Wants=network-online.target
After=network-online.target
@@ -11,11 +11,11 @@
NoNewPrivileges=true
RuntimeDirectory=yggdrasil
ReadWritePaths=/var/run/yggdrasil /run/yggdrasil
-SyslogIdentifier=yggdrasil
+SyslogIdentifier=yggdrasil-%i
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
ExecStartPre=+-/sbin/modprobe tun
-ExecStart=/usr/sbin/yggdrasil -useconffile /etc/yggdrasil/yggdrasil.conf
+ExecStart=/usr/sbin/yggdrasil -useconffile %E/%p/%i.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
TimeoutStopSec=5The idea is barely as simple as:
That is, if one start a Next issue was that both instances will compete for admin socket ( And it works! The next issue is that now we have two entries in routing table (routes for LL address are skipped): $ ip -6 route show match 200::/7
200::/7 dev ygg0 proto kernel metric 256 pref medium
200::/7 dev ygg42 proto kernel metric 256 pref mediumAgain, in my configuration, one instance ( Unfortunately, depending on whatever, I don't know for sure, may be start order of services, one route "beats" another resulting in packets going to wrong network segment. Is there a way to prevent Another issue is that when any of multiple services going to be stopped, it removes |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
You can run as many instances as you want, but you can only run one instance with TUN enabled in a given network namespace if you want anything to work right. As you pointed out there are multiple routing table entries that will conflict.
In this case, set
I don't think we ever envisaged that more than one systemd unit would be running precisely because of the fact that multiple TUN interfaces will conflict and most people wouldn't ever figure out how to work around that. |
Beta Was this translation helpful? Give feedback.
You can run as many instances as you want, but you can only run one instance with TUN enabled in a given network namespace if you want anything to work right. As you pointed out there are multiple routing table entries that will conflict.
In this case, set
IfName: noneto disable TUN and that instance will not conflict with others.I don't think we ever envisaged that more than one systemd unit would …