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 = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecStart = ''
|
||||
${pkgs.iproute2}/bin/ip link add veth-%i type veth peer name veth-ns-%i
|
||||
${pkgs.iproute2}/bin/ip link set veth-ns-%i netns %i
|
||||
${pkgs.iproute2}/bin/ip link set veth-%i up
|
||||
${pkgs.iproute2}/bin/ip netns exec %i ${pkgs.iproute2}/bin/ip link set veth-ns-%i up
|
||||
${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 netns exec %i ${pkgs.iproute2}/bin/ip route add default via 10.0.0.1
|
||||
'';
|
||||
ExecStart =
|
||||
let
|
||||
script = pkgs.writers.writeBash "veth-up" ''
|
||||
ns="$1"
|
||||
${pkgs.iproute2}/bin/ip link add veth-init-$ns type veth peer name veth-ns-$ns
|
||||
${pkgs.iproute2}/bin/ip link set veth-ns-$ns netns $ns
|
||||
${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";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.network.networks."50-veth" = {
|
||||
matchConfig.Name = "veth-*";
|
||||
matchConfig.Name = "veth-init-vpn";
|
||||
networkConfig = {
|
||||
Address = "10.0.0.1/24";
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue