osrg / gobgp

BGP implemented in the Go Programming Language
https://osrg.github.io/gobgp/
Apache License 2.0
3.59k stars 684 forks source link

FRR(v6.02)+gobgp(v2.3.0) mpls vpn #2054

Open keyibo opened 5 years ago

keyibo commented 5 years ago

We build the following topology.

+----+          +----+            +------+            +----+             +-----+
| CE1 | ------- | PE1 |-----------| CORE |------------| PE2 |------------| CE2 |
+----+     |    +----+      |     +------+      |     +----+     |       +-----+  
           |                |                   |                |
 192.168.1.0/24        10.1.1.0/24         10.1.2.0/24       192.168.2.0/24                                                                   

CE1 has a loopback0: 1.1.1.1/32 PE1 has a loopback0: 2.2.2.2/32 CORE has a loopback0: 3.3.3.3/32 PE2 has a loopback0: 4.4.4.4/32 CE2 has a loopback0: 5.5.5.5/32

First, we use ospf(which is supported by FRR) to make PE1, CORE and PE2 interconnected. Second, on PE1, CORE and PE2 configure mpls. Third, on PE1 and PE2, we create VRF.

PE1 and PE2:

$sudo ip link add red type vrf table 1
$sudo ip route add table 1 unreachable default metric 4278198272
$sudo ip link set dev red up
$sudo ip link set dev eth0 master blue              // eth0 is a interface which is connected with CE
$sudo sysctl -w net.ipv4.tcp_l3mdev_accept=1
$sudo sysctl -w net.ipv4.udp_l3mdev_accept=1

At last, on CE1, PE1, CORE, PE2 and CE2, we use gobgp.(CORE is RR)

CE1:

[global.config]                                                     
    as=200
    router-id="1.1.1.1"
 [zebra]
    [zebra.config]
        enabled=true
        url="unix:/var/run/frr/zserv.api"
        version=6
[[neighbors]]
    [neighbors.config]
        neighbor-address="192.168.1.2"
        peer-as=100
    [neighbors.transport.config]
        local-address="192.168.1.1"
$gobgp glo rib add 1.1.1.1/32

PE1:

[global.config]
     as=100
     router-id=2.2.2.2
 [global.apply-policy.config]
     export-policy-list=["set"]
 [zebra]
     [zebra.config]
         enabled=true
         url="unix:/var/run/frr/zserv.api"
         version=6
         mpls-label-range-size=100
 [[neighbors]]
     [neighbors.config]
         neighbor-address="3.3.3.3"
     [neighbors.transport.config]
         local-address="2.2.2.2"
     [[neighbors.afi-safis]]
         [neighbors.afi-safis.config]
              afi-safi-name="l3vpn-ipv4-unicast"
 [[defined-sets.neighbor-sets]]
     neighbor-set-name="core"
     neighbor-info-list=["3.3.3.3"]
 [[policy-definitions]]
     name="set"
     [policy-definitions.statements.conditions.match-neighbor-set]
         neighbor-set="core"
     [policy-definitions.statements.actions.bgp-actions]
         set-next-hop="2.2.2.2"`
$gobgp vrf add red id 5 rd 100:1 rt both 100:1  //red is a VRF which has been created, and its id is 5
$gobgp nei add 192.168.1.1 as 200 vrf blue

CORE:

[global.config]
     as=100
     router-id="3.3.3.3"
 [[neighbors]]
    [neighbors.config]
        neighbor-address="2.2.2.2"
    [neighbors.transport.config]
        local-address="3.3.3.3"
    [neighbors.route-reflector.config]
        route-reflector-client=true
        route-reflector-cluster-id="3.3.3.3"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
             afi-safi-name="l3vpn-ipv4-unicast"
[[neighbors]]
    [neighbors.config]
        neighbor-address="4.4.4.4"
    [neighbors.transport.config]
        local-address="3.3.3.3"
    [neighbors.route-reflector.config]
        route-reflector-client=true
        route-reflector-cluster-id="3.3.3.3"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
             afi-safi-name="l3vpn-ipv4-unicast"

After configuration, there are some errors. The loopback0 of CE1 can't communicate with the loopback0 of CE2. But CE1 and CE2 have the route. And on PE1, its kernel routing table of vrf only has a route,"5.5.5.5/32". ON PE2, its kernel routing table of vrf only has a route,"1.1.1.1/32". How can i use FRR(v6.02) and gobgp(v2.3.0) to build mpls vpn?

irino commented 5 years ago

sudo ip link set dev eth0 master blue I assume you don't need to add eth0 to blue VRF. eth0 should belong to default VRF.

$gobgp vrf add red id 5 rd 100:1 rt both 100:1 //red is a VRF which has been created, and its id is 5 $gobgp nei add 192.168.1.1 as 200 vrf blue I assume you have to add neighbor with VRF red instead of blue.

DKCopy commented 5 years ago

gobgp can't allocate a label for vrf