fix: veth setup
Signed-off-by: Lander Van den Bulcke <landervandenbulcke@gmail.com>
This commit is contained in:
parent
ded73650a9
commit
1f846cae56
1 changed files with 13 additions and 9 deletions
|
|
@ -54,20 +54,24 @@
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
ExecStart = ''
|
ExecStart =
|
||||||
${pkgs.iproute2}/bin/ip link add veth-%i type veth peer name veth-ns-%i
|
let
|
||||||
${pkgs.iproute2}/bin/ip link set veth-ns-%i netns %i
|
script = pkgs.writers.writeBash "veth-up" ''
|
||||||
${pkgs.iproute2}/bin/ip link set veth-%i up
|
ns="$1"
|
||||||
${pkgs.iproute2}/bin/ip netns exec %i ${pkgs.iproute2}/bin/ip link set veth-ns-%i up
|
${pkgs.iproute2}/bin/ip link add veth-init-$ns type veth peer name veth-ns-$ns
|
||||||
${pkgs.iproute2}/bin/ip netns exec %i ${pkgs.iproute2}/bin/ip addr add 10.0.0.2/24 dev veth-ns-%i
|
${pkgs.iproute2}/bin/ip link set veth-ns-$ns netns $ns
|
||||||
${pkgs.iproute2}/bin/ip netns exec %i ${pkgs.iproute2}/bin/ip route add default via 10.0.0.1
|
${pkgs.iproute2}/bin/ip link set veth-init-$ns up
|
||||||
'';
|
${pkgs.iproute2}/bin/ip netns exec $ns ${pkgs.iproute2}/bin/ip link set veth-ns-$ns up
|
||||||
|
${pkgs.iproute2}/bin/ip netns exec $ns ${pkgs.iproute2}/bin/ip addr add 10.0.0.2/24 dev veth-ns-$ns
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
"${script} %i";
|
||||||
ExecStop = "${pkgs.iproute2}/bin/ip link del veth-%i";
|
ExecStop = "${pkgs.iproute2}/bin/ip link del veth-%i";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.network.networks."50-veth" = {
|
systemd.network.networks."50-veth" = {
|
||||||
matchConfig.Name = "veth-*";
|
matchConfig.Name = "veth-init-vpn";
|
||||||
networkConfig = {
|
networkConfig = {
|
||||||
Address = "10.0.0.1/24";
|
Address = "10.0.0.1/24";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue