From 935042365cfeca3781842f76836fdb12fb2a35e1 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 28 Feb 2007 14:19:20 +0000 Subject: [PATCH] * Allow a netmask to be specified for each interface. svn path=/nixos/trunk/; revision=8099 --- system/options.nix | 2 +- upstart-jobs/network-interfaces.nix | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/system/options.nix b/system/options.nix index 8bfe656c5dc1..95345faf47cd 100644 --- a/system/options.nix +++ b/system/options.nix @@ -203,7 +203,7 @@ example = [ { name = "eth0"; ipAddress = "131.211.84.78"; - netmask = "255.255.255.128"; + subnetMask = "255.255.255.128"; } ]; description = " diff --git a/upstart-jobs/network-interfaces.nix b/upstart-jobs/network-interfaces.nix index 7ed68d7a7b2f..5e85401422c0 100644 --- a/upstart-jobs/network-interfaces.nix +++ b/upstart-jobs/network-interfaces.nix @@ -8,6 +8,7 @@ let # !!! use XML names = map (i: i.name) interfaces; ipAddresses = map (i: i.ipAddress) interfaces; + subnetMasks = map (i: if i ? subnetMask then i.subnetMask else "default") interfaces; in @@ -31,12 +32,18 @@ start script # Configure the manually specified interfaces. names=(${toString names}) ipAddresses=(${toString ipAddresses}) + subnetMasks=(${toString subnetMasks}) for ((n = 0; n < \${#names[*]}; n++)); do name=\${names[$n]} ipAddress=\${ipAddresses[$n]} + subnetMask=\${subnetMasks[$n]} echo \"Configuring interface $name...\" - ${nettools}/sbin/ifconfig \"$name\" \"$ipAddress\" || true + extraFlags= + if test \"$subnetMask\" != default; then + extraFlags=\"$extraFlags netmask $subnetMask\" + fi + ${nettools}/sbin/ifconfig \"$name\" \"$ipAddress\" $extraFlags || true done # Set the nameservers.