* 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 = [
{ name = "eth0";
ipAddress = "131.211.84.78";
netmask = "255.255.255.128";
subnetMask = "255.255.255.128";
}
];
description = "

View File

@ -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.