1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-25 07:00:43 +00:00

* Allow a netmask to be specified for each interface.

svn path=/nixos/trunk/; revision=8099
This commit is contained in:
Eelco Dolstra 2007-02-28 14:19:20 +00:00
parent 36d4802ea6
commit 935042365c
2 changed files with 9 additions and 2 deletions

View file

@ -203,7 +203,7 @@
example = [ example = [
{ name = "eth0"; { name = "eth0";
ipAddress = "131.211.84.78"; ipAddress = "131.211.84.78";
netmask = "255.255.255.128"; subnetMask = "255.255.255.128";
} }
]; ];
description = " description = "

View file

@ -8,6 +8,7 @@ let
# !!! use XML # !!! use XML
names = map (i: i.name) interfaces; names = map (i: i.name) interfaces;
ipAddresses = map (i: i.ipAddress) interfaces; ipAddresses = map (i: i.ipAddress) interfaces;
subnetMasks = map (i: if i ? subnetMask then i.subnetMask else "default") interfaces;
in in
@ -31,12 +32,18 @@ start script
# Configure the manually specified interfaces. # Configure the manually specified interfaces.
names=(${toString names}) names=(${toString names})
ipAddresses=(${toString ipAddresses}) ipAddresses=(${toString ipAddresses})
subnetMasks=(${toString subnetMasks})
for ((n = 0; n < \${#names[*]}; n++)); do for ((n = 0; n < \${#names[*]}; n++)); do
name=\${names[$n]} name=\${names[$n]}
ipAddress=\${ipAddresses[$n]} ipAddress=\${ipAddresses[$n]}
subnetMask=\${subnetMasks[$n]}
echo \"Configuring interface $name...\" 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 done
# Set the nameservers. # Set the nameservers.