@@ -122,24 +122,32 @@ let
122
122
123
123
# Set the default gateway.
124
124
${ optionalString ( cfg . defaultGateway != null && cfg . defaultGateway . address != "" ) ''
125
- # FIXME: get rid of "|| true" (necessary to make it idempotent).
126
- ip route add default ${ optionalString ( cfg . defaultGateway . metric != null )
125
+ ${ optionalString ( cfg . defaultGateway . interface != null ) ''
126
+ ip route replace ${ cfg . defaultGateway . address } dev ${ cfg . defaultGateway . interface } ${ optionalString ( cfg . defaultGateway . metric != null )
127
+ "metric ${ toString cfg . defaultGateway . metric } "
128
+ } proto static
129
+ '' }
130
+ ip route replace default ${ optionalString ( cfg . defaultGateway . metric != null )
127
131
"metric ${ toString cfg . defaultGateway . metric } "
128
132
} via "${ cfg . defaultGateway . address } " ${
129
133
optionalString ( cfg . defaultGatewayWindowSize != null )
130
134
"window ${ toString cfg . defaultGatewayWindowSize } " } ${
131
135
optionalString ( cfg . defaultGateway . interface != null )
132
- "dev ${ cfg . defaultGateway . interface } " } proto static || true
136
+ "dev ${ cfg . defaultGateway . interface } " } proto static
133
137
'' }
134
138
${ optionalString ( cfg . defaultGateway6 != null && cfg . defaultGateway6 . address != "" ) ''
135
- # FIXME: get rid of "|| true" (necessary to make it idempotent).
136
- ip -6 route add ::/0 ${ optionalString ( cfg . defaultGateway6 . metric != null )
139
+ ${ optionalString ( cfg . defaultGateway6 . interface != null ) ''
140
+ ip -6 route replace ${ cfg . defaultGateway6 . address } dev ${ cfg . defaultGateway6 . interface } ${ optionalString ( cfg . defaultGateway6 . metric != null )
141
+ "metric ${ toString cfg . defaultGateway6 . metric } "
142
+ } proto static
143
+ '' }
144
+ ip -6 route replace default ${ optionalString ( cfg . defaultGateway6 . metric != null )
137
145
"metric ${ toString cfg . defaultGateway6 . metric } "
138
146
} via "${ cfg . defaultGateway6 . address } " ${
139
147
optionalString ( cfg . defaultGatewayWindowSize != null )
140
148
"window ${ toString cfg . defaultGatewayWindowSize } " } ${
141
149
optionalString ( cfg . defaultGateway6 . interface != null )
142
- "dev ${ cfg . defaultGateway6 . interface } " } proto static || true
150
+ "dev ${ cfg . defaultGateway6 . interface } " } proto static
143
151
'' }
144
152
'' ;
145
153
} ;
0 commit comments