Don't let interfaces get IPv6 addresses if networking.enableIPv6 is false

This commit is contained in:
Eelco Dolstra 2012-10-19 15:41:01 -04:00
parent ac8db6fd33
commit c8628e0293
2 changed files with 8 additions and 1 deletions

View File

@ -3,7 +3,9 @@
{config, pkgs, ...}: {config, pkgs, ...}:
with pkgs.lib; with pkgs.lib;
let let
cfg = config.networking; cfg = config.networking;
options = { options = {
@ -43,7 +45,9 @@ in
source = pkgs.writeText "hosts" source = pkgs.writeText "hosts"
'' ''
127.0.0.1 localhost 127.0.0.1 localhost
::1 localhost ${optionalString cfg.enableIPv6 ''
::1 localhost
''}
${cfg.extraHosts} ${cfg.extraHosts}
''; '';
target = "hosts"; target = "hosts";

View File

@ -278,6 +278,9 @@ in
'')} '')}
EOF EOF
# Disable or enable IPv6.
echo ${if cfg.enableIPv6 then "0" else "1"} > /proc/sys/net/ipv6/conf/all/disable_ipv6
# Set the default gateway. # Set the default gateway.
${optionalString (cfg.defaultGateway != "") '' ${optionalString (cfg.defaultGateway != "") ''
# FIXME: get rid of "|| true" (necessary to make it idempotent). # FIXME: get rid of "|| true" (necessary to make it idempotent).