Protocol Independent Routing · Topic 1 of 4

Static, Aggregate and Generated Routes and Martian Addresses

Learn Junos static, aggregate and generated routes, their preferences and next hops, martian addresses and how to check them with show route for JN0-352.

  • 6 min
In a nutshell
  • Static preference is 5. Aggregate and generated preference is 130.
  • Aggregates and generated routes need an active contributing route.
  • Aggregate default next hop is reject; discard can be configured. A generated route uses the contributor's next hop.

What it is

Junos OS lets you create three kinds of routes by hand, under [edit routing-options]. A static route points a prefix at a next hop you choose. An aggregate route summarizes many more specific routes. A generated route is a route that only exists while a more specific route exists, and it forwards like that route.

Martian addresses are the opposite idea: prefixes the router ignores when a routing protocol offers them, because they are not valid destinations on a network.

Configured routeneeds reachable next hopStatic routepreference 5Contributing routemust existAggregate or generated routepreference 130Routing protocol updatematches martian listRoute ignored

How it works

Static routes

A static route has a prefix and a next hop, and it is installed in inet.0 with preference 5. The next hop can be an IP address, an interface, or one of the special next hops discard and reject.

user@router# set routing-options static route 10.20.0.0/16 next-hop 192.168.1.2
user@router# set routing-options static route 0.0.0.0/0 next-hop 192.168.1.1
user@router# set routing-options static route 172.16.0.0/12 discard

The IP next hop must be reachable through a route the router already has, such as a directly connected subnet. If it is not, the static route is not active.

OptionEffect
discardDrop matching packets silently
rejectDrop matching packets and send an ICMP unreachable message
preferenceChange the route preference from 5 (a higher number is less preferred)
qualified-next-hopGive one next hop its own preference, for a backup path
no-readvertiseDo not offer the route to other routing protocols
next-tableLook the destination up again in another routing table

A floating static route is a backup that loses while the primary route exists. Give the backup a higher preference number:

user@router# set routing-options static route 0.0.0.0/0 next-hop 192.168.1.1
user@router# set routing-options static route 0.0.0.0/0 qualified-next-hop 192.168.2.1 preference 10

Aggregate routes

An aggregate route is created with routing-options aggregate route. It is installed with preference 130, and its default next hop is reject, so traffic that matches only the aggregate is dropped with an ICMP unreachable.

user@router# set routing-options aggregate route 10.0.0.0/8
user@router# set routing-options aggregate route 10.0.0.0/8 discard

The aggregate becomes active only while at least one contributing route exists. A contributing route is an active route whose prefix falls inside the aggregate and is more specific than it. With no contributor, the aggregate disappears from the table. A policy on the aggregate (policy) can restrict which routes count as contributors.

Generated routes

A generated route uses routing-options generate route. It also has preference 130 and also needs a contributing route, but its next hop is not reject. It takes the next hop of the best contributing route, so it forwards traffic.

user@router# set routing-options generate route 0.0.0.0/0 policy HAS-UPSTREAM

Generated routes are used to create a default route that is advertised only while a real route exists, for example a default route that depends on a customer prefix being reachable.

StaticAggregateGenerated
Hierarchystatic routeaggregate routegenerate route
Preference5130130
Needs a contributorNoYesYes
Default next hopThe one configuredRejectNext hop of best contributor
Shown in show route asStaticAggregateAggregate

Martian addresses

Martians are prefixes Junos refuses to install when a routing protocol learns them. By default the IPv4 martians include 0.0.0.0/8, 127.0.0.0/8, 192.0.0.0/24 and 240.0.0.0/4, each matched as orlonger, and some multicast ranges. The default route 0.0.0.0/0 exactly is allowed.

user@router# set routing-options martians 10.255.0.0/16 orlonger
user@router# set routing-options martians 240.0.0.0/4 orlonger allow

The first line adds your own martian. The second removes a default martian from the list with the allow keyword; delete alone cannot remove a built-in entry. Match types are exact, longer, orlonger, upto, prefix-length-range and through.

Monitoring and troubleshooting

user@router> show route protocol static
inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

0.0.0.0/0          *[Static/5] 00:10:12
                    >  to 192.168.1.1 via ge-0/0/0.0

user@router> show route protocol aggregate
10.0.0.0/8         *[Aggregate/130] 00:01:30
                       Reject

user@router> show route 10.0.0.0/8 exact detail
user@router> show route martians

If a static route is missing from the table, check that its next hop is resolvable, that a more preferred route for the same prefix does not exist, and that show route hidden does not list it.

Exam tip

To see why a route is not used, compare show route <prefix> exact detail with show route hidden. The detail output lists the preference of every candidate route for the prefix.

Common mistakes

Expecting an aggregate to forward traffic. Its default next hop is reject. Traffic matching only the aggregate is dropped; more specific contributors forward everything else.

Using an aggregate when a generated route is needed. An aggregate cannot give you a default route that points at a real next hop. A generated route inherits the next hop of its contributor.

Pointing a static route at an unreachable next hop. The route is not active until a route exists to reach the next hop.

Trying to delete a default martian. Use the allow keyword instead.

Watch out

A floating static route with the same preference as the primary is not a backup. Both are equal cost candidates, so give the backup a higher preference number.

What to remember for the exam

  • Static preference is 5. Aggregate and generated preference is 130.
  • Aggregates and generated routes need an active contributing route.
  • Aggregate default next hop is reject; discard can be configured. A generated route uses the contributor's next hop.
  • discard drops silently; reject drops and sends ICMP unreachable.
  • qualified-next-hop with a higher preference makes a floating backup.
  • Martians are ignored when learned from a routing protocol. Use martians ... allow to permit a default martian.
  • show route protocol static, show route protocol aggregate and show route martians are the check commands. Generated routes also appear with the protocol name Aggregate.

Check yourself

  • An aggregate 10.0.0.0/8 is configured but no 10.x.x.x routes exist in the table. Is the aggregate in inet.0?

    No, an aggregate is active only while at least one contributing route exists.

  • What is the difference between the next hop of an aggregate route and a generated route by default?

    An aggregate defaults to reject, while a generated route takes the next hop of its best contributing route.

  • How do you make a second default route a backup that is used only when the first fails?

    Give it a higher preference number than the primary, for example with qualified-next-hop and preference 10, because the default static preference is 5.

Topic 1 of 4 in Protocol Independent Routing

Test yourself on Protocol Independent Routing

The full Juniper JNCIS-ENT JN0-352 question bank has 846 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.