Evil_TTL> show | s

Route Aggregation on Juniper SRX

Category:Juniper -> Security

Let’s configure Lo interface with IP address 192.168.250.1/32. We are going to use this IP address, aggregate into 192.168.250.0/24 and advertise to BGP peers.

I’m going to use pre-configured logical system and virtual-router routing-instance as part of the configurations.

From minimum required configuration to maximum.

Part 1

set logical-systems LSYS routing-instances VR routing-options aggregate route 192.168.250.0/24

set logical
-systems LSYS policy-options policy-statement EXPORT_AGGREGATE from protocol aggregate
set logical
-systems LSYS policy-options policy-statement EXPORT_AGGREGATE then accept

set logical
-systems LSYS routing-instances VR protocols bgp group BGP_GROUP export EXPORT_AGGREGATE 

This will search for all routes 192.168.250.0/24 orlonger and as long there are such in the routing table, the SRX will aggregate them into 192.168.250.0/24 and export to BGP peers via EXPORT_AGGREGATE policy. Here is a small test which contributing routes are there in the routing table:

show route protocol aggregate extensive logical-system LSYS

VR
.inet.020 destinations32 routes (19 active0 holddown1 hidden)
192.168.250.0/24 (1 entry1 announced)
TSI:
KRT in-kernel 192.168.250.0/24 -> {}
Page 0 idx 0
, (group BGP_GROUP type ExternalType 1 val 0xb23cf2c (adv_entry)
 
Advertised metrics:
  
NexthopSelf
  
AS path[65001] I (LocalAgg)
  
Communities:
Path 192.168.250.0 Vector len 4.  Val0
 
*Aggregate Preference130
  Next hop type
RejectNext hop index0
  Address
0xa1e1e28
  Next
-hop reference count3
  State
: <Active Int Ext>
  
Local AS: 65001
  Age
2:53:18
  Validation State
unverified
  Task
Aggregate
  Announcement bits 
(2): 0-KRT 1-BGP_RT_Background
  
AS pathI  (LocalAgg)
  
Flags:                  Depth0        Active
  
AS path list:
  AS 
pathI Refcount1
  Contributing Routes 
(1):
   
192.168.250.1/32 proto Direct 

Now see what happens if I matched 192.168.0.0/16:

set logical-systems LSYS routing-instances VR routing-options aggregate route 192.168.0.0/16

set logical
-systems LSYS policy-options policy-statement EXPORT_AGGREGATE from protocol aggregate
set logical
-systems LSYS policy-options policy-statement EXPORT_AGGREGATE then accept

set logical
-systems LSYS routing-instances VR protocols bgp group BGP_GROUP export EXPORT_AGGREGATE

######################################################################################

show route protocol aggregate extensive logical-system LSYS

VR
.inet.020 destinations32 routes (19 active0 holddown1 hidden)
192.168.0.0/16 (1 entry1 announced)
TSI:
KRT in-kernel 192.168.0.0/16 -> {}
Page 0 idx 0
, (group BGP_GROUP type ExternalType 1 val 0xb23cf2c (adv_entry)
 
Advertised metrics:
  
NexthopSelf
  
AS path[65001] {65402 65404} I (LocalAgg)
  
Communities:
Path 192.168.0.0 Vector len 4.  Val0
 
*Aggregate Preference130
  Next hop type
RejectNext hop index0
  Address
0xa1e1e28
  Next
-hop reference count3
  State
: <Active Int Ext>
  
Local AS: 65001
  Age
5
  Validation State
unverified
  Task
Aggregate
  Announcement bits 
(2): 0-KRT 1-BGP_RT_Background
  
AS path{65402 65404} I  (LocalAgg)
  
Flags:                  Depth1        Active
  
AS path list:
  AS 
pathI Refcount3
  
AS path65404 65402 I Refcount3
  Contributing Routes 
(6):
   
192.168.1.0/30 proto Direct
   192.168.1.4
/30 proto Direct
   192.168.250.1
/32 proto Direct
   192.168.100.0
/24 proto BGP
   192.168.101.0
/24 proto BGP
   192.168.102.0
/24 proto BGP 

And this is what happens if there is nothing to match, for example non-existent 192.168.251.0/24:

set logical-systems LSYS routing-instances VR routing-options aggregate route 192.168.251.0/24

set logical
-systems LSYS policy-options policy-statement EXPORT_AGGREGATE from protocol aggregate
set logical
-systems LSYS policy-options policy-statement EXPORT_AGGREGATE then accept

set logical
-systems LSYS routing-instances VR protocols bgp group BGP_GROUP export EXPORT_AGGREGATE

######################################################################################

show route protocol aggregate extensive logical-system LSYS

VR
.inet.019 destinations31 routes (18 active0 holddown1 hidden)

inet6.01 destinations1 routes (1 active0 holddown0 hidden)

VR.inet6.01 destinations1 routes (1 active0 holddown0 hidden

Part 2

Now we’ll apply additional filters:

set logical-systems LSYS routing-instances VR routing-options aggregate route 192.168.250.0/24

set logical
-systems LSYS policy-options policy-statement EXPORT_AGGREGATE from protocol aggregate
set logical
-systems LSYS policy-options policy-statement EXPORT_AGGREGATE from route-filter 192.168.250.0/24 exact // <----- filter
set logical-systems LSYS policy-options policy-statement EXPORT_AGGREGATE then accept

set logical
-systems LSYS routing-instances VR protocols bgp group BGP_GROUP export EXPORT_AGGREGATE 

If we had more than 1 aggregated IP subnet, we could filter just what we needed.

Part 3

More filters:

set logical-systems LSYS policy-options policy-statement AGGREGATE term 1 from direct
set logical
-systems LSYS policy-options policy-statement AGGREGATE term 1 from route-filter 192.168.250.1/32 exact
set logical
-systems LSYS policy-options policy-statement AGGREGATE term 1 then accept
set logical
-systems LSYS policy-options policy-statement AGGREGATE term else-reject then reject // <---- this line is necessary, else if "term 1" doesn't match anything, everything will be accepted

set logical-systems LSYS routing-instances VR routing-options aggregate route 192.168.250.0/24 policy AGGREGATE // <----- new filter

set logical-systems LSYS policy-options policy-statement EXPORT_AGGREGATE from protocol aggregate
set logical
-systems LSYS policy-options policy-statement EXPORT_AGGREGATE from route-filter 192.168.250.0/24 exact // <----- filter from Part 2
set logical-systems LSYS policy-options policy-statement EXPORT_AGGREGATE then accept

set logical
-systems LSYS routing-instances VR protocols bgp group BGP_GROUP export EXPORT_AGGREGATE 

If we experiment with the filters:

set logical-systems LSYS policy-options policy-statement AGGREGATE term 1 from direct
set logical
-systems LSYS policy-options policy-statement AGGREGATE term 1 from route-filter 192.168.250.1/32 exact
set logical
-systems LSYS policy-options policy-statement AGGREGATE term 1 then accept
set logical
-systems LSYS policy-options policy-statement AGGREGATE term else-reject then reject

set logical
-systems LSYS routing-instances VR routing-options aggregate route 192.168.0.0/16 policy AGGREGATE // <----- remember filter from "Part 1" and how many contributing routes it referred to? The AGGREGATE policy will reject anything extra so only 192.168.250.1/32 will remain

set logical-systems LSYS policy-options policy-statement EXPORT_AGGREGATE from protocol aggregate
// #set logical-systems LSYS policy-options policy-statement EXPORT_AGGREGATE from route-filter 192.168.250.0/24 exact // <----- removed temporarily
set logical-systems LSYS policy-options policy-statement EXPORT_AGGREGATE then accept

set logical
-systems LSYS routing-instances VR protocols bgp group BGP_GROUP export EXPORT_AGGREGATE

#######################################################
//Aggregated:

VR.inet.019 destinations31 routes (19 active0 holddown0 hidden)
192.168.0.0/16 (1 entry1 announced)
TSI:
KRT in-kernel 192.168.0.0/16 -> {}
Page 0 idx 0
, (group BGP_GROUP type ExternalType 1 val 0xb23cf2c (adv_entry)
 
Advertised metrics:
  
NexthopSelf
  
AS path[65001] I (LocalAgg)
  
Communities:
Path 192.168.0.0 Vector len 4.  Val0
 
*Aggregate Preference130
  Next hop type
RejectNext hop index0
  Address
0xa1e1e28
  Next
-hop reference count2
  State
: <Active Int Ext>
  
Local AS: 65001
  Age
35
  Validation State
unverified
  Task
Aggregate
  Announcement bits 
(2): 0-KRT 1-BGP_RT_Background
  
AS pathI  (LocalAgg)
  
Flags:                  Depth0        Active
  
AS path list:
  AS 
pathI Refcount1
  Contributing Routes 
(1):
   
192.168.250.1/32 proto Direct

//Advertised:

test@hostname# run show route advertising-protocol bgp 192.168.1.2 logical-system LSYS

VR.inet.019 destinations31 routes (19 active0 holddown0 hidden)
Prefix                  Nexthop              MED     Lclpref    AS path
192.168.0.0/16          Self                                    I 

Under different conditions:

set logical-systems LSYS policy-options policy-statement AGGREGATE term 1 from direct
set logical
-systems LSYS policy-options policy-statement AGGREGATE term 1 from route-filter 192.168.250.1/32 exact
set logical
-systems LSYS policy-options policy-statement AGGREGATE term 1 then accept
set logical
-systems LSYS policy-options policy-statement AGGREGATE term else-reject then reject

set logical
-systems LSYS routing-instances VR routing-options aggregate route 192.168.0.0/16 policy AGGREGATE // <----- remember filter from "Part 1" and how many contributing routes it referred to? The AGGREGATE policy will reject anything extra so only 192.168.250.1/32 will remain

set logical-systems LSYS policy-options policy-statement EXPORT_AGGREGATE from protocol aggregate
set logical
-systems LSYS policy-options policy-statement EXPORT_AGGREGATE from route-filter 192.168.250.0/24 exact // <------ readded
set logical-systems LSYS policy-options policy-statement EXPORT_AGGREGATE then accept

set logical
-systems LSYS routing-instances VR protocols bgp group BGP_GROUP export EXPORT_AGGREGATE


#######################################################
//Aggregated:

VR.inet.019 destinations31 routes (19 active0 holddown0 hidden)
192.168.0.0/16 (1 entry1 announced)
TSI:
KRT in-kernel 192.168.0.0/16 -> {}
Page 0 idx 0
, (group BGP_GROUP type ExternalType 1 val 0xb23cf2c (adv_entry)
 
Advertised metrics:
  
NexthopSelf
  
AS path[65001] I (LocalAgg)
  
Communities:
Path 192.168.0.0 Vector len 4.  Val0
 
*Aggregate Preference130
  Next hop type
RejectNext hop index0
  Address
0xa1e1e28
  Next
-hop reference count2
  State
: <Active Int Ext>
  
Local AS: 65001
  Age
35
  Validation State
unverified
  Task
Aggregate
  Announcement bits 
(2): 0-KRT 1-BGP_RT_Background
  
AS pathI  (LocalAgg)
  
Flags:                  Depth0        Active
  
AS path list:
  AS 
pathI Refcount1
  Contributing Routes 
(1):
   
192.168.250.1/32 proto Direct

//Advertised:

test@hostname# run show route advertising-protocol bgp 192.168.1.2 logical-system LSYS
<blank//not advertised 

 

By privilege15