Set BGP next-hop based on Interface


#1

Hey All,

I’ve just started plying with VyOS as a replacement for a couple of Virtual Miktorik’s I have and so far I’m quite liking it. I’ve run into one issue with forcing a next-hop address on a BGP Session though and I’m hoping someone will be able to point me in the right direction.

The scenario: I have multiple VyOS routers connected via GRE tunnels, all running iBGP. The GRE tunnels have both IPv4 and IPv6 addresses assigned and I am running a single BGP session to advertise both V4 and V6 routes. I would like to create a route-map so that exported routes have the correct next-hop value, however I’d rather avoid creating a separate route-map for each BGP session as that would get tedious quickly. What I’ve tried doing is creating a single route-map, with multiple rules to match the tunnel interfaces the session is running over, however, what seems to happen is the first rule is matched all the time and the next-hop is set accordingly to the first rule. Am I mis-interpreting how the interface matching is supposed to work? Below is a config snippit of my route map and BGP session:

show policy route-map 10VPN-Internal-Out
rule 2 {
action permit
match {
interface tun23
}
set {
ip-next-hop 10.2.1.80
}
}
rule 3 {
action permit
match {
interface tun2
}
set {
ip-next-hop 10.2.1.19
}
}
rule 4 {
action permit
match {
interface tun1
}
set {
ip-next-hop 10.2.1.93
}
}

show protocols bgp 396503 neighbor 2602:fed2:3e7:21::1
remote-as 396503
route-map {
export 10VPN-Internal-Out
import 10VPN-Internal
}