Redistribute Ospf

Scenario to verify BGP redistribute ospf functionality with metric and route-map filtering options.

../../../../_images/redistributeospf.svg

Test BGP Redistribute OSPF iBGP

Description

Test BGP redistribute ospf with iBGP. DUT0 runs OSPF and announces a dummy interface route. DUT1 (OSPF + BGP AS 10) learns the route via OSPF and redistributes it into BGP. DUT2 (BGP AS 10) learns the OSPF route through iBGP redistribution.

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces dummy dum0 address 192.168.100.1/24
set interfaces ethernet eth0 address 10.1.1.1/24
set protocols ospf area 0 network 10.1.1.0/24
set protocols ospf redistribute connected
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 address 10.1.1.100/24
set interfaces ethernet eth1 address 10.2.2.100/24
set protocols bgp 10 neighbor peer nexthop-self
set protocols bgp 10 neighbor peer remote-address 10.2.2.2
set protocols bgp 10 neighbor peer remote-as 10
set protocols bgp 10 redistribute ospf
set protocols ospf area 0 network 10.1.1.0/24
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Set the following configuration in DUT2 :

set interfaces ethernet eth1 address 10.2.2.2/24
set protocols bgp 10 neighbor peer remote-address 10.2.2.100
set protocols bgp 10 neighbor peer remote-as 10
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Attention

Verify OSPF neighbor is established between DUT0 and DUT1

Step 4: Run command protocols ospf show neighbor at DUT1 and check if output matches the following regular expressions:

10.1.1.1
Show output
Neighbor ID     Pri State           Up Time         Dead Time Address         Interface                        RXmtL RqstL DBsmL
192.168.100.1     1 2-Way/DROther   1.456s            38.543s 10.1.1.1        eth0:10.1.1.100                      0     0     0

Attention

Verify DUT1 learns the OSPF route 192.168.100.0/24 from DUT0

Step 5: Run command protocols ip show route at DUT1 and check if output matches the following regular expressions:

O>[*]\s+192.168.100.0/24
Show output
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
O   10.1.1.0/24 [110/10] is directly connected, eth0, weight 1, 00:00:50
C>* 10.1.1.0/24 is directly connected, eth0, weight 1, 00:00:50
K * 10.1.1.0/24 [0/0] is directly connected, eth0, weight 1, 00:00:50
L>* 10.1.1.100/32 is directly connected, eth0, weight 1, 00:00:50
C>* 10.2.2.0/24 is directly connected, eth1, weight 1, 00:00:51
K * 10.2.2.0/24 [0/0] is directly connected, eth1, weight 1, 00:00:51
L>* 10.2.2.100/32 is directly connected, eth1, weight 1, 00:00:51
O>* 192.168.100.0/24 [110/20] via 10.1.1.1, eth0, weight 1, 00:00:01

Attention

Verify BGP session is established between DUT1 and DUT2

Step 6: Run command protocols bgp show ip summary at DUT1 and check if output matches the following regular expressions:

10.2.2.2.*Established
Show output
IPv4 Unicast Summary:
BGP router identifier 10.2.2.100, local AS number 10 VRF default vrf-id 0
BGP table version 1
RIB entries 1, using 128 bytes of memory
Peers 1, using 24 KiB of memory

Neighbor        LocalAddr       V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down        State   PfxRcd   PfxSnt Desc
10.2.2.2        10.2.2.100      4         10         4         6        1    0    0 00:00:48  Established        0        1 FRRouting/10.4.1

Total number of neighbors 1

Attention

Verify DUT2 learns the redistributed OSPF route 192.168.100.0/24 via BGP

Step 7: Run command protocols bgp show ip at DUT2 and check if output matches the following regular expressions:

[*]>i\s+192.168.100.0/24
Show output
BGP table version is 1, local router ID is 10.2.2.2, vrf id 0
Default local pref 100, local AS 10
local address -
Status codes:  s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>i 192.168.100.0/24 10.2.2.100              20    100      0 ?

Displayed 1 routes and 1 total paths

Attention

Verify that route is installed in routing table

Step 8: Run command protocols ip show route at DUT2 and check if output matches the following regular expressions:

B>[*]\s+192.168.100.0/24
Show output
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
C>* 10.2.2.0/24 is directly connected, eth1, weight 1, 00:00:49
L>* 10.2.2.2/32 is directly connected, eth1, weight 1, 00:00:49
B>* 192.168.100.0/24 [200/20] via 10.2.2.100, eth1, weight 1, 00:00:01

Test BGP Redistribute OSPF eBGP

Description

Test BGP redistribute ospf with eBGP. DUT0 runs OSPF and announces a dummy interface route. DUT1 (OSPF + BGP AS 10) learns the route via OSPF and redistributes it into BGP. DUT2 (BGP AS 20) learns the OSPF route through eBGP redistribution.

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces dummy dum0 address 192.168.100.1/24
set interfaces ethernet eth0 address 10.1.1.1/24
set protocols ospf area 0 network 10.1.1.0/24
set protocols ospf redistribute connected
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 address 10.1.1.100/24
set interfaces ethernet eth1 address 10.2.2.100/24
set protocols bgp 10 neighbor peer remote-address 10.2.2.2
set protocols bgp 10 neighbor peer remote-as 20
set protocols bgp 10 neighbor peer route-map export PERMIT
set protocols bgp 10 redistribute ospf
set protocols ospf area 0 network 10.1.1.0/24
set protocols route-map PERMIT rule 1 action permit
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Set the following configuration in DUT2 :

set interfaces ethernet eth1 address 10.2.2.2/24
set protocols bgp 20 neighbor peer remote-address 10.2.2.100
set protocols bgp 20 neighbor peer remote-as 10
set protocols bgp 20 neighbor peer route-map import PERMIT
set protocols route-map PERMIT rule 1 action permit
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Attention

Verify OSPF neighbor is established between DUT0 and DUT1

Step 4: Run command protocols ospf show neighbor at DUT1 and check if output matches the following regular expressions:

10.1.1.1
Show output
Neighbor ID     Pri State           Up Time         Dead Time Address         Interface                        RXmtL RqstL DBsmL
192.168.100.1     1 2-Way/DROther   1.557s            38.442s 10.1.1.1        eth0:10.1.1.100                      0     0     0

Attention

Verify DUT1 learns the OSPF route 192.168.100.0/24 from DUT0

Step 5: Run command protocols ip show route at DUT1 and check if output matches the following regular expressions:

O>[*]\s+192.168.100.0/24
Show output
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
O   10.1.1.0/24 [110/10] is directly connected, eth0, weight 1, 00:00:50
C>* 10.1.1.0/24 is directly connected, eth0, weight 1, 00:00:51
L>* 10.1.1.100/32 is directly connected, eth0, weight 1, 00:00:51
C>* 10.2.2.0/24 is directly connected, eth1, weight 1, 00:00:51
L>* 10.2.2.100/32 is directly connected, eth1, weight 1, 00:00:51
O>* 192.168.100.0/24 [110/20] via 10.1.1.1, eth0, weight 1, 00:00:01

Attention

Verify BGP session is established between DUT1 and DUT2

Step 6: Run command protocols bgp show ip summary at DUT1 and check if output matches the following regular expressions:

10.2.2.2.*Established
Show output
IPv4 Unicast Summary:
BGP router identifier 10.2.2.100, local AS number 10 VRF default vrf-id 0
BGP table version 1
RIB entries 1, using 128 bytes of memory
Peers 1, using 24 KiB of memory

Neighbor        LocalAddr       V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down        State   PfxRcd   PfxSnt Desc
10.2.2.2        10.2.2.100      4         20         5         7        1    0    0 00:00:49  Established (Policy)        1 N/A

Total number of neighbors 1

Attention

Verify DUT2 learns the redistributed OSPF route 192.168.100.0/24 via BGP

Step 7: Run command protocols bgp show ip at DUT2 and check if output matches the following regular expressions:

[*]>\s+192.168.100.0/24
Show output
BGP table version is 1, local router ID is 10.2.2.2, vrf id 0
Default local pref 100, local AS 20
local address -
Status codes:  s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  192.168.100.0/24 10.2.2.100              20             0 10 ?

Displayed 1 routes and 1 total paths

Attention

Verify that route is installed in routing table

Step 8: Run command protocols ip show route at DUT2 and check if output matches the following regular expressions:

B>[*]\s+192.168.100.0/24
Show output
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
C>* 10.2.2.0/24 is directly connected, eth1, weight 1, 00:00:50
K * 10.2.2.0/24 [0/0] is directly connected, eth1, weight 1, 00:00:50
L>* 10.2.2.2/32 is directly connected, eth1, weight 1, 00:00:50
B>* 192.168.100.0/24 [20/20] via 10.2.2.100, eth1, weight 1, 00:00:02

Test BGP Redistribute OSPF With Metric iBGP

Description

Test BGP redistribute ospf metric with iBGP. DUT1 redistributes OSPF routes with metric 100 (MED). DUT2 learns the route with MED 100.

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces dummy dum0 address 192.168.100.1/24
set interfaces ethernet eth0 address 10.1.1.1/24
set protocols ospf area 0 network 10.1.1.0/24
set protocols ospf redistribute connected
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 address 10.1.1.100/24
set interfaces ethernet eth1 address 10.2.2.100/24
set protocols bgp 10 neighbor peer nexthop-self
set protocols bgp 10 neighbor peer remote-address 10.2.2.2
set protocols bgp 10 neighbor peer remote-as 10
set protocols bgp 10 redistribute ospf metric 100
set protocols ospf area 0 network 10.1.1.0/24
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Set the following configuration in DUT2 :

set interfaces ethernet eth1 address 10.2.2.2/24
set protocols bgp 10 neighbor peer remote-address 10.2.2.100
set protocols bgp 10 neighbor peer remote-as 10
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Attention

Verify OSPF neighbor is established between DUT0 and DUT1

Step 4: Run command protocols ospf show neighbor at DUT1 and check if output matches the following regular expressions:

10.1.1.1
Show output
Neighbor ID     Pri State           Up Time         Dead Time Address         Interface                        RXmtL RqstL DBsmL
192.168.100.1     1 Init/DROther    1.559s            38.440s 10.1.1.1        eth0:10.1.1.100                      0     0     0

Attention

Verify DUT1 learns the OSPF route 192.168.100.0/24 from DUT0

Step 5: Run command protocols ip show route at DUT1 and check if output matches the following regular expressions:

O>[*]\s+192.168.100.0/24
Show output
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
O   10.1.1.0/24 [110/10] is directly connected, eth0, weight 1, 00:00:50
C>* 10.1.1.0/24 is directly connected, eth0, weight 1, 00:00:50
K * 10.1.1.0/24 [0/0] is directly connected, eth0, weight 1, 00:00:50
L>* 10.1.1.100/32 is directly connected, eth0, weight 1, 00:00:50
C>* 10.2.2.0/24 is directly connected, eth1, weight 1, 00:00:51
K * 10.2.2.0/24 [0/0] is directly connected, eth1, weight 1, 00:00:51
L>* 10.2.2.100/32 is directly connected, eth1, weight 1, 00:00:51
O>* 192.168.100.0/24 [110/20] via 10.1.1.1, eth0, weight 1, 00:00:01

Attention

Verify BGP session is established between DUT1 and DUT2

Step 6: Run command protocols bgp show ip summary at DUT1 and check if output matches the following regular expressions:

10.2.2.2.*Established
Show output
IPv4 Unicast Summary:
BGP router identifier 10.2.2.100, local AS number 10 VRF default vrf-id 0
BGP table version 1
RIB entries 1, using 128 bytes of memory
Peers 1, using 24 KiB of memory

Neighbor        LocalAddr       V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down        State   PfxRcd   PfxSnt Desc
10.2.2.2        10.2.2.100      4         10         4         6        1    0    0 00:00:48  Established        0        1 FRRouting/10.4.1

Total number of neighbors 1

Attention

Verify DUT2 learns route 192.168.100.0/24 with MED 100

Step 7: Run command protocols bgp show ip at DUT2 and check if output matches the following regular expressions:

[*]>i\s+192.168.100.0/24.+\s100\s
Show output
BGP table version is 1, local router ID is 10.2.2.2, vrf id 0
Default local pref 100, local AS 10
local address -
Status codes:  s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>i 192.168.100.0/24 10.2.2.100             100    100      0 ?

Displayed 1 routes and 1 total paths

Test BGP Redistribute OSPF With Metric eBGP

Description

Test BGP redistribute ospf metric with eBGP. DUT1 (BGP AS 10) redistributes OSPF routes with metric 100 (MED) to DUT2 (BGP AS 20).

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces dummy dum0 address 192.168.100.1/24
set interfaces ethernet eth0 address 10.1.1.1/24
set protocols ospf area 0 network 10.1.1.0/24
set protocols ospf redistribute connected
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 address 10.1.1.100/24
set interfaces ethernet eth1 address 10.2.2.100/24
set protocols bgp 10 neighbor peer remote-address 10.2.2.2
set protocols bgp 10 neighbor peer remote-as 20
set protocols bgp 10 neighbor peer route-map export PERMIT
set protocols bgp 10 redistribute ospf metric 100
set protocols ospf area 0 network 10.1.1.0/24
set protocols route-map PERMIT rule 1 action permit
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Set the following configuration in DUT2 :

set interfaces ethernet eth1 address 10.2.2.2/24
set protocols bgp 20 neighbor peer remote-address 10.2.2.100
set protocols bgp 20 neighbor peer remote-as 10
set protocols bgp 20 neighbor peer route-map import PERMIT
set protocols route-map PERMIT rule 1 action permit
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Attention

Verify OSPF neighbor is established between DUT0 and DUT1

Step 4: Run command protocols ospf show neighbor at DUT1 and check if output matches the following regular expressions:

10.1.1.1
Show output
Neighbor ID     Pri State           Up Time         Dead Time Address         Interface                        RXmtL RqstL DBsmL
192.168.100.1     1 Init/DROther    1.885s            38.114s 10.1.1.1        eth0:10.1.1.100                      0     0     0

Attention

Verify DUT1 learns the OSPF route 192.168.100.0/24 from DUT0

Step 5: Run command protocols ip show route at DUT1 and check if output matches the following regular expressions:

O>[*]\s+192.168.100.0/24
Show output
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
O   10.1.1.0/24 [110/10] is directly connected, eth0, weight 1, 00:00:51
C>* 10.1.1.0/24 is directly connected, eth0, weight 1, 00:00:51
K * 10.1.1.0/24 [0/0] is directly connected, eth0, weight 1, 00:00:51
L>* 10.1.1.100/32 is directly connected, eth0, weight 1, 00:00:51
C>* 10.2.2.0/24 is directly connected, eth1, weight 1, 00:00:51
K * 10.2.2.0/24 [0/0] is directly connected, eth1, weight 1, 00:00:51
L>* 10.2.2.100/32 is directly connected, eth1, weight 1, 00:00:51
O>* 192.168.100.0/24 [110/20] via 10.1.1.1, eth0, weight 1, 00:00:02

Attention

Verify BGP session is established between DUT1 and DUT2

Step 6: Run command protocols bgp show ip summary at DUT1 and check if output matches the following regular expressions:

10.2.2.2.*Established
Show output
IPv4 Unicast Summary:
BGP router identifier 10.2.2.100, local AS number 10 VRF default vrf-id 0
BGP table version 1
RIB entries 1, using 128 bytes of memory
Peers 1, using 24 KiB of memory

Neighbor        LocalAddr       V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down        State   PfxRcd   PfxSnt Desc
10.2.2.2        10.2.2.100      4         20         5         7        1    0    0 00:00:50  Established (Policy)        1 N/A

Total number of neighbors 1

Attention

Verify DUT2 learns route 192.168.100.0/24 with MED 100

Step 7: Run command protocols bgp show ip at DUT2 and check if output matches the following regular expressions:

[*]>\s+192.168.100.0/24.+\s100\s
Show output
BGP table version is 1, local router ID is 10.2.2.2, vrf id 0
Default local pref 100, local AS 20
local address -
Status codes:  s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  192.168.100.0/24 10.2.2.100             100             0 10 ?

Displayed 1 routes and 1 total paths

Test BGP Redistribute OSPF With Route-Map iBGP

Description

Test BGP redistribute ospf route-map with iBGP. DUT0 announces two OSPF networks (dum0 and dum1) via OSPF. DUT1 uses a route-map to only redistribute 192.168.100.0/24 to BGP. DUT2 learns only the matching route, while 192.168.200.0/24 is filtered out.

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces dummy dum0 address 192.168.100.1/24
set interfaces dummy dum1 address 192.168.200.1/24
set interfaces ethernet eth0 address 10.1.1.1/24
set protocols ospf area 0 network 10.1.1.0/24
set protocols ospf redistribute connected
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 address 10.1.1.100/24
set interfaces ethernet eth1 address 10.2.2.100/24
set protocols bgp 10 neighbor peer nexthop-self
set protocols bgp 10 neighbor peer remote-address 10.2.2.2
set protocols bgp 10 neighbor peer remote-as 10
set protocols bgp 10 redistribute ospf route-map FILTER-OSPF
set protocols ip prefix-list ALLOW-DUM0 rule 1 action permit
set protocols ip prefix-list ALLOW-DUM0 rule 1 prefix 192.168.100.0/24
set protocols ospf area 0 network 10.1.1.0/24
set protocols route-map FILTER-OSPF rule 1 action permit
set protocols route-map FILTER-OSPF rule 1 match ip address prefix-list ALLOW-DUM0
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Set the following configuration in DUT2 :

set interfaces ethernet eth1 address 10.2.2.2/24
set protocols bgp 10 neighbor peer remote-address 10.2.2.100
set protocols bgp 10 neighbor peer remote-as 10
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Attention

Verify OSPF neighbor is established between DUT0 and DUT1

Step 4: Run command protocols ospf show neighbor at DUT1 and check if output matches the following regular expressions:

10.1.1.1
Show output
Neighbor ID     Pri State           Up Time         Dead Time Address         Interface                        RXmtL RqstL DBsmL
192.168.200.1     1 Init/DROther    1.889s            38.110s 10.1.1.1        eth0:10.1.1.100                      0     0     0

Attention

Verify DUT1 learns both OSPF routes from DUT0

Step 5: Run command protocols ip show route at DUT1 and check if output matches the following regular expressions:

192.168.100.0/24[\s\S]+192.168.200.0/24
Show output
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
O   10.1.1.0/24 [110/10] is directly connected, eth0, weight 1, 00:00:51
C>* 10.1.1.0/24 is directly connected, eth0, weight 1, 00:00:51
K * 10.1.1.0/24 [0/0] is directly connected, eth0, weight 1, 00:00:51
L>* 10.1.1.100/32 is directly connected, eth0, weight 1, 00:00:51
C>* 10.2.2.0/24 is directly connected, eth1, weight 1, 00:00:51
K * 10.2.2.0/24 [0/0] is directly connected, eth1, weight 1, 00:00:51
L>* 10.2.2.100/32 is directly connected, eth1, weight 1, 00:00:51
O>* 192.168.100.0/24 [110/20] via 10.1.1.1, eth0, weight 1, 00:00:02
O>* 192.168.200.0/24 [110/20] via 10.1.1.1, eth0, weight 1, 00:00:02

Attention

Verify BGP session is established between DUT1 and DUT2

Step 6: Run command protocols bgp show ip summary at DUT1 and check if output matches the following regular expressions:

10.2.2.2.*Established
Show output
IPv4 Unicast Summary:
BGP router identifier 10.2.2.100, local AS number 10 VRF default vrf-id 0
BGP table version 1
RIB entries 1, using 128 bytes of memory
Peers 1, using 24 KiB of memory

Neighbor        LocalAddr       V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down        State   PfxRcd   PfxSnt Desc
10.2.2.2        10.2.2.100      4         10         4         6        1    0    0 00:00:48  Established        0        1 FRRouting/10.4.1

Total number of neighbors 1

Attention

Verify DUT2 learns only 192.168.100.0/24 (matching route-map)

Step 7: Run command protocols bgp show ip at DUT2 and check if output matches the following regular expressions:

[*]>i\s+192.168.100.0/24
Show output
BGP table version is 1, local router ID is 10.2.2.2, vrf id 0
Default local pref 100, local AS 10
local address -
Status codes:  s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>i 192.168.100.0/24 10.2.2.100              20    100      0 ?

Displayed 1 routes and 1 total paths

Test BGP Redistribute OSPF With Route-Map eBGP

Description

Test BGP redistribute ospf route-map with eBGP. DUT0 announces two OSPF networks (dum0 and dum1) via OSPF. DUT1 (BGP AS 10) uses a route-map to only redistribute 192.168.100.0/24 to BGP. DUT2 (BGP AS 20) learns only the matching route.

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces dummy dum0 address 192.168.100.1/24
set interfaces dummy dum1 address 192.168.200.1/24
set interfaces ethernet eth0 address 10.1.1.1/24
set protocols ospf area 0 network 10.1.1.0/24
set protocols ospf redistribute connected
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 address 10.1.1.100/24
set interfaces ethernet eth1 address 10.2.2.100/24
set protocols bgp 10 neighbor peer remote-address 10.2.2.2
set protocols bgp 10 neighbor peer remote-as 20
set protocols bgp 10 neighbor peer route-map export PERMIT
set protocols bgp 10 redistribute ospf route-map FILTER-OSPF
set protocols ip prefix-list ALLOW-DUM0 rule 1 action permit
set protocols ip prefix-list ALLOW-DUM0 rule 1 prefix 192.168.100.0/24
set protocols ospf area 0 network 10.1.1.0/24
set protocols route-map FILTER-OSPF rule 1 action permit
set protocols route-map FILTER-OSPF rule 1 match ip address prefix-list ALLOW-DUM0
set protocols route-map PERMIT rule 1 action permit
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Set the following configuration in DUT2 :

set interfaces ethernet eth1 address 10.2.2.2/24
set protocols bgp 20 neighbor peer remote-address 10.2.2.100
set protocols bgp 20 neighbor peer remote-as 10
set protocols bgp 20 neighbor peer route-map import PERMIT
set protocols route-map PERMIT rule 1 action permit
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Attention

Verify OSPF neighbor is established between DUT0 and DUT1

Step 4: Run command protocols ospf show neighbor at DUT1 and check if output matches the following regular expressions:

10.1.1.1
Show output
Neighbor ID     Pri State           Up Time         Dead Time Address         Interface                        RXmtL RqstL DBsmL
192.168.200.1     1 Init/DROther    0.173s            39.826s 10.1.1.1        eth0:10.1.1.100                      0     0     0

Attention

Verify DUT1 learns both OSPF routes from DUT0

Step 5: Run command protocols ip show route at DUT1 and check if output matches the following regular expressions:

192.168.100.0/24[\s\S]+192.168.200.0/24
Show output
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
O   10.1.1.0/24 [110/10] is directly connected, eth0, weight 1, 00:00:54
C>* 10.1.1.0/24 is directly connected, eth0, weight 1, 00:00:54
K * 10.1.1.0/24 [0/0] is directly connected, eth0, weight 1, 00:00:54
L>* 10.1.1.100/32 is directly connected, eth0, weight 1, 00:00:54
C>* 10.2.2.0/24 is directly connected, eth1, weight 1, 00:00:54
K * 10.2.2.0/24 [0/0] is directly connected, eth1, weight 1, 00:00:54
L>* 10.2.2.100/32 is directly connected, eth1, weight 1, 00:00:54
O>* 192.168.100.0/24 [110/20] via 10.1.1.1, eth0, weight 1, 00:00:05
O>* 192.168.200.0/24 [110/20] via 10.1.1.1, eth0, weight 1, 00:00:05

Attention

Verify BGP session is established between DUT1 and DUT2

Step 6: Run command protocols bgp show ip summary at DUT1 and check if output matches the following regular expressions:

10.2.2.2.*Established
Show output
IPv4 Unicast Summary:
BGP router identifier 10.2.2.100, local AS number 10 VRF default vrf-id 0
BGP table version 1
RIB entries 1, using 128 bytes of memory
Peers 1, using 24 KiB of memory

Neighbor        LocalAddr       V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down        State   PfxRcd   PfxSnt Desc
10.2.2.2        10.2.2.100      4         20         5         7        1    0    0 00:00:52  Established (Policy)        1 N/A

Total number of neighbors 1

Attention

Verify DUT2 learns only 192.168.100.0/24 (matching route-map)

Step 7: Run command protocols bgp show ip at DUT2 and check if output matches the following regular expressions:

[*]>\s+192.168.100.0/24
Show output
BGP table version is 1, local router ID is 10.2.2.2, vrf id 0
Default local pref 100, local AS 20
local address -
Status codes:  s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  192.168.100.0/24 10.2.2.100              20             0 10 ?

Displayed 1 routes and 1 total paths