ROUTE(8)
๐ ROUTE(8) ๐
route is the Linux System Administrator's Manual tool for showing and messing with the IP routing table ๐ . Okay, let's get into it, bestie ๐ฆ
โจ NAME โจ
route - show / manipulate the IP routing table
๐บ๏ธ SYNOPSIS ๐บ๏ธ
route [-CFvnNee] [-A family |-4|-6]
route [-v] [-A family |-4|-6] add [-net|-host] target [netmask Nm] [gw
Gw] [metric N] [mss M] [window W] [irtt I] [reject] [mod] [dyn]
[reinstate] [[dev] If]
route [-v] [-A family |-4|-6] del [-net|-host] target [gw Gw] [netmask
Nm] [metric M] [[dev] If]
route [-V] [--version] [-h] [--help]
๐ DESCRIPTION ๐
okay so route is the tool that touches the kernel's IP routing tables ๐ง. Its main job is setting up static routes to specific hosts or networks through an interface, but only after that interface has been configured with the ifconfig(8) program. Order matters, bestie ๐ซถ
When you use the add or del options, route actually changes the routing tables ๐ฅ. Without them, it just shows you what's currently in there, so no changes, just vibes ๐
๐ OPTIONS ๐
-A familyโ use the address family you pick (likeinet). Runroute --helpfor the full list of families ๐. You can use-6as a shortcut for--inet6, and-4as a shortcut for-A inetโจ-Fโ works on the kernel's FIB (Forwarding Information Base) routing table. This is the default, so you don't have to ask for it ๐-Cโ works on the kernel's routing cache instead ๐ฆ-vโ turns on verbose mode, so it talks your ear off ๐ฃ๏ธ-nโ shows numerical addresses instead of trying to figure out symbolic host names ๐ข. This is super useful if you're trying to find out why the route to your nameserver has vanished ๐ญ-eโ shows the table in netstat(8) format ๐.-eegoes even harder and prints one very long line with every single parameter from the routing table ๐delโ deletes a route ๐๏ธaddโ adds a brand new route ๐targetโ the destination network or host ๐ฏ. You can give it an address or a symbolic network or host name. You can also use /prefixlen notation instead of thenetmaskoption, which is very slay ๐-netโ tells route that the target is a network ๐-hostโ tells route that the target is a single host ๐งโโ๏ธnetmask NMโ when you're adding a network route, this is the netmask to use ๐ญgw GWโ routes packets through a gateway ๐ช
NOTE: the gateway you pick has to be reachable first ๐จ. This usually means you need to set up a static route to the gateway beforehand. If you give it the address of one of your own local interfaces, that interface gets used to decide where the packets go. This is a BSDism compatibility hack, so it's kinda a bit of a quirk ๐
metric Mโ sets the metric field in the routing table (the one routing daemons care about) toM๐. If you skip this, the metric defaults to1for the inet6 (IPv6) address family, and0for inet (IPv4). Honestly, always specify an explicit metric so you're not relying on those defaults ๐ค. They also differ from iproute2, so be warned ๐mss Mโ sets the MTU (Maximum Transmission Unit) of the route toMbytes ๐ฆ. Heads up though: the current route command can't actually set the Maximum Segment Size (MSS), even though this option exists ๐window Wโ sets the TCP window size for connections over this route toWbytes ๐ช. This is usually only used on AX.25 networks and with drivers that can't handle back to back frames ๐กirtt Iโ sets the initial round trip time (irtt) for TCP connections over this route toImilliseconds (1-12000) โฑ๏ธ. This is mostly an AX.25 thing too. If you leave it out, the RFC 1122 default of 300ms gets used ๐rejectโ installs a blocking route that forces route lookups to fail ๐ซ. This is handy for masking out networks before you use the default route, for example. This is NOT for firewalling, so don't even try ๐ โโ๏ธmod,dyn,reinstateโ install a modified, dynamic, or reinstated route ๐งช. These flags are for diagnostic purposes and are generally only set by routing daemons, so unless you're one of those, leave them alone ๐คdev Ifโ forces the route to be tied to the device you name ๐. Otherwise the kernel tries to figure out the device on its own, by checking existing routes and device specs and seeing where the route gets added. Most normal networks won't need this ๐ฅฐ
If dev If is the last thing on the command line, you can drop the word dev, since it's the default ๐
. Otherwise, the order of the route modifiers (metric, netmask, gw, dev) doesn't matter at all โจ
๐ง EXAMPLES ๐ง
- Adds the normal loopback entry:
route add -net 127.0.0.0 netmask 255.0.0.0 metric 1024 dev lo
Uses netmask 255.0.0.0 and ties it to the "lo" device (assuming you already set that up correctly with ifconfig(8)) ๐
- Adds a route to your local network via eth0:
route add -net 192.56.76.0 netmask 255.255.255.0 metric 1024 dev eth0
This adds a route to the local network 192.56.76.x via "eth0". The word "dev" can be left out here ๐
- Deletes the default route:
route del default
Deletes the current default route, which shows up as "default" or 0.0.0.0 in the destination field of the routing table ๐๏ธ
- Deletes a specific network route:
route del -net 192.56.76.0 netmask 255.255.255.0
Deletes the route. The Linux routing kernel uses classless addressing, so you pretty much always have to type the same netmask you see in the route -n listing ๐ง
- Adds a default route through a gateway named mango:
route add default gw mango
Adds a default route, which gets used when no other route matches ๐. All packets using this route get gatewayed through the address of a node named "mango". The device that actually gets used depends on how we can reach "mango", and "mango" has to be on a directly reachable route ๐ญ
- Adds a route to the host mango via the SLIP interface:
route add mango sl0
Adds the route to the host named "mango" via the SLIP interface (assuming "mango" is the SLIP host) ๐
- Gateways a network through the SLIP route:
route add -net 192.57.66.0 netmask 255.255.255.0 gw mango
This adds the net "192.57.66.x" and has it gatewayed through the former route to the SLIP interface ๐ช
- Sends all class D (multicast) routes through eth0:
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
This one is obscure, documented so people know how to do it ๐คซ. It sets all of the class D (multicast) IP routes to go via "eth0". This is the correct normal config line with a multicasting kernel ๐ก
- Installs a rejecting route for the private 10.x network:
route add -net 10.0.0.0 netmask 255.0.0.0 metric 1024 reject
This installs a rejecting route for the private network "10.x.x.x." ๐
- Adds an IPv6 route:
route -6 add 2001:0002::/48 metric 1 dev eth0
This adds an IPv6 route with the specified metric, directly reachable via eth0 ๐ธ
๐ OUTPUT ๐
okay the kernel routing table output comes in these columns ๐
Destinationโ the destination network or destination host ๐ฏGatewayโ the gateway address, or*if none is set ๐ชGenmaskโ the netmask for the destination net. It shows255.255.255.255for a host destination and0.0.0.0for the default route ๐ญFlagsโ possible flags include:U(route is up) ๐ขH(target is a host) ๐งโโ๏ธG(use gateway) ๐ชR(reinstate route for dynamic routing) ๐D(dynamically installed by daemon or redirect) โกM(modified from routing daemon or redirect) ๐งชA(installed by addrconf) ๐C(cache entry) ๐พ!(reject route) ๐ซ
Metricโ the 'distance' to the target, usually counted in hops ๐Refโ number of references to this route. (Not used in the Linux kernel, so it's just vibes ๐ซ )Useโ count of lookups for the route. Depending on whether you used-For-C, this is either route cache misses (-F) or hits (-C) ๐ฏIfaceโ the interface packets for this route get sent out of ๐คMSSโ default maximum segment size for TCP connections over this route ๐ฆWindowโ default window size for TCP connections over this route ๐ชirttโ initial RTT (Round Trip Time). The kernel uses this to guess the best TCP protocol parameters without waiting on (possibly slow) answers โฑ๏ธHH(cached only) โ the number of ARP entries and cached routes that refer to the hardware header cache for the cached route. It'll be-1if a hardware address isn't needed for that interface, likelo๐ขArp(cached only) โ whether or not the hardware address for the cached route is up to date ๐ฐ๏ธ
๐ FILES ๐
/proc/net/ipv6_route
/proc/net/route
/proc/net/rt_cache
๐ SEE ALSO ๐
ethers(5), arp(8), rarp(8), route(8), ifconfig(8), netstat(8) ๐ฆ
๐ HISTORY ๐
okay so Route for Linux was originally written by Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>, and then modified by Johannes Stille and Linus Torvalds for pl15. Alan Cox added the mss and window options for Linux 1.1.22 ๐. irtt support and the merge with netstat came from Bernd Eckenfels ๐
๐งโ๐ป AUTHOR ๐งโ๐ป
Currently maintained by Phil Blundell <Philip.Blundell@pobox.com> and Bernd Eckenfels <net-tools@lina.inka.de> ๐ซถ
Bestie, you now know everything about route ๐ Go route some packets and be iconic about it โจ net-tools, 2014-02-17 ๐ธ
๐ฆ where this page comes from
- alpine 3.22: net-tools-doc 2.10-r3 ยท GPL-2.0-or-later
- alpine 3.23: net-tools-doc 2.10-r3 ยท GPL-2.0-or-later
- alpine 3.24: net-tools-doc 2.10-r3 ยท GPL-2.0-or-later
- arch rolling: net-tools 2.10-3 ยท GPL2
- debian bookworm: net-tools 2.10-0.1+deb12u2 ยท GPL-2.0-or-later
- debian trixie: net-tools 2.10-1.3 ยท GPL-2.0-or-later
- nixpkgs unstable: net-tools 2.10
- opensuse-leap 16.0: net-tools-deprecated 2.10-160000.4.1 ยท GPL-2.0-or-later
- opensuse-leap 16.0: net-tools-deprecated 2.10-160000.4.1 ยท GPL-2.0-or-later
- opensuse-leap 16.0: net-tools-deprecated 2.10-160000.4.1 ยท GPL-2.0-or-later
- opensuse-leap 16.0: net-tools-deprecated 2.10-160000.4.1 ยท GPL-2.0-or-later
- ubuntu noble: net-tools 2.10-0.1ubuntu4 ยท GPL-2.0-or-later
- ubuntu noble: net-tools 2.10-0.1ubuntu4.4 ยท GPL-2.0-or-later
- ubuntu questing: net-tools 2.10-1.3ubuntu2 ยท GPL-2.0-or-later
- ubuntu resolute: net-tools 2.10-2ubuntu1 ยท GPL-2.0-or-later
- ubuntu stonking: net-tools 2.10-2ubuntu1 ยท GPL-2.0-or-later
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms