Tinc: Difference between revisions
imported>Makefu pre -> syntaxHighlight |
imported>Aforemny m Add missing quotes around `address`'s value |
||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 68: | Line 68: | ||
<syntaxHighlight lang=nix># for heinz | <syntaxHighlight lang=nix># for heinz | ||
networking.interfaces."tinc. | networking.interfaces."tinc.${networkName}".ipv4.addresses = [ { address = "10.1.1.25"; prefixLength = 24; } ]; | ||
</syntaxHighlight> | </syntaxHighlight> | ||
| Line 74: | Line 74: | ||
The following snippet '''seems''' to fix that (until perhaps a more proper fix is upstreamed?): | The following snippet '''seems''' to fix that (until perhaps a more proper fix is upstreamed?): | ||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
systemd.services."network-addresses-tinc.${networkName}". | # Start the unit for adding addresses if Tinc is started | ||
systemd.services."network- | systemd.services."tinc.${networkName}".wants = [ "network-addresses-tinc.${networkName}.service" ]; | ||
# Stop the unit for adding addresses if Tinc is stopped or restarted | |||
systemd.services."network-addresses-tinc.${networkName}".partOf = [ "tinc.${networkName}.service" ]; | |||
# Start the unit for adding addresses after the Tinc device is added | |||
systemd.services."network-addresses-tinc.${networkName}".after = [ "sys-subsystem-net-devices-tinc.${networkName}.device" ]; | |||
</syntaxHighlight> | </syntaxHighlight> | ||
=== tinc-up/tinc-down === | === tinc-up/tinc-down === | ||
| Line 86: | Line 89: | ||
<syntaxHighlight lang=nix># for heinz | <syntaxHighlight lang=nix># for heinz | ||
environment.etc | environment.etc = { | ||
"tinc/private/tinc-up".source = pkgs.writeScript "tinc-up-private" '' | |||
#!${pkgs.stdenv.shell} | |||
''; | ${pkgs.nettools}/bin/ifconfig $INTERFACE 10.1.1.25 netmask 255.255.255.0 | ||
''; | |||
"tinc/private/tinc-down".source = pkgs.writeScript "tinc-down-private" '' | |||
#!${pkgs.stdenv.shell} | |||
'';</syntaxHighlight> | /run/wrappers/bin/sudo ${pkgs.nettools}/bin/ifconfig $INTERFACE down | ||
''; | |||
};</syntaxHighlight> | |||
For the <code>tinc-down</code> we need to use sudo, because the user <code>tinc.private</code> who starts the service is not able to tear down the interface. | For the <code>tinc-down</code> we need to use sudo, because the user <code>tinc.private</code> who starts the service is not able to tear down the interface. | ||