IFROUTE(5)

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

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

ok bestie, so this one is ifroute, a Network configuration manual page, and it's literally the blueprint for how your interface's static routes get set up. buckle in πŸ’–


✨ SYNOPSIS ✨

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

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the tea is this: /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 a trio, they work as a unit, periodt. 🫢

here's the split, no cap:

  • /etc/sysconfig/network/ifroute-<interface> β€” holds routes for that particular interface only
  • /etc/sysconfig/network/routes β€” can hold routes for all interfaces

and if you ever wanna see which routes are actually assigned rn, you literally just run:

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

that hands you the current (main) routing tables. iconic. πŸ‘‘


πŸ’… Syntax πŸ’…

both files? same syntax. the only difference is how the interface field in the 4th column gets interpreted. that's it, that's the whole diff.

lines starting with # and blank lines are ignored (we love a comment that minds its own business ✨). there are 5 columns with special meaning. if you wanna 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 β€” she's flexible like that. πŸŽ€

the columns are:

Destination Gateway Netmask Interface Options

1st β€” Destination 🌸

this is your destination / prefix, written as either the IP-address of a host or as a network in prefix-length (CIDR notation), e.g. 10.10.0.0/16 for IPv4 or fc00::/7 for IPv6 routes. the keyword default means the route is the default gateway in the same address family (ipv4 or ipv6) as the gateway. and for device routes without a gateway? use explicit 0.0.0.0/0 or ::/0 destinations. don't be shy, spell it out. πŸ’œ

2nd β€” Gateway πŸ¦‹

this column defines the gateway, i.e. the regular IP-address of a host that routes the packets to a remote host or remote network. for rejecting or device routes you can totally omit this info using a dash -. slay.

3rd β€” Netmask πŸ“

this one is deprecated, bestie, so heads up. it gives the IPv4 netmask of the destination. for IPv6 routes, for the default route, or if you were using a prefix-length (CIDR notation) in the 1st destination column, you can omit it with a dash -. lowkey ghosting this column is fine in those cases.

4th β€” Interface 🌈

contains the name of the interface (lo, eth0, eth1, ib0, ...).

and now the plot twist: if you leave this field empty (using a dash -), the result depends on which file you're in. πŸ™ˆ

  • In /etc/sysconfig/network/routes, the field is interpreted as no interface information available, and the gateway gets examined to see if it belongs to the same network as a 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. not the vibe. πŸ’€
  • 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. much more main character energy. ✨

5th β€” Options πŸ’…

this column is where you specify further options for the route, like preference (metric), mtu, or the type of a route:

  • 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's 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 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.
  • nat β€” a special NAT route, not supported any longer since Linux 2.6. she's retired, we respect the legacy. πŸŽ€

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

fr fr reminder: columns which are not needed should contain a dash sign (-) to ensure that the parser correctly interprets the command. don't leave her guessing. πŸ’€

πŸ”₯ 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 it for you, bestie, don't duplicate her work.

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 they should be omitted. yes, literally leave them out. 🫢


πŸŽ€ FILES πŸŽ€

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

πŸ‘‘ 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 ip-route man page by Michail Litvak and others were also used. legends, all of them. πŸ’–


⭐ BUGS ⭐

please report bugs as described at <https://bugs.opensuse.org> β€” don't sit on them, tell the maintainers, they wanna know. πŸ¦‹


🌈 SEE ALSO 🌈


and that's the whole page, bestie β€” this one's sysconfig, dated May 2014, and she ate. go forth and route responsibly πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from