i like to create a policy for the conditional advertisement of default route to a bgp customer i.e. the default routes (0.0.0.0/0) only advertised if another route (say 1.1.0.0/16) presents. Following are two ways which comes into my mind and appreciate if one can provide your feedback if the following can fullfill the requirement. If both can work than which one could be the recommended one.
Thanks
-------------------------------
---- OPTION 1 -----------------
-------------------------------
[edit routing-options]
aggregate {
route 1.1.0.0/16;
}
generate {
route 0.0.0.0/0 discard;
}
[edit policy-options]
policy-statement bgpcust-default-out {
term 10 {
from {
route-filter 0.0.0.0/0 exact;
route-filter 1.1.0.0/16 exact;
}
then {
community delete all;
accept;
}
}
}
community all members *:*;
[edit protocols bgp]
group External {
neighbor 99.99.99.1 {
export bgpcust-default-out;
peer-as 65100;
}
}
-------------------------------
---- OPTION 2 -----------------
-------------------------------
[edit routing-options]
generate {
route 0.0.0.0/0 {
policy if-default-network-exists;
discard;
}
}
[edit policy-options]
policy-statement if-default-network-exists {
term DEFAULT_ROUTE {
from {
route-filter 1.1.0.0/16 exact;
}
then accept;
}
term reject-all-other-routes {
then reject;
}
}
policy-statement bgpcust-defaultroute-out {
term 1 {
from {
route-filter 0.0.0.0/0 exact;
}
then {
community delete all;
accept;
}
}
}
community all members *:*;
[edit protocols bgp]
group External {
neighbor 100.100.100.1 {
export bgpcust-defaultroute-out;
peer-as 65100;
}
}