IFROUTE(5)

πŸ“¦ version 0.6.80, in opensuse-leap 16.0

✨ IFROUTE(5) β€” the static routing tables glow-up ✨

okay bestie, buckle up, because this is the page about making your interface's static routes actually happen πŸ’… and it lives in ifroute(5), the Network configuration manual. no cap, it's lowkey iconic.


πŸ¦‹ NAME πŸ¦‹

ifroute β€” configure the interface static routing tables. that's it, that's the whole vibe. ✨


🌸 SYNOPSIS 🌸

/etc/sysconfig/network/ifroute-<interface>
/etc/sysconfig/network/routes

two files, main character energy, doing the routing thing. πŸŽ€


πŸ’– DESCRIPTION πŸ’–

so here's the tea: /etc/sysconfig/network/ifroute-<interface> and /etc/sysconfig/network/routes get parsed together with /etc/sysconfig/network/ifcfg-<interface> to set up static routes for a particular interface. they're literally a trio, besties. 🫢

  • /etc/sysconfig/network/ifroute-<interface> β€” holds the routes for that particular interface (very "this is MY lane" of it)
  • /etc/sysconfig/network/routes β€” can hold routes for all interfaces, the social butterfly of the two πŸ¦‹

wanna see the routes that are currently assigned? just run:

/sbin/ip -4 route show ; /sbin/ip -6 route show

and that gives you the current (main) routing tables. cute, right? πŸ’…


🌈 Syntax 🌈

both files use the exact same syntax, the only difference is how the interface field in the 4th column gets interpreted. iykyk.

lines starting with # and blank lines are ignored (snubbed, honestly). there are 5 columns with special meaning. if you want to omit an entry for a field, write a dash -. and if all the following fields in the line are empty too, you can even skip the dash entirely β€” slay, efficiency. ✨

the columns are: Destination Gateway Netmask Interface Options

1st β€” Destination column: gives the destination / prefix, written either as the IP-address of a host or as a network in a prefix-length (CIDR notation), e.g. 10.10.0.0/16 for IPv4 or fc00::/7 for IPv6 routes. the heading default indicates that the route is the default gateway in the same address family (ipv4 or ipv6) as the gateway. for device routes without a gateway, use explicit 0.0.0.0/0 or ::/0 destinations. no gateway? no problem, just be explicit about it. 🧚

2nd β€” Gateway column: defines the gateway. write the regular IP-address of a host which routes the packets to a remote host or remote network. you can omit this info for rejecting or device routes using a dash -. πŸ™ˆ

3rd β€” Netmask column: bestie, this one is deprecated πŸ’€ it gives the IPv4 netmask of the destination. for IPv6 routes, the default route, or if you were using a prefix-length (CIDR notation) in the 1st destination column, you can omit it using a dash -.

4th β€” Interface column: contains the name of the interface (lo, eth0, eth1, ib0, ...). classic.

now if you leave this field empty (using a dash -), the result depends on which file you're in β€” plot twist:

  • in /etc/sysconfig/network/routes, the field is interpreted as no interface information available, and the gateway is examined to see if it belongs to the same network as an IPADDR in all (currently parsed) ifcfg-<interface> files. the first IP address match is used, so if you have multiple interfaces, such a route may match multiple IP addresses and cause unintended behavior. 😭 so watch out for that.
  • in the latter case you may want to use /etc/sysconfig/network/ifroute-<interface> instead. here an empty interface field is replaced with the interface name that is currently being activated β€” that is, the interface in the file name. self-aware king. πŸ‘‘

5th β€” Options column: can be used to specify further options for the route like preference (metric), mtu, or the type of a route. the types, in all their glory:

  • unicast β€” the route entry describes real paths to the destinations covered by the route prefix.
  • local β€” the destinations are assigned to this host. the packets are looped back and delivered locally.
  • broadcast β€” the destinations are broadcast addresses. the packets are sent as link broadcasts.
  • multicast β€” a special type used for multicast routing. it is not present in normal routing tables.
  • throw β€” a special control route used together with policy rules. if such a route is selected, lookup in this table is terminated pretending that no route was found. without policy routing it is equivalent to the absence of the route in the routing table. the packets are dropped and the ICMP message net unreachable is generated. the local senders get an ENETUNREACH error. πŸ’€
  • unreachable β€” these destinations are unreachable. packets are discarded and and the ICMP message host unreachable is generated. the local senders get an EHOSTUNREACH error.
  • prohibit β€” these destinations are unreachable. packets are discarded and the ICMP message communication administratively prohibited is generated. the local senders get an EACCES error.
  • blackhole β€” these destinations are unreachable. packets are discarded silently. the local senders get an EINVAL error. the silent treatment, literally.
  • nat β€” a special NAT route, not supported any longer since Linux 2.6. rip, she's retired. πŸͺ¦

all options (except of to, via and dev used in columns 1-4) of the ip route add command shall be supported. fancy. ✨

columns which are not needed should contain a dash sign ( - ) to ensure that the parser correctly interprets the command. do it for the parser, she's trying her best. 🫢


πŸ’œ EXAMPLES πŸ’œ

an example with common network interfaces and some static routes:

# --- IPv4 routes in CIDR prefix notation:
# Destination     [Gateway]         -                  Interface
#
127.0.0.0/8       -                 -                  lo
204.127.235.0/24  -                 -                  eth0
default           204.127.235.41    -                  eth0
207.68.156.51/32  207.68.145.45     -                  eth1
192.168.0.0/16    207.68.156.51     -                  eth1

# --- IPv4 routes in deprecared netmask notation:
# Destination     [Dummy/Gateway]   Netmask            Interface
#
127.0.0.0         0.0.0.0           255.255.255.0      lo
204.127.235.0     0.0.0.0           255.255.255.0      eth0
default           204.127.235.41    0.0.0.0            eth0
207.68.156.51     207.68.145.45     255.255.255.255    eth1
192.168.0.0       207.68.156.51     255.255.0.0        eth1

# --- IPv6 routes are always using CIDR notation:
# Destination     [Gateway]                -           Interface
#
2001:DB8:100::/64 -                        -           eth0
2001:DB8:100::/32 fe80::216:3eff:fe6d:c042 -           eth0

Note: πŸŽ€ routes to a directly connected network are created automatically (Linux kernel 2.4 and later) as soon as the IP address is assigned to the interface. the kernel is doing the most, honestly.

for example, when the eth0 interface IP addresses are 204.127.235.42/24 and 2001:DB8:100::42/64, the following routes are created automatically:

     204.127.235.0/24  -   -   eth0
     2001:DB8:100::/64 -   -   eth0
     fe80::/64         -   -   eth0

and those should be omitted. don't double up, bestie. πŸ™ˆ


πŸ“ FILES πŸ“

  • /etc/sysconfig/network/ifroute-<interface>
  • /etc/sysconfig/network/routes

(the two icons of this whole page, fr fr πŸ’…)


πŸ‘‘ AUTHOR πŸ‘‘

  • Michal Svec
  • Christian Zoz
  • Mads Martin Joergensen
  • Marius Tomaschewski

thanks to Werner Fink for the old route.conf(5). parts of the ip reference by Alexey Kuznetsov and the ip-route man page by Michail Litvak and others were also used. stan the contributors. 🫢✨


πŸ’€ BUGS πŸ’€

please report bugs as described at <https://bugs.opensuse.org> β€” help the maintainers help you, bestie. πŸ›


⭐ SEE ALSO ⭐

ifcfg(5), ip-route(8)


ngl, if you got this far you're basically a routing legend now. go assign some routes, you icon. πŸŒˆπŸ‘‘

this was sysconfig, May 2014 β€” the IFROUTE(5) era of the Network configuration manual. mwah. πŸ’‹βœŒοΈ

πŸ“¦ where this page comes from