Compare commits

..

No commits in common. "9784736260c8300d5d63b3f77a4690904b2cc5c0" and "40e80df84aebe62f197840725597f1fe6e225c78" have entirely different histories.

2 changed files with 3 additions and 15 deletions

View file

@ -50,18 +50,11 @@ with scriptsNFiles;
# proxmox makes it very hard to manually add interfaces directly on /etc/network/interfaces while the pve services are not running # proxmox makes it very hard to manually add interfaces directly on /etc/network/interfaces while the pve services are not running
# it also doesn't pick up files in interfaces.d # it also doesn't pick up files in interfaces.d
# so manually do that via service after boot # so manually do that via service after boot
# After= must live in [Unit] — in [Service] systemd ignores it, leaving the
# merge/ifreload racing networking.service (and ifreload fails outright if it
# runs before /run/network exists, see ifupdown2#276).
mergeNetIfacesDService = pkgs.writeText "manual-net-ifaces.d.service" '' mergeNetIfacesDService = pkgs.writeText "manual-net-ifaces.d.service" ''
[Unit]
After = networking.service
Wants = networking.service
[Service] [Service]
Type = oneshot Type = oneshot
ExecStartPre = /bin/mkdir -p /run/network
ExecStart = /bin/bash -c "cat /etc/network/interfaces.d/* >> /etc/network/interfaces; rm /etc/network/interfaces.d/*; ifreload -a;" ExecStart = /bin/bash -c "cat /etc/network/interfaces.d/* >> /etc/network/interfaces; rm /etc/network/interfaces.d/*; ifreload -a;"
After = network.target
[Install] [Install]
WantedBy = multi-user.target WantedBy = multi-user.target

View file

@ -172,10 +172,6 @@ let
let let
wanCfg = cfg // { spaceName = spaceName; }; wanCfg = cfg // { spaceName = spaceName; };
vethInNSToHost.iface = "vhost"; vethInNSToHost.iface = "vhost";
# Temporary peer name, unique per namespace. The peer briefly exists in the
# host namespace before being moved; a shared name ("vhost") lets parallel
# wan.net.vmix@* starts steal each other's peer ends, cross-wiring namespaces.
vethInNSToHost.tempIface = "vh-${wanCfg.spaceName}";
vethOnHostToNS.iface = "vn-${wanCfg.spaceName}"; vethOnHostToNS.iface = "vn-${wanCfg.spaceName}";
vethOnHostToNS.ipv4.address = calc.cidr.host 1 wanCfg.ipv4.range; vethOnHostToNS.ipv4.address = calc.cidr.host 1 wanCfg.ipv4.range;
vethInNSToHost.ipv4.address = calc.cidr.host 2 wanCfg.ipv4.range; vethInNSToHost.ipv4.address = calc.cidr.host 2 wanCfg.ipv4.range;
@ -184,9 +180,8 @@ let
portForwardRules = lib.concatStringsSep "\n" (lib.mapAttrsToList (hostIPnPort: nsPort: "iptables -t nat -A PREROUTING -p tcp --dport ${hostIPnPort} -j DNAT --to-destination ${vethInNSToHost.ipv4.address}:${toString nsPort}") wanCfg.forwardPorts); portForwardRules = lib.concatStringsSep "\n" (lib.mapAttrsToList (hostIPnPort: nsPort: "iptables -t nat -A PREROUTING -p tcp --dport ${hostIPnPort} -j DNAT --to-destination ${vethInNSToHost.ipv4.address}:${toString nsPort}") wanCfg.forwardPorts);
createWanCommands = '' createWanCommands = ''
ip link add ${vethOnHostToNS.iface} type veth peer name ${vethInNSToHost.tempIface} ip link add ${vethOnHostToNS.iface} type veth peer name ${vethInNSToHost.iface}
ip link set ${vethInNSToHost.tempIface} netns ${wanCfg.spaceName}.vmix ip link set ${vethInNSToHost.iface} netns ${wanCfg.spaceName}.vmix
ip netns exec ${wanCfg.spaceName}.vmix ip link set ${vethInNSToHost.tempIface} name ${vethInNSToHost.iface}
ip address add ${vethOnHostToNS.ipv4.address}/${networkPrefix} dev ${vethOnHostToNS.iface} ip address add ${vethOnHostToNS.ipv4.address}/${networkPrefix} dev ${vethOnHostToNS.iface}
ip netns exec ${wanCfg.spaceName}.vmix ip address add ${vethInNSToHost.ipv4.address}/${networkPrefix} dev ${vethInNSToHost.iface} ip netns exec ${wanCfg.spaceName}.vmix ip address add ${vethInNSToHost.ipv4.address}/${networkPrefix} dev ${vethInNSToHost.iface}