| 1 |
.TH ROUTE 8 "2025-09-10" "net\-tools" "Linux System Administrator's Manual" |
| 2 |
|
| 3 |
.SH NAME |
| 4 |
route \- show / manipulate the routing table |
| 5 |
|
| 6 |
.SH SYNOPSIS |
| 7 |
.SY route |
| 8 |
.RB [ \-CFvnNee ] |
| 9 |
.RB [ \-A |
| 10 |
.I Family |
| 11 |
.RB | \-4 | \-6 ] |
| 12 |
|
| 13 |
.P |
| 14 |
.SY route |
| 15 |
.RB [ \-v ] |
| 16 |
.RB [ \-A |
| 17 |
.I Family |
| 18 |
.RB | \-4 | \-6 ] |
| 19 |
.B add |
| 20 |
.RB [ \-net | \-host ] |
| 21 |
.I Target |
| 22 |
.RB [ netmask |
| 23 |
.IR Nm ] |
| 24 |
.RB [ gw |
| 25 |
.IR Gw ] |
| 26 |
.RB [ metric |
| 27 |
.IR N ] |
| 28 |
.RB [ mss |
| 29 |
.IR M ] |
| 30 |
.RB [ window |
| 31 |
.IR W ] |
| 32 |
.RB [ irtt |
| 33 |
.IR I ] |
| 34 |
.RB [ reject ] |
| 35 |
.RB [ mod ] |
| 36 |
.RB [ dyn ] |
| 37 |
.RB [ reinstate ] |
| 38 |
.RB [[ dev ] |
| 39 |
.IR If ] |
| 40 |
|
| 41 |
.P |
| 42 |
.SY route |
| 43 |
.RB [ \-v ] |
| 44 |
.RB [ \-A |
| 45 |
.I Family |
| 46 |
.RB | \-4 | \-6 ] |
| 47 |
.B del |
| 48 |
.RB [ \-net | \-host ] |
| 49 |
.I Target |
| 50 |
.RB [ gw |
| 51 |
.IR Gw ] |
| 52 |
.RB [ netmask |
| 53 |
.IR Nm ] |
| 54 |
.RB [ metric |
| 55 |
.IR M ] |
| 56 |
.RB [[ dev ] |
| 57 |
.IR If ] |
| 58 |
|
| 59 |
.P |
| 60 |
.SY route |
| 61 |
.RB [ \-V ] |
| 62 |
.RB [ \-\-version ] |
| 63 |
.RB [ \-h ] |
| 64 |
.RB [ \-\-help ] |
| 65 |
|
| 66 |
.SH DESCRIPTION |
| 67 |
.B Route |
| 68 |
manipulates the kernel's routing tables. |
| 69 |
Its primary use is to set up static routes to specific hosts or |
| 70 |
networks via an interface after it has been configured with the |
| 71 |
.BR ifconfig (8) |
| 72 |
program. |
| 73 |
|
| 74 |
When the |
| 75 |
.B add |
| 76 |
or |
| 77 |
.B del |
| 78 |
options are used, |
| 79 |
.B route |
| 80 |
modifies the routing tables. Without these options, |
| 81 |
.B route |
| 82 |
displays the current contents of the routing tables. |
| 83 |
|
| 84 |
.SH OPTIONS |
| 85 |
.TP |
| 86 |
\fB\-A\fP \fIFamily\fP |
| 87 |
use the specified address family (eg `inet'). Use |
| 88 |
.B route \-\-help |
| 89 |
for a full list. |
| 90 |
.br |
| 91 |
You can use |
| 92 |
.B \-6 |
| 93 |
as an alias for |
| 94 |
.B \-\-inet6 |
| 95 |
and |
| 96 |
.B \-4 |
| 97 |
as an alias for |
| 98 |
.BR "\-A inet" . |
| 99 |
|
| 100 |
.TP |
| 101 |
.B \-F |
| 102 |
operate on the kernel's FIB (Forwarding Information Base) routing table. |
| 103 |
This is the default. |
| 104 |
.TP |
| 105 |
.B \-C |
| 106 |
operate on the kernel's routing cache. (This is no longer available.) |
| 107 |
.TP |
| 108 |
.B \-v |
| 109 |
select verbose operation. |
| 110 |
.TP |
| 111 |
.B \-n |
| 112 |
show numerical addresses instead of trying to determine symbolic host |
| 113 |
names. This is useful if you are trying to determine why the route to your |
| 114 |
nameserver has vanished. |
| 115 |
.TP |
| 116 |
.B \-e |
| 117 |
use |
| 118 |
.BR netstat (8)\-format |
| 119 |
for displaying the routing table. |
| 120 |
.B \-ee |
| 121 |
will generate a very long line with all parameters from the routing table. |
| 122 |
.TP |
| 123 |
.B del |
| 124 |
delete a route. |
| 125 |
.TP |
| 126 |
.B add |
| 127 |
add a new route. |
| 128 |
.TP |
| 129 |
.I Target |
| 130 |
the destination network or host. You can provide an addresses or symbolic |
| 131 |
network or host name. Optionally you can use \fB/\fIprefixlen\fR notation |
| 132 |
instead of using the \fBnetmask\fR option. |
| 133 |
.TP |
| 134 |
.B \-net |
| 135 |
the |
| 136 |
.I Target |
| 137 |
is a network. |
| 138 |
.TP |
| 139 |
.B \-host |
| 140 |
the |
| 141 |
.I Target |
| 142 |
is a host. |
| 143 |
.TP |
| 144 |
\fBnetmask\fP \fINm\fP |
| 145 |
when adding a network route, the netmask |
| 146 |
.I Nm |
| 147 |
to be used. |
| 148 |
.TP |
| 149 |
\fBgw\fP \fIGW\fP |
| 150 |
route packets via a gateway |
| 151 |
.IR Gw . |
| 152 |
|
| 153 |
.B NOTE: |
| 154 |
The specified gateway must be reachable first. This usually means that |
| 155 |
you have to set up a static route to the gateway beforehand. If you specify |
| 156 |
the address of one of your local interfaces, it will be used to decide about |
| 157 |
the interface to which the packets should be routed to. This is a BSDism |
| 158 |
compatibility hack. |
| 159 |
.TP |
| 160 |
\fBmetric\fP \fIN\fP |
| 161 |
set the metric field in the routing table (used by routing daemons) |
| 162 |
to \fIN\fR. |
| 163 |
If this option is not specified the metric for inet6 (IPv6) address family |
| 164 |
defaults to '1', for inet (IPv4) it defaults to '0'. |
| 165 |
You should always specify an explicit metric value to not rely on those defaults |
| 166 |
- they also differ from iproute2. |
| 167 |
.TP |
| 168 |
\fBmss\fP \fIM\fP |
| 169 |
sets MTU (Maximum Transmission Unit) of the route to \fIM\fR bytes. |
| 170 |
Note that the current implementation of the route command does not allow |
| 171 |
the option to set the Maximum Segment Size (MSS). |
| 172 |
.TP |
| 173 |
\fBwindow\fP \fIW\fP |
| 174 |
set the TCP window size for connections over this route to \fIW\fR |
| 175 |
bytes. This is typically only used on AX.25 networks and with drivers |
| 176 |
unable to handle back to back frames. |
| 177 |
.TP |
| 178 |
\fBirtt\fP \fII\fP |
| 179 |
set the initial round trip time (irtt) for TCP connections over this |
| 180 |
route to \fII\fR milliseconds (1-12000). This is typically only used on |
| 181 |
AX.25 networks. If omitted the RFC 1122 default of 300ms is used. |
| 182 |
.TP |
| 183 |
.B reject |
| 184 |
install a blocking route, which will force a route lookup to fail. |
| 185 |
This is for example used to mask out networks before using the default |
| 186 |
route. This is NOT for firewalling. |
| 187 |
.TP |
| 188 |
.BR mod ", " dyn ", " reinstate |
| 189 |
install a dynamic or modified route. These flags are for diagnostic |
| 190 |
purposes, and are generally only set by routing daemons. |
| 191 |
.TP |
| 192 |
\fBdev\fP \fIIf\fP |
| 193 |
force the route to be associated with the specified device, as the |
| 194 |
kernel will otherwise try to determine the device on its own (by |
| 195 |
checking already existing routes and device specifications, and where |
| 196 |
the route is added to). In most normal networks you won't need this. |
| 197 |
|
| 198 |
If \fIIf\fP is the last option on the command line, the word |
| 199 |
.B dev |
| 200 |
may be omitted, as it's the default. |
| 201 |
Otherwise the order of the route modifiers |
| 202 |
(\fBmetric netmask gw dev\fR) doesn't matter. |
| 203 |
|
| 204 |
.SH EXAMPLES |
| 205 |
.TP |
| 206 |
.B route add \-net 127.0.0.0 netmask 255.0.0.0 metric 1024 dev lo |
| 207 |
adds the normal loopback entry, using netmask 255.0.0.0 and associated with the |
| 208 |
"lo" device (assuming this device was previously set up correctly with |
| 209 |
.BR ifconfig (8)). |
| 210 |
|
| 211 |
.TP |
| 212 |
.B route add \-net 192.56.76.0 netmask 255.255.255.0 metric 1024 dev eth0 |
| 213 |
adds a route to the local network 192.56.76.x via |
| 214 |
"eth0". The word "dev" can be omitted here. |
| 215 |
|
| 216 |
.TP |
| 217 |
.B route del default |
| 218 |
deletes the current default route, which is labeled "default" or 0.0.0.0 |
| 219 |
in the destination field of the current routing table. |
| 220 |
|
| 221 |
.TP |
| 222 |
.B route del \-net 192.56.76.0 netmask 255.255.255.0 |
| 223 |
deletes the route. Since the Linux routing kernel uses classless |
| 224 |
addressing, you pretty much always have to specify the netmask that is |
| 225 |
same as as seen in 'route -n' listing. |
| 226 |
|
| 227 |
.TP |
| 228 |
.B route add default gw mango |
| 229 |
adds a default route (which will be used if no other route matches). |
| 230 |
All packets using this route will be gatewayed through the address of a node |
| 231 |
named "mango". The |
| 232 |
device which will actually be used for that route depends on how we |
| 233 |
can reach "mango" - "mango" must be on directly reachable route. |
| 234 |
|
| 235 |
.TP |
| 236 |
.B route add mango sl0 |
| 237 |
Adds the route to the host named "mango" via the SLIP interface (assuming that |
| 238 |
"mango" is the SLIP host). |
| 239 |
|
| 240 |
.TP |
| 241 |
.B route add \-net 192.57.66.0 netmask 255.255.255.0 gw mango |
| 242 |
This command adds the net "192.57.66.x" to be gatewayed through the former |
| 243 |
route to the SLIP interface. |
| 244 |
|
| 245 |
.TP |
| 246 |
.B route add \-net 224.0.0.0 netmask 240.0.0.0 dev eth0 |
| 247 |
This is an obscure one documented so people know how to do it. This sets |
| 248 |
all of the class D (multicast) IP routes to go via "eth0". This is the |
| 249 |
correct normal configuration line with a multicasting kernel. |
| 250 |
|
| 251 |
.TP |
| 252 |
.B route add \-net 10.0.0.0 netmask 255.0.0.0 metric 1024 reject |
| 253 |
This installs a rejecting route for the private network "10.x.x.x." |
| 254 |
|
| 255 |
.TP |
| 256 |
.B route -6 add 2001:0002::/48 metric 1 dev eth0 |
| 257 |
This adds a IPv6 route with the specified metric to be directly reachable via |
| 258 |
eth0. |
| 259 |
|
| 260 |
.SH OUTPUT |
| 261 |
The output of the kernel routing table is organized in the following columns |
| 262 |
.TP |
| 263 |
.B Destination |
| 264 |
The destination network or destination host. |
| 265 |
.TP |
| 266 |
.B Gateway |
| 267 |
The gateway address or '*' if none set. |
| 268 |
.TP |
| 269 |
.B Genmask |
| 270 |
The netmask for the destination net; '255.255.255.255' for a host destination |
| 271 |
and '0.0.0.0' for the |
| 272 |
.B default |
| 273 |
route. |
| 274 |
.TP |
| 275 |
.B Flags |
| 276 |
Possible flags include |
| 277 |
.br |
| 278 |
.B U |
| 279 |
(route is |
| 280 |
.BR up ) |
| 281 |
.br |
| 282 |
.B H |
| 283 |
(target is a |
| 284 |
.BR host ) |
| 285 |
.br |
| 286 |
.B G |
| 287 |
(use |
| 288 |
.BR gateway ) |
| 289 |
.br |
| 290 |
.B R |
| 291 |
.RB ( reinstate |
| 292 |
route for dynamic routing) |
| 293 |
.br |
| 294 |
.B D |
| 295 |
.RB ( dynamically |
| 296 |
installed by daemon or redirect) |
| 297 |
.br |
| 298 |
.B M |
| 299 |
.RB ( modified |
| 300 |
from routing daemon or redirect) |
| 301 |
.br |
| 302 |
.B A |
| 303 |
(installed by |
| 304 |
.BR addrconf ) |
| 305 |
.br |
| 306 |
.B C |
| 307 |
.RB ( cache |
| 308 |
entry) |
| 309 |
.br |
| 310 |
.B ! |
| 311 |
.RB ( reject |
| 312 |
route) |
| 313 |
.br |
| 314 |
.TP |
| 315 |
.B Metric |
| 316 |
The 'distance' to the target (usually counted in hops). |
| 317 |
.TP |
| 318 |
.B Ref |
| 319 |
Number of references to this route. (Not used in the Linux kernel.) |
| 320 |
.TP |
| 321 |
.B Use |
| 322 |
Count of lookups for the route. Depending on the use of \-F and \-C this will |
| 323 |
be either route cache misses (\-F) or hits (\-C). |
| 324 |
.TP |
| 325 |
.B Iface |
| 326 |
Interface to which packets for this route will be sent. |
| 327 |
.TP |
| 328 |
.B MSS |
| 329 |
Default maximum segment size for TCP connections over this route. |
| 330 |
.TP |
| 331 |
.B Window |
| 332 |
Default window size for TCP connections over this route. |
| 333 |
.TP |
| 334 |
.B irtt |
| 335 |
Initial RTT (Round Trip Time). The kernel uses this to guess about the best |
| 336 |
TCP protocol parameters without waiting on (possibly slow) answers. |
| 337 |
.TP |
| 338 |
.BR HH " (cached only)" |
| 339 |
The number of ARP entries and cached routes that refer to the hardware |
| 340 |
header cache for the cached route. This will be \-1 if a hardware |
| 341 |
address is not needed for the interface of the cached route (e.g. lo). |
| 342 |
.TP |
| 343 |
.BR Arp " (cached only)" |
| 344 |
Whether or not the hardware address for the cached route is up to date. |
| 345 |
|
| 346 |
.SH FILES |
| 347 |
.I /proc/net/ipv6_route |
| 348 |
.br |
| 349 |
.I /proc/net/route |
| 350 |
.br |
| 351 |
.I /proc/net/rt_cache |
| 352 |
|
| 353 |
.SH HISTORY |
| 354 |
.B Route |
| 355 |
for Linux was originally written by Fred N. van Kempen, |
| 356 |
<[email protected]> and then modified by Johannes Stille and |
| 357 |
Linus Torvalds for pl15. Alan Cox added the mss and window options for |
| 358 |
Linux 1.1.22. irtt support and merged with netstat from Bernd Eckenfels. |
| 359 |
|
| 360 |
With the introduction of the netlink kernel interface this |
| 361 |
tool is mostly superseded by the \fBip route\fP command. |
| 362 |
|
| 363 |
.SH "SEE ALSO" |
| 364 |
Homepage of the \fInet\-tools\fP project: |
| 365 |
.UR https://net-tools.sourceforge.io |
| 366 |
.UE |
| 367 |
|
| 368 |
.P |
| 369 |
.BR arp (8), |
| 370 |
.BR ifconfig (8), |
| 371 |
.BR netstat (8), |
| 372 |
.BR ip-route (8) |
| 373 |
.br |
| 374 |
.BR ethers (5), |
| 375 |
.BR rtnetlink (7), |
| 376 |
.BR netplan (5) |
| 377 |
|
| 378 |
.SH AUTHOR |
| 379 |
Currently maintained by |
| 380 |
.br |
| 381 |
Phil Blundell <[email protected]>, |
| 382 |
.br |
| 383 |
Bernd Eckenfels <net\[email protected]>. |