通信系が好きな社会人

blogというかmemo

GoBGPでBGPフルルートmrt injectionでnext-hop-self & set ip next-hopする方法

GoBGPで①next-hop-self , ②set ip next-hopを実現する方法。

構成図

f:id:uchy_13a:20220311165441p:plain

フルルートのinject

 gobgp mrt inject global rib.20220311.0600

①GoBGPでnext-hop-self(next-hop: 192.168.100.60)

[global.config]
  as = 65000
  router-id = "192.168.100.60"
 [global.apply-policy.config]
   export-policy-list = ["next-hop-self"]


[[neighbors]]
 [neighbors.config]
   peer-type = "external"
   neighbor-address = "192.168.100.61"
   peer-as = 65001

[[neighbors]]
 [neighbors.config]
   peer-type = "external"
   neighbor-address = "192.168.100.62"
   peer-as = 65002

[[neighbors]]
 [neighbors.config]
   peer-type = "external"
   neighbor-address = "fd00:192:168:100::61"
   peer-as = 65001

[[neighbors]]
 [neighbors.config]
   peer-type = "external"
   neighbor-address = "fd00:192:168:100::62"
   peer-as = 65002

[[policy-definitions]]
  name = "next-hop-self"
  [[policy-definitions.statements]]
    name = "statement1"
    [policy-definitions.statements.actions.bgp-actions]
      set-next-hop = "self"

②GoBGPでset ip next-hop(next-hop: 192.168.100.1)

[global.config]
  as = 65000
  router-id = "192.168.100.60"
 [global.apply-policy.config]
   export-policy-list = ["set-ip-nexthop-v4","set-ip-nexthop-v6"]

[[neighbors]]
 [neighbors.config]
   peer-type = "external"
   neighbor-address = "192.168.100.61"
   peer-as = 65001

[[neighbors]]
 [neighbors.config]
   peer-type = "external"
   neighbor-address = "192.168.100.62"
   peer-as = 65002

[[neighbors]]
 [neighbors.config]
   peer-type = "external"
   neighbor-address = "fd00:192:168:100::61"
   peer-as = 65001

[[neighbors]]
 [neighbors.config]
   peer-type = "external"
   neighbor-address = "fd00:192:168:100::62"
   peer-as = 65002

[[defined-sets.neighbor-sets]]
  neighbor-set-name = "ns-ipv4"
  neighbor-info-list = ["192.168.100.61","192.168.100.62"]

[[defined-sets.neighbor-sets]]
  neighbor-set-name = "ns-ipv6"
  neighbor-info-list = ["fd00:192:168:100::61","fd00:192:168:100::62"]

[[policy-definitions]]
  name = "set-ip-nexthop-v4"
  [[policy-definitions.statements]]
    name = "v4-statement1"
      [policy-definitions.statements.conditions.match-neighbor-set]
        neighbor-set = "ns-ipv4"
        match-set-options = "any"
      [policy-definitions.statements.actions.bgp-actions]
        set-next-hop = "192.168.100.1"

[[policy-definitions]]
  name = "set-ip-nexthop-v6"
  [[policy-definitions.statements]]
    name = "v6-statement1"
      [policy-definitions.statements.conditions.match-neighbor-set]
        neighbor-set = "ns-ipv6"
        match-set-options = "any"
      [policy-definitions.statements.actions.bgp-actions]
        set-next-hop = "fd00:192:168:100::1"

FRR1側のIPv4出力(set ip next-hop)

frr1(config-router-af)# do show ip bgp neighbors 192.168.100.60 received
   Network          Next Hop            Metric LocPrf Weight Path
*> 1.0.0.0/24       192.168.100.1                          0 65000 6939 13335 i
*> 1.0.4.0/22       192.168.100.1                          0 65000 6939 4826 38803 i
*> 1.0.4.0/24       192.168.100.1                          0 65000 6939 4826 38803 i

FRR1側のIPv6出力(set ip next-hop)

frr1(config-router-af)# do show bgp neighbors fd00:192:168:100::60 received-routes 

   Network          Next Hop            Metric LocPrf Weight Path
*> 2001::/32        fd00:192:168:100::1
                                                           0 65000 6939 i
*> 2001:4:112::/48  fd00:192:168:100::1
                                             0             0 65000 6939 112 i
*> 2001:200::/32    fd00:192:168:100::1
                                                           0 65000 6939 2914 2500 2500 i
*> 2001:200:900::/40
                    fd00:192:168:100::1
                                                           0 65000 6939 2516 7660 7660 7660 i