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
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.0: 20 destinations, 32 routes (19 active, 0 holddown, 1 hidden)
192.168.250.0/24 (1 entry, 1 announced)
TSI:
KRT in-kernel 192.168.250.0/24 -> {}
Page 0 idx 0, (group BGP_GROUP type External) Type 1 val 0xb23cf2c (adv_entry)
Advertised metrics:
Nexthop: Self
AS path: [65001] I (LocalAgg)
Communities:
Path 192.168.250.0 Vector len 4. Val: 0
*Aggregate Preference: 130
Next hop type: Reject, Next hop index: 0
Address: 0xa1e1e28
Next-hop reference count: 3
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 path: I (LocalAgg)
Flags: Depth: 0 Active
AS path list:
AS path: I Refcount: 1
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.0: 20 destinations, 32 routes (19 active, 0 holddown, 1 hidden)
192.168.0.0/16 (1 entry, 1 announced)
TSI:
KRT in-kernel 192.168.0.0/16 -> {}
Page 0 idx 0, (group BGP_GROUP type External) Type 1 val 0xb23cf2c (adv_entry)
Advertised metrics:
Nexthop: Self
AS path: [65001] {65402 65404} I (LocalAgg)
Communities:
Path 192.168.0.0 Vector len 4. Val: 0
*Aggregate Preference: 130
Next hop type: Reject, Next hop index: 0
Address: 0xa1e1e28
Next-hop reference count: 3
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: Depth: 1 Active
AS path list:
AS path: I Refcount: 3
AS path: 65404 65402 I Refcount: 3
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.0: 19 destinations, 31 routes (18 active, 0 holddown, 1 hidden)
inet6.0: 1 destinations, 1 routes (1 active, 0 holddown, 0 hidden)
VR.inet6.0: 1 destinations, 1 routes (1 active, 0 holddown, 0 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.0: 19 destinations, 31 routes (19 active, 0 holddown, 0 hidden)
192.168.0.0/16 (1 entry, 1 announced)
TSI:
KRT in-kernel 192.168.0.0/16 -> {}
Page 0 idx 0, (group BGP_GROUP type External) Type 1 val 0xb23cf2c (adv_entry)
Advertised metrics:
Nexthop: Self
AS path: [65001] I (LocalAgg)
Communities:
Path 192.168.0.0 Vector len 4. Val: 0
*Aggregate Preference: 130
Next hop type: Reject, Next hop index: 0
Address: 0xa1e1e28
Next-hop reference count: 2
State: <Active Int Ext>
Local AS: 65001
Age: 35
Validation State: unverified
Task: Aggregate
Announcement bits (2): 0-KRT 1-BGP_RT_Background
AS path: I (LocalAgg)
Flags: Depth: 0 Active
AS path list:
AS path: I Refcount: 1
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.0: 19 destinations, 31 routes (19 active, 0 holddown, 0 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.0: 19 destinations, 31 routes (19 active, 0 holddown, 0 hidden)
192.168.0.0/16 (1 entry, 1 announced)
TSI:
KRT in-kernel 192.168.0.0/16 -> {}
Page 0 idx 0, (group BGP_GROUP type External) Type 1 val 0xb23cf2c (adv_entry)
Advertised metrics:
Nexthop: Self
AS path: [65001] I (LocalAgg)
Communities:
Path 192.168.0.0 Vector len 4. Val: 0
*Aggregate Preference: 130
Next hop type: Reject, Next hop index: 0
Address: 0xa1e1e28
Next-hop reference count: 2
State: <Active Int Ext>
Local AS: 65001
Age: 35
Validation State: unverified
Task: Aggregate
Announcement bits (2): 0-KRT 1-BGP_RT_Background
AS path: I (LocalAgg)
Flags: Depth: 0 Active
AS path list:
AS path: I Refcount: 1
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