Skip to content

Commit cc8b3cc

Browse files
committed
Add config option for local_cidr control
1 parent f346cf4 commit cc8b3cc

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

examples/config.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,13 @@ firewall:
309309
outbound_action: drop
310310
inbound_action: drop
311311

312+
# Controls the default value for local_cidr. Default is true, will be deprecated after v1.9 and defaulted to false.
313+
# This setting only affects nebula hosts with subnets encoded in their certificate. A nebula host acting as an
314+
# unsafe router with `default_local_cidr_any: true` will expose their unsafe routes to every inbound rule regardless
315+
# of the actual destination for the packet. Setting this to false requires each inbound rule to contain a `local_cidr`
316+
# if the intention is to allow traffic to flow to an unsafe route.
317+
#default_local_cidr_any: false
318+
312319
conntrack:
313320
tcp_timeout: 12m
314321
udp_timeout: 3m
@@ -325,7 +332,8 @@ firewall:
325332
# groups: Same as group but accepts a list of values. Multiple values are AND'd together and a certificate would have to contain all groups to pass
326333
# cidr: a remote CIDR, `0.0.0.0/0` is any.
327334
# local_cidr: a local CIDR, `0.0.0.0/0` is any. This could be used to filter destinations when using unsafe_routes.
328-
# Default is `any` unless the certificate contains subnets and then the default is the ip issued in the certificate.
335+
# Default is `any` unless the certificate contains subnets and then the default is the ip issued in the certificate
336+
# if `default_local_cidr_any` is false, otherwise its `any`.
329337
# ca_name: An issuing CA name
330338
# ca_sha: An issuing CA shasum
331339

firewall.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ type Firewall struct {
6565
rules string
6666
rulesVersion uint16
6767

68-
trackTCPRTT bool
69-
metricTCPRTT metrics.Histogram
70-
incomingMetrics firewallMetrics
71-
outgoingMetrics firewallMetrics
68+
defaultLocalCIDRAny bool
69+
trackTCPRTT bool
70+
metricTCPRTT metrics.Histogram
71+
incomingMetrics firewallMetrics
72+
outgoingMetrics firewallMetrics
7273

7374
l *logrus.Logger
7475
}
@@ -206,6 +207,9 @@ func NewFirewallFromConfig(l *logrus.Logger, nc *cert.NebulaCertificate, c *conf
206207
//TODO: max_connections
207208
)
208209

210+
//TODO: Flip to false after v1.9 release
211+
fw.defaultLocalCIDRAny = c.GetBool("firewall.default_local_cidr_any", true)
212+
209213
inboundAction := c.GetString("firewall.inbound_action", "drop")
210214
switch inboundAction {
211215
case "reject":
@@ -873,10 +877,11 @@ func (fr *FirewallRule) match(p firewall.Packet, c *cert.NebulaCertificate) bool
873877

874878
func (flc *firewallLocalCIDR) addRule(f *Firewall, localIp *net.IPNet) error {
875879
if localIp == nil || (localIp != nil && localIp.Contains(net.IPv4(0, 0, 0, 0))) {
876-
if !f.hasSubnets {
880+
if !f.hasSubnets || f.defaultLocalCIDRAny {
877881
flc.Any = true
878882
return nil
879883
}
884+
880885
localIp = f.assignedCIDR
881886
}
882887

0 commit comments

Comments
 (0)