# Issue with static/connected route redistribution into OpenBGP



## janakktrivedi (Jun 9, 2022)

Hi, 
I am running FreeBSD 13.0 with OpenBGPD software 5.2.20121209_4. 
I am facing issue with static/connected route redistribution into BGP.
Here is the scenario:
FreeBSD firewall cluster is learning route from BGP peers from global routing table where route is learning from other site.
I am adding same route locally in Firewalls to advertise it locally, but BGP is not installing this static route in route table, although static routes should be prefered over BGP due to low AD value. bgpctl reload did not help too. But as soon as I restart the BGPD process(server openbgpd restart), static route works as expected.
In general, I want to announce same network/IP from multiple location to load balance the traffic towards nearest location.
Here is some of the statistics from the route table:

```
bgpctl show rib detail x.x.x.x

BGP routing table entry for x.x.x.x/32
    65003 65220
    Nexthop x.x.x.x (via y.y.y.y) from xxxx (y.y.y.y)
    Origin incomplete, metric 100, localpref 100, weight 0, internal, valid, best
    Last update: 00:48:59 ago
    Originator Id: y.y.y.y.y
    Cluster ID List: y.y.y.y
```
But if we check with netstat command, static route is visible there with lower preference:

```
netstat -rn | grep x.x.x.x
x.x.x.x      y.y.y.y     UGH1    vlan133     <<<<<<<<<<<<<<< This route is being learn from BGP upstream peers
x.x.x.x      z.z.z.z         UGHS    vlan133  <<<<<<<<<<<<<<< This route is static added locally in firewalls.
```
I would like to know if this is expected behaviour in FreeBSD openbgpd or is there any bug in it. Btw, the same routing behavour works fine in OpenBSD openbgpd since almost 10 years without any issues.

Any help would be much appreciated.

Thanks
Janak


----------



## VladiBG (Jun 9, 2022)

I would avoid using static routes at all. Anyway you can change the static route weight like this
route add x.x.x.x/24 y.y.y.y.y -weight 100
route get x.x.x.x/24


----------



## janakktrivedi (Jun 9, 2022)

Thanks for the inputs, however it did not help. Still BGP don't see that static route.

```
# route add 10.68.189.201/32 10.96.124.134
add net 10.68.189.201: gateway 10.96.124.134

# netstat -rn | grep 10.68.189.201
10.68.189.201      10.240.103.177     UGH1    vlan133
10.68.189.201      10.96.124.134      UGHS    vlan136


# bgpctl show rib 10.68.189.201
flags: * = Valid, > = Selected, I = via IBGP, A = Announced, S = Stale
origin: i = IGP, e = EGP, ? = Incomplete

flags destination          gateway          lpref   med aspath origin
I*>   10.68.189.201/32     10.240.103.177     100   100 65003 65220 ?
I*    10.68.189.201/32     10.240.103.178     100   127 65003 65220 ?
```


----------



## janakktrivedi (Jun 9, 2022)

As soon as I restart BGPD service, we can see the static route.

```
# bgpctl show rib 10.68.189.201
flags: * = Valid, > = Selected, I = via IBGP, A = Announced, S = Stale
origin: i = IGP, e = EGP, ? = Incomplete

flags destination          gateway          lpref   med aspath origin
AI*>  10.68.189.201/32     0.0.0.0            100     0 i
I*    10.68.189.201/32     10.240.103.177     100   100 65003 65220 ?
I*    10.68.189.201/32     10.240.103.178     100   127 65003 65220 ?
```


----------



## VladiBG (Jun 9, 2022)

Sorry i didn't understand what exactly you want to achieve.
If you want to redistribute the static route via BGP then use `network 10.68.189.201/32 static` in bgpd so you can advertise your static route of 10.68.189.201 to other neighbors.
The same command in cisco config with route-map will look like this

```
address-family ipv4
  redistribute connected
  redistribute static route-map static

route-map static permit 10
 match ip address prefix-list static

ip prefix-list static seq 5 permit 10.68.189.201/32 le 32
```


----------



## janakktrivedi (Jun 9, 2022)

Exactly, I am looking for auto redistribution of static route in BGP even though BGP has same route learning from other peers.
For that, I have below configuration in /usr/local/etc/bgpd.conf

network inet connected
network inet static

In general, BGP has NO issue with restribution of static routes if that route doesn't exist in BGP rib.


----------



## janakktrivedi (Aug 16, 2022)

Still struggling to get it working. Any help would be much appreciated!!!


----------

