Protocol-Independent Routing · Topic 1 of 4

Static Routes and Martian Addresses

Learn Junos static routes for the JN0-364: next-hop, qualified-next-hop, resolve, discard and reject, preference 5, martian addresses and show route.

  • 6 min
In a nutshell
  • Static route default preference is 5; direct is 0.
  • Configure with set routing-options static route <prefix> next-hop <address>; IPv6 under rib inet6.0 static.
  • The next hop must be directly connected unless you add resolve.

What it is

A static route is a route you configure by hand under [edit routing-options]. It has a default route preference of 5, so it beats every dynamic protocol but loses to a direct route (preference 0).

Martian addresses are prefixes Junos treats as invalid. Routes to martian prefixes are ignored: a protocol that learns one does not install it, and you cannot use a martian address as a normal route.

Static route configurednext hop reachableActivepreference 5Static route configurednext hop not connectedNot installednot usedLearned routemartian prefixIgnored

How it works

Basic static routes

IPv4 static routes go in inet.0 by default. IPv6 static routes need the rib inet6.0 level.

user@router# set routing-options static route 0.0.0.0/0 next-hop 192.0.2.1
user@router# set routing-options static route 10.20.0.0/16 next-hop 172.16.1.2
user@router# set routing-options rib inet6.0 static route ::/0 next-hop 2001:db8:1::1

In hierarchy form:

routing-options {
    static {
        route 0.0.0.0/0 next-hop 192.0.2.1;
        route 10.20.0.0/16 next-hop 172.16.1.2;
    }
}

By default the next hop must be on a directly connected subnet. If it is not, the route stays inactive. Add resolve to let Junos look up a remote next hop recursively in the routing table, which is how you point a static route at a loopback address learned through an IGP.

user@router# set routing-options static route 10.30.0.0/16 next-hop 10.255.0.5 resolve

Next-hop types

OptionEffect
next-hop <address>Forward to that gateway
next-hop <interface>Forward out a point-to-point interface
discardDrop silently, no ICMP message
rejectDrop and send ICMP unreachable
receiveSend the packet to the Routing Engine
next-table <table>Look up the destination again in another table

discard is often used for a null route that anchors a prefix you advertise in BGP.

Qualified next hops and floating static routes

A qualified next hop carries its own preference or metric. The best next hop is used, and the other takes over only if the first one fails. This gives a backup path within one static route.

user@router# set routing-options static route 0.0.0.0/0 next-hop 192.0.2.1
user@router# set routing-options static route 0.0.0.0/0 qualified-next-hop 198.51.100.1 preference 7

The main next hop uses preference 5, so it wins. If 192.0.2.1 becomes unreachable, the qualified next hop with preference 7 becomes active.

A floating static route is a static route with a preference higher than the dynamic route it backs up. For example, preference 200 loses to OSPF (10 internal, 150 external) and to BGP (170), so it is only used when the dynamic route disappears.

Other useful static options

OptionMeaning
preference <n>Change the default of 5
metric <n>Set the route metric, used to rank routes with equal preference
no-readvertiseStop export policies from advertising the route
retainKeep the route in the forwarding table when the routing process shuts down; the default is no-retain
tag, communityAdd values that routing policy can match

Static routes are not advertised by any protocol on their own. You need an export policy with from protocol static in OSPF, IS-IS or BGP.

Martian addresses

Junos keeps a martian list per routing table. View it with show route martians. The default IPv4 list includes ranges such as 0.0.0.0/8, 127.0.0.0/8 and the Class E range 240.0.0.0/4, each marked orlonger -- disallowed. The exact default list depends on the release, so check it on the router.

user@router> show route martians table inet.0

inet.0:
             0.0.0.0/0 exact -- allowed
             0.0.0.0/8 orlonger -- disallowed
             127.0.0.0/8 orlonger -- disallowed
             240.0.0.0/4 orlonger -- disallowed
...

You add your own martians, or allow a default one, under routing-options martians:

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

The first line stops any route inside 192.168.0.0/16 from being accepted in inet.0. The second removes Class E from the martian list. Martians for another table go under that table's own rib or routing instance.

Verifying static routes

user@router> show route protocol static

inet.0: 12 destinations, 12 routes (12 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

0.0.0.0/0          *[Static/5] 00:12:41
                    >  to 192.0.2.1 via ge-0/0/0.0
10.20.0.0/16       *[Static/5] 00:12:41
                    >  to 172.16.1.2 via ge-0/0/1.0
CommandUse
show route protocol staticAll static routes and their state
show route 10.20.0.0/16 exact detailPreference, next hop and why a route is active or not
show route hiddenRoutes that exist but cannot be used, for example an unresolved next hop
show route forwarding-table destination 10.20.0.0What the Packet Forwarding Engine really uses
Exam tip

A static route that is missing from show route protocol static usually has a next hop that is not directly connected and no resolve statement. Check that a direct route to the next hop exists.

Common mistakes

Using a remote next hop without resolve. The route never becomes active, because by default the next hop must be on a connected subnet.

Expecting static routes to be advertised. OSPF, IS-IS and BGP do not send static routes unless an export policy accepts them.

Mixing up discard and reject. Both drop traffic. Only reject sends an ICMP unreachable back.

Watch out

A floating static route needs a preference higher than the route it backs up. Setting preference 1 on a backup route makes it beat everything except direct routes, so it takes over at once.

What to remember for the exam

  • Static route default preference is 5; direct is 0.
  • Configure with set routing-options static route <prefix> next-hop <address>; IPv6 under rib inet6.0 static.
  • The next hop must be directly connected unless you add resolve.
  • qualified-next-hop <address> preference <n> gives a backup next hop inside one static route.
  • discard drops silently; reject drops and sends ICMP unreachable.
  • Static routes need an export policy to be advertised by any protocol.
  • Martian prefixes are ignored; view them with show route martians, change them with routing-options martians.
  • show route hidden lists routes that exist but are unusable, for example with an unusable next hop.

Check yourself

  • A static route points to 10.255.0.5, a loopback learned through OSPF, and stays inactive. What is missing?

    The resolve option, because by default a static next hop must be on a directly connected subnet.

  • A static route has next-hop 192.0.2.1 and qualified-next-hop 198.51.100.1 preference 7. Which next hop is used while both are reachable?

    192.0.2.1, because it keeps the default preference of 5, which is lower than 7.

  • Which command shows the prefixes that Junos treats as martian?

    show route martians, which lists the default and configured martian prefixes per table.

Topic 1 of 4 in Protocol-Independent Routing

Test yourself on Protocol-Independent Routing

The full Juniper JNCIS-SP JN0-364 question bank has 860 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.