DHCP-Relay over VRF in OSPF+MPLS+BGP (VRF aware)

Hello everyone!

I'm working in a lab with three CHRs v7.19.6 on eve-ng. My current configuration is OSPF+MPLS+BGP+VRF. I followed the instructions on the wiki and it's working.
I'm very happy because I've never mixed so many protocols together before. My problem is that I want to have a DHCP server on R1 and pass a DHCP relay from that R1 DHCP server to R3.
R1 has a DHCP server on ether5 and it's in vrf2. The idea is to pass it to R3 via vrf2 and with DHCP relay. I saw an example on the wiki, but it's not clear to me since they don't use OSPF+MPLS+BGP.

Diagram:

                   R2
                  /  \
  DHCP SERVER ->R1----R3-> DHCP RELAY

What would be the correct step to implement it with OSPF+MPLS+BGP? I know the steps are different for other brands like Cisco/OCNOS.


R1:

/ip address
add address=172.16.100.1/30 interface=ether2 network=172.16.100.0
add address=172.16.100.14/30 interface=ether3 network=172.16.100.12
add address=10.10.1.1 interface=lo network=10.10.1.1
add address=192.168.100.1/24 interface=ether10 network=192.168.100.0
add address=192.168.102.1/24 interface=ether5 network=192.168.102.0

# DHCP Server

/ip pool
add name=dhcp_pool0 ranges=192.168.100.100-192.168.100.200
add name=pool102 ranges=192.168.102.100-192.168.102.200

/ip dhcp-server
add address-pool=dhcp_pool0 interface=ether10 name=dhcp1
add address-pool=pool102 interface=ether5 name=server1 relay=192.168.102.1

/ip dhcp-server network
add address=192.168.100.0/24 dns-server=8.8.8.8,1.1.1.1 gateway=192.168.100.1

# OSPF

/routing ospf instance
add disabled=no name=backbone
/routing ospf area
add disabled=no instance=backbone name=backbone-area
/routing ospf interface-template
add area=backbone-area disabled=no interfaces=ether2,ether3,lo

# MPLS

/mpls ldp
add disabled=no lsr-id=10.10.1.1 transport-addresses=10.10.1.1
/mpls ldp interface
add disabled=no interface=ether2
add disabled=no interface=ether3

# BGP

/routing bgp template
set default afi=ip,vpnv4 as=65000 disabled=no routing-table=main

/routing bgp connection
add afi=ip,vpnv4 as=65000 connect=yes disabled=no listen=yes local.address=\
    10.10.1.1 .role=ibgp name=to-R2 remote.address=10.10.2.1/32 .as=65000 \
    routing-table=main templates=default
add afi=ip,vpnv4 as=65000 connect=yes disabled=no listen=yes local.address=\
    10.10.1.1 .role=ibgp name=to-R3 remote.address=10.10.3.1/32 .as=65000 \
    routing-table=main templates=default
add afi=ip,vpnv4 as=65000 connect=yes disabled=no listen=yes local.address=\
    10.10.1.1 .role=ibgp name=to-R4 remote.address=10.10.4.1/32 .as=65000 \
    routing-table=main templates=default

# VRF

/ip vrf
add interfaces=ether5 name=vrf2
add interfaces=ether10 name=vrf1

/routing bgp vpn
add disabled=no export.redistribute=connected,static .route-targets=111:1 \
    import.route-targets=111:1 label-allocation-policy=per-vrf name=\
    bgp-mpls-vpn-1 route-distinguisher=111:1 vrf=vrf1
add disabled=no export.redistribute=connected,static,dhcp .route-targets=111:2 \
    import.route-targets=111:2 label-allocation-policy=per-vrf name=\
    bgp-mpls-vpn-2 route-distinguisher=111:2 vrf=vrf2

# OTHERS

/ip dhcp-client
add interface=ether1

/system identity
set name=R1

/tool romon
set enabled=yes

R2:

/ip address
add address=172.16.100.2/30 interface=ether1 network=172.16.100.0
add address=172.16.100.5/30 interface=ether2 network=172.16.100.4
add address=10.10.2.1 interface=lo network=10.10.2.1

# DHCP Server

# OSPF

/routing ospf instance
add disabled=no name=backbone
/routing ospf area
add disabled=no instance=backbone name=backbone-area
/routing ospf interface-template
add area=backbone-area disabled=no interfaces=ether1,ether2,lo

# MPLS 

/mpls ldp
add disabled=no lsr-id=10.10.2.1 transport-addresses=10.10.2.1
/mpls ldp interface
add disabled=no interface=ether1
add disabled=no interface=ether2

# BGP 

/routing bgp template
set default afi=ip,vpnv4 as=65000 disabled=no routing-table=main

/routing bgp connection
add afi=ip,vpnv4 as=65000 connect=yes disabled=no listen=yes local.address=\
    10.10.2.1 .role=ibgp name=to-R1 remote.address=10.10.1.1/32 .as=65000 \
    routing-table=main templates=default

# VRF

# OTHERS

/system identity
set name=R2

/tool romon
set enabled=yes

R3:

/ip address
add address=172.16.100.13/30 interface=ether2 network=172.16.100.12
add address=172.16.100.6/30 interface=ether1 network=172.16.100.4
add address=10.10.3.1 interface=lo network=10.10.3.1
add address=192.168.101.1/24 interface=ether10 network=192.168.101.0

# DHCP Server

/ip pool
add name=dhcp_pool0 ranges=192.168.101.100-192.168.101.200
/ip dhcp-server
add address-pool=dhcp_pool0 interface=ether10 name=dhcp1
/ip dhcp-server network
add address=192.168.101.0/24 dns-server=8.8.8.8,1.1.1.1 gateway=192.168.101.1

/ip dhcp-server
add address-pool=pool102 interface=ether5 name=server1 relay=192.168.102.1

# OSPF

/routing ospf instance
add disabled=no name=backbone
/routing ospf area
add disabled=no instance=backbone name=backbone-area
/routing ospf interface-template
add area=backbone-area disabled=no interfaces=ether1,ether2,lo

# MPLS 

/mpls ldp
add disabled=no lsr-id=10.10.3.1 transport-addresses=10.10.3.1
/mpls ldp interface
add disabled=no interface=ether1
add disabled=no interface=ether2

# BGP 

/routing bgp template
set default afi=ip,vpnv4 as=65000 disabled=no routing-table=main
/routing bgp connection
add afi=ip,vpnv4 as=65000 connect=yes disabled=no listen=yes local.address=10.10.3.1 .role=ibgp name=to-R1 remote.address=10.10.1.1/32 .as=65000 routing-table=main templates=\
    default

# VRF

/ip vrf
add interfaces=ether5 name=vrf2
add interfaces=ether10 name=vrf1

/routing bgp vpn
add disabled=no export.redistribute=connected,static .route-targets=111:1 import.route-targets=111:1 label-allocation-policy=per-vrf name=bgp-mpls-vpn-1 route-distinguisher=\
    111:1 vrf=vrf1

/routing bgp vpn
add disabled=no export.redistribute=connected,static,dhcp .route-targets=111:2 import.route-targets=111:2 label-allocation-policy=per-vrf name=bgp-mpls-vpn-2 route-distinguisher=111:2 \
    vrf=vrf2

# OTHERS

/system identity
set name=R3

/tool romon
set enabled=yes

Hi,

According to my understanding, in a multi VRF setup the DHCP relay must operate inside the same VRF as the client network. It simply forwards DHCP messages within that VRF and doesn’t interact with MPLS labels or the global routing table.

The key is that both the relay on R3 and the DHCP server on R1 are in the same VRF, and MP BGP correctly exchanges the routes for that VRF. Once IP reachability exists between them, DHCP works the same way as in a normal network.

I’m curious, where are you in your lab right now Are you able to reach the DHCP server IP from R3 within the VRF