Monday, May 29, 2023

Multi path routing with BGPD

Hello,

I try to setup multipath routing environment with OpenBSD's bgpd.
As I understand from man page the keyword is add-path.
Here is my environmental report:

1. In my lab I simulate two wan links for each device.
2. Each device also has a LAN network to announce.
3. In the middle of these two devices there is another OpenBSD acting as Router.

Device 1 :
WAN1 : 192.168.10.2/24
WAN2
: 10.1.1.2/24
LAN : 172.16.1.1/24
GRE1
: 172.31.1.1 -> 172.31.1.2 netmask /24 (over wan1)
GRE2 : 172.31.2.1 -> 172.31.2.2 netmask /24 (over wan2)

Device 2 :
WAN1 : 192.168.20.2/24
WAN2
: 10.1.2.2/24
LAN : 172.16.2.1/24
GRE1
: 172.31.1.2 -> 172.31.1.1 netmask /24 (over wan1)
GRE2 : 172.31.2.2 -> 172.31.2.1 netmask /24 (over wan2)


Router :
192.168.10.1/24
192.168.20.1/24
10.1.1.1/24
10.1.2.1/24

---------

Here bgpd.conf file contents :

Device1# cat /etc/bgpd.conf
AS 100
network 172.16.1.0/24
neighbor 172.31.1.2 {
      remote-as 100
      log updates
      announce IPv4 unicast
announce add-path recv yes
announce add-path send best
}
neighbor 172.31.2.2 {
      remote-as 100
      log updates
      announce IPv4 unicast
      announce add-path recv yes
      announce add-path send best
}
allow quick from { ibgp }
allow quick to { ibgp }

Device2# cat /etc/bgpd.conf
AS 100
network 172.16.2.0/24
neighbor 172.31.1.1 {
      remote-as 100
      log updates
      announce IPv4 unicast
announce add-path recv yes
announce add-path send best
}
neighbor 172.31.2.1 {
      remote-as 100
      log updates
      announce IPv4 unicast
announce add-path recv yes
announce add-path send best
}
allow quick from { ibgp }
allow quick to { ibgp }

Here bgpctl show outputs:

#bgp connection is OK

Device1# bgpctl show
Neighbor AS MsgRcvd MsgSent OutQ Up/Down State/PrfRcvd
172.31.1.2 100 9 9 0 00:02:34 1
172.31.2.2 100 9 9 0 00:02:34 1

# we can see rib tables are ready

Device1# bgpctl show rib
flags: * = Valid, > = Selected, I = via IBGP, A = Announced,
S = Stale, E = Error
origin validation state: N = not-found, V = valid, ! = invalid
origin: i = IGP, e = EGP, ? = Incomplete

flags ovs destination gateway lpref med aspath origin
AI*> N 172.16.1.0/24 0.0.0.0 100 0 i
I*> N 172.16.2.0/24 172.31.1.2 100 0 i
I*m N 172.16.2.0/24 172.31.2.2 100 0 i

Device2# bgpctl show rib
flags: * = Valid, > = Selected, I = via IBGP, A = Announced,
S = Stale, E = Error
origin validation state: N = not-found, V = valid, ! = invalid
origin: i = IGP, e = EGP, ? = Incomplete

flags ovs destination gateway lpref med aspath origin
I*> N 172.16.1.0/24 172.31.1.1 100 0 i
I*m N 172.16.1.0/24 172.31.2.1 100 0 i
AI*> N 172.16.2.0/24 0.0.0.0 100 0 i


But there is only one path in FIB table:

Device1# bgpctl show fib | grep B
flags: B = BGP, C = Connected, S = Static
N = BGP Nexthop reachable via this route
B 48 172.16.2.0/24 172.31.1.2

Device2# bgpctl show fib | grep B
flags: B = BGP, C = Connected, S = Static
N = BGP Nexthop reachable via this route
B 48 172.16.1.0/24 172.31.1.1

Also my sysctl.conf is ok (net.inet.ip.multipath=1)
I just wanna add multpath routes for my networks as dynamic.

It's ok with static routing(*) but I would like to achieve it as dynamically with bgpd.
What is wrong with my configuration? Can you please help me.
Thanks.

(*)
Device1# route add 172.16.2.0/24 172.31.1.2 -mpath
add net 172.16.2.0/24: gateway 172.31.1.2
Device1# route add 172.16.2.0/24 172.31.2.2 -mpath
add net 172.16.2.0/24: gateway 172.31.2.2
Device1# netstat -rnf inet | grep 172.16.2
172.16.2/24 172.31.1.2 UGSP 0 0 - 8 gre1
172.16.2/24 172.31.2.2 UGSP 0 0 - 8 gre2

Device2# route add 172.16.1.0/24 172.31.1.1 -mpath
add net 172.16.1.0/24: gateway 172.31.1.1
Device2# route add 172.16.1.0/24 172.31.2.1 -mpath
add net 172.16.1.0/24: gateway 172.31.2.1
Device2# netstat -rnf inet | grep 172.16.1
172.16.1/24 172.31.1.1 UGSP 0 0 - 8 gre1
172.16.1/24 172.31.2.1 UGSP 0 0 - 8 gre2

No comments:

Post a Comment