From c6e0edb73b97602550e43547bfa64f3bc9e6fe91 Mon Sep 17 00:00:00 2001 From: Eric Litak Date: Mon, 17 Oct 2016 22:50:48 -0700 Subject: [PATCH] eth1 stanza for private networking; fixes #7 --- nixos-infect | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/nixos-infect b/nixos-infect index 90a586d..4b7e7fd 100755 --- a/nixos-infect +++ b/nixos-infect @@ -78,8 +78,10 @@ EOF EOF local IFS=$'\n' - ip4s=($(ip address show dev eth0 | grep 'inet ' | sed -r 's|.*inet ([0-9.]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|')) - ip6s=($(ip address show dev eth0 | grep 'inet6 .*global' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|')) + eth0_ip4s=($(ip address show dev eth0 | grep 'inet ' | sed -r 's|.*inet ([0-9.]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|')) + eth0_ip6s=($(ip address show dev eth0 | grep 'inet6 .*global' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|')) + eth1_ip4s=($(ip address show dev eth1 | grep 'inet ' | sed -r 's|.*inet ([0-9.]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|')) + eth1_ip6s=($(ip address show dev eth1 | grep 'inet6 .*global' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|')) gateway=($(ip route show dev eth0 | grep default | sed -r 's|default via ([0-9.]+).*|\1|')) gateway6=($(ip -6 route show dev eth0 | grep default | sed -r 's|default via ([0-9a-f:]+).*|\1|')) ether0=($(ip address show dev eth0 | grep link/ether | sed -r 's|.*link/ether ([0-9a-f:]+) .*|\1|')) @@ -98,15 +100,21 @@ EOF defaultGateway6 = "${gateway6}"; interfaces = { eth0 = { - ip4 = [$(for a in ${ip4s[@]}; do echo -n " + ip4 = [$(for a in ${eth0_ip4s[@]}; do echo -n " $a"; done) ]; - ip6 = [$(for a in ${ip6s[@]}; do echo -n " + ip6 = [$(for a in ${eth1_ip6s[@]}; do echo -n " + $a"; done) + ]; + }; + eth1 = { + ip4 = [$(for a in ${eth1_ip4s[@]}; do echo -n " + $a"; done) + ]; + ip6 = [$(for a in ${eth1_ip6s[@]}; do echo -n " $a"; done) ]; }; - # eth1 is for private networking or something? - eth1.useDHCP = false; }; }; services.udev.extraRules = ''