From 07f2ce562e8840cd8b05d691268a3e40a9dbd17a Mon Sep 17 00:00:00 2001 From: Denozordec Date: Mon, 6 Apr 2026 13:32:23 +0700 Subject: [PATCH] feat: add strict bind configuration to BGP templates. Enhance BGP template rendering by including 'strict bind on' for both IPv4 and IPv6 templates, improving address binding behavior in Docker and bridge environments. --- internal/birdfmt/bgp.go | 3 +++ .../scenarios/standard_layout/bird.d/evobgp_bgp_template.conf | 2 ++ 2 files changed, 5 insertions(+) diff --git a/internal/birdfmt/bgp.go b/internal/birdfmt/bgp.go index 42d3b08..3676973 100644 --- a/internal/birdfmt/bgp.go +++ b/internal/birdfmt/bgp.go @@ -43,6 +43,8 @@ func RenderBGPTemplates(opts BGPTemplatesOptions) (string, error) { b.WriteString(" };\n") b.WriteString(" hold time 90;\n") b.WriteString(" keepalive time 30;\n") + // Жёсткая привязка к source address (см. пир): полезно в Docker / bridge, иначе listen может уйти на 0.0.0.0. + b.WriteString(" strict bind on;\n") b.WriteString("}\n\n") fmt.Fprintf(&b, "template bgp %s {\n", BGPTemplateNameV6) fmt.Fprintf(&b, " local as %d;\n", opts.LocalASN) @@ -54,6 +56,7 @@ func RenderBGPTemplates(opts BGPTemplatesOptions) (string, error) { b.WriteString(" };\n") b.WriteString(" hold time 90;\n") b.WriteString(" keepalive time 30;\n") + b.WriteString(" strict bind on;\n") b.WriteString("}\n") return b.String(), nil } diff --git a/internal/birdfmt/testdata/scenarios/standard_layout/bird.d/evobgp_bgp_template.conf b/internal/birdfmt/testdata/scenarios/standard_layout/bird.d/evobgp_bgp_template.conf index 72f51e9..1ecc5fa 100644 --- a/internal/birdfmt/testdata/scenarios/standard_layout/bird.d/evobgp_bgp_template.conf +++ b/internal/birdfmt/testdata/scenarios/standard_layout/bird.d/evobgp_bgp_template.conf @@ -6,6 +6,7 @@ template bgp bgp_template { }; hold time 90; keepalive time 30; + strict bind on; } template bgp bgp_template_v6 { @@ -16,4 +17,5 @@ template bgp bgp_template_v6 { }; hold time 90; keepalive time 30; + strict bind on; }