]> git.proxmox.com Git - mirror_frr.git/blame - doc/user/static.rst
Merge pull request #12571 from Shikugawa/ospfd-json
[mirror_frr.git] / doc / user / static.rst
CommitLineData
614aa5c1
DS
1.. _static:
2
3******
4STATIC
5******
6
7:abbr:`STATIC` is a daemon that handles the installation and deletion
8of static routes.
9
10.. _starting-static:
11
4c97fd1a 12Starting STATIC
614aa5c1
DS
13===============
14
15Default configuration file for *staticd* is :file:`staticd.conf`. The typical
16location of :file:`staticd.conf` is |INSTALL_PREFIX_ETC|/staticd.conf.
17
18If the user is using integrated config, then :file:`staticd.conf` need not be
19present and the :file:`frr.conf` is read instead.
20
21If the user has not fully upgraded to using the staticd.conf and still has
22a non-integrated config with zebra.conf holding the static routes, *staticd*
23will read in the :file:`zebrad.conf` as a backup.
24
25.. program:: staticd
26
27:abbr:`STATIC` supports all the common FRR daemon start options which are
28documented elsewhere.
29
30.. _static-route-commands:
31
32Static Route Commands
33=====================
34
35Static routing is a very fundamental feature of routing technology. It defines
beaa0727 36a static prefix and gateway, with several possible forms.
614aa5c1 37
beaa0727 38.. clicmd:: ip route NETWORK GATEWAY [DISTANCE] [table TABLENO] [nexthop-vrf VRFNAME] [vrf VRFNAME]
614aa5c1 39
beaa0727
BJ
40.. clicmd:: ip route NETWORK IFNAME [DISTANCE] [table TABLENO] [nexthop-vrf VRFNAME] [vrf VRFNAME]
41
42.. clicmd:: ip route NETWORK GATEWAY IFNAME [DISTANCE] [onlink] [table TABLENO] [nexthop-vrf VRFNAME] [vrf VRFNAME]
43
44.. clicmd:: ip route NETWORK (Null0|blackhole|reject) [DISTANCE] [table TABLENO] [nexthop-vrf VRFNAME] [vrf VRFNAME]
45
46.. clicmd:: ipv6 route NETWORK [from SRCPREFIX] GATEWAY [DISTANCE] [table TABLENO] [nexthop-vrf VRFNAME] [vrf VRFNAME]
47
48.. clicmd:: ipv6 route NETWORK [from SRCPREFIX] IFNAME [DISTANCE] [table TABLENO] [nexthop-vrf VRFNAME] [vrf VRFNAME]
49
50.. clicmd:: ipv6 route NETWORK [from SRCPREFIX] GATEWAY IFNAME [DISTANCE] [onlink] [table TABLENO] [nexthop-vrf VRFNAME] [vrf VRFNAME]
51
52.. clicmd:: ipv6 route NETWORK [from SRCPREFIX] (Null0|blackhole|reject) [DISTANCE] [table TABLENO] [nexthop-vrf VRFNAME] [vrf VRFNAME]
614aa5c1
DS
53
54 NETWORK is destination prefix with a valid v4 or v6 network based upon
beaa0727
BJ
55 initial form of the command.
56
57 GATEWAY is the IP address to use as next-hop for the prefix. Currently, it must match
58 the v4 or v6 route type specified at the start of the command.
59
60 IFNAME is the name of the interface to use as next-hop. If only IFNAME is specified
61 (without GATEWAY), a connected route will be created.
62
63 When both IFNAME and GATEWAY are specified together, it binds the route to the specified
64 interface. In this case, it is also possible to specify ``onlink`` to force the kernel
65 to consider the next-hop as "on link" on the given interface.
66
67 Alternatively, the gateway can be specified as ``Null0`` or ``blackhole`` to create a blackhole
68 route that drops all traffic. It can also be specified as ``reject`` to create an unreachable
69 route that rejects traffic with ICMP "Destination Unreachable" messages.
70
71 TABLENO is an optional parameter for namespaces that allows you to create the
72 route in a specified table associated with the vrf namespace. ``table`` will
73 be rejected if you are not using namespace based vrfs.
74
75 ``vrf`` VRFNAME allows you to create the route in a specified vrf.
76
77 ``nexthop-vrf`` VRFNAME allows you to create a leaked route with a nexthop in the
78 specified VRFNAME. ``nexthop-vrf`` cannot be currently used with namespace based vrfs.
79
80 The IPv6 variant allows the installation of a static source-specific route
614aa5c1
DS
81 with the SRCPREFIX sub command. These routes are currently supported
82 on Linux operating systems only, and perform AND matching on packet's
83 destination and source addresses in the kernel's forwarding path. Note
84 that destination longest-prefix match is "more important" than source
85 LPM, e.g. ``2001:db8:1::/64 from 2001:db8::/48`` will win over
86 ``2001:db8::/48 from 2001:db8:1::/64`` if both match.
87
88.. _multiple-route-command:
89
90Multiple nexthop static route
91=============================
92
93To create multiple nexthops to the same NETWORK, just reenter the same
94network statement with different nexthop information.
95
96.. code-block:: frr
97
98 ip route 10.0.0.1/32 10.0.0.2
99 ip route 10.0.0.1/32 10.0.0.3
100 ip route 10.0.0.1/32 eth0
101
102
103If there is no route to 10.0.0.2 and 10.0.0.3, and interface eth0
104is reachable, then the last route is installed into the kernel.
105
106If zebra has been compiled with multipath support, and both 10.0.0.2 and
10710.0.0.3 are reachable, zebra will install a multipath route via both
108nexthops, if the platform supports this.
109
110::
111
112 router> show ip route
113 S> 10.0.0.1/32 [1/0] via 10.0.0.2 inactive
114 via 10.0.0.3 inactive
115 * is directly connected, eth0
116
117
118.. code-block:: frr
119
120 ip route 10.0.0.0/8 10.0.0.2
121 ip route 10.0.0.0/8 10.0.0.3
122 ip route 10.0.0.0/8 null0 255
123
124
125This will install a multihop route via the specified next-hops if they are
126reachable, as well as a high-distance blackhole route, which can be useful to
127prevent traffic destined for a prefix to match less-specific routes (e.g.
128default) should the specified gateways not be reachable. E.g.:
129
130::
131
132 router> show ip route 10.0.0.0/8
133 Routing entry for 10.0.0.0/8
134 Known via "static", distance 1, metric 0
135 10.0.0.2 inactive
136 10.0.0.3 inactive
137
138 Routing entry for 10.0.0.0/8
139 Known via "static", distance 255, metric 0
140 directly connected, Null0
141
142Also, if the user wants to configure a static route for a specific VRF, then
143a specific VRF configuration mode is available. After entering into that mode
144with :clicmd:`vrf VRF` the user can enter the same route command as before,
145but this time, the route command will apply to the VRF.
146
147.. code-block:: frr
148
149 # case with VRF
982589a3 150 configure
614aa5c1
DS
151 vrf r1-cust1
152 ip route 10.0.0.0/24 10.0.0.2
153 exit-vrf
154
065276ae
SM
155
156SR-TE Route Commands
157====================
158
159It is possible to specify a route using a SR-TE policy configured in Zebra.
160
161e.g. to use the SR-TE policy with endpoint 6.6.6.6 and color 123 to reach the
162network 9.9.9.9/24:
163
164.. code-block:: frr
165
166 ip route 9.9.9.9/24 6.6.6.6 color 123