mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 13:57:10 +03:00
network-interfaces: device routes for default gateway
Iff interface is set, it makes sense to add device route by default.
This commit is contained in:
parent
0a6fca15fd
commit
d0435ba032
@ -122,24 +122,32 @@ let
|
|||||||
|
|
||||||
# Set the default gateway.
|
# Set the default gateway.
|
||||||
${optionalString (cfg.defaultGateway != null && cfg.defaultGateway.address != "") ''
|
${optionalString (cfg.defaultGateway != null && cfg.defaultGateway.address != "") ''
|
||||||
# FIXME: get rid of "|| true" (necessary to make it idempotent).
|
${optionalString (cfg.defaultGateway.interface != null) ''
|
||||||
ip route add default ${optionalString (cfg.defaultGateway.metric != null)
|
ip route replace ${cfg.defaultGateway.address} dev ${cfg.defaultGateway.interface} ${optionalString (cfg.defaultGateway.metric != null)
|
||||||
|
"metric ${toString cfg.defaultGateway.metric}"
|
||||||
|
} proto static
|
||||||
|
''}
|
||||||
|
ip route replace default ${optionalString (cfg.defaultGateway.metric != null)
|
||||||
"metric ${toString cfg.defaultGateway.metric}"
|
"metric ${toString cfg.defaultGateway.metric}"
|
||||||
} via "${cfg.defaultGateway.address}" ${
|
} via "${cfg.defaultGateway.address}" ${
|
||||||
optionalString (cfg.defaultGatewayWindowSize != null)
|
optionalString (cfg.defaultGatewayWindowSize != null)
|
||||||
"window ${toString cfg.defaultGatewayWindowSize}"} ${
|
"window ${toString cfg.defaultGatewayWindowSize}"} ${
|
||||||
optionalString (cfg.defaultGateway.interface != null)
|
optionalString (cfg.defaultGateway.interface != null)
|
||||||
"dev ${cfg.defaultGateway.interface}"} proto static || true
|
"dev ${cfg.defaultGateway.interface}"} proto static
|
||||||
''}
|
''}
|
||||||
${optionalString (cfg.defaultGateway6 != null && cfg.defaultGateway6.address != "") ''
|
${optionalString (cfg.defaultGateway6 != null && cfg.defaultGateway6.address != "") ''
|
||||||
# FIXME: get rid of "|| true" (necessary to make it idempotent).
|
${optionalString (cfg.defaultGateway6.interface != null) ''
|
||||||
ip -6 route add ::/0 ${optionalString (cfg.defaultGateway6.metric != null)
|
ip -6 route replace ${cfg.defaultGateway6.address} dev ${cfg.defaultGateway6.interface} ${optionalString (cfg.defaultGateway6.metric != null)
|
||||||
|
"metric ${toString cfg.defaultGateway6.metric}"
|
||||||
|
} proto static
|
||||||
|
''}
|
||||||
|
ip -6 route replace default ${optionalString (cfg.defaultGateway6.metric != null)
|
||||||
"metric ${toString cfg.defaultGateway6.metric}"
|
"metric ${toString cfg.defaultGateway6.metric}"
|
||||||
} via "${cfg.defaultGateway6.address}" ${
|
} via "${cfg.defaultGateway6.address}" ${
|
||||||
optionalString (cfg.defaultGatewayWindowSize != null)
|
optionalString (cfg.defaultGatewayWindowSize != null)
|
||||||
"window ${toString cfg.defaultGatewayWindowSize}"} ${
|
"window ${toString cfg.defaultGatewayWindowSize}"} ${
|
||||||
optionalString (cfg.defaultGateway6.interface != null)
|
optionalString (cfg.defaultGateway6.interface != null)
|
||||||
"dev ${cfg.defaultGateway6.interface}"} proto static || true
|
"dev ${cfg.defaultGateway6.interface}"} proto static
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user