RDOMAIN(4)

πŸ“¦ in nixpkgs unstable

πŸ¦‹ rtable, rdomain β€” RDOMAIN(4) but make it make sense πŸ¦‹

okay bestie, gather round: this is the RDOMAIN(4) page from the Kernel Interfaces Manual, and it's literally about routing tables and routing domains. think of it as the group chat where packets find out where they’re allowed to go. πŸ’…


✨ NAME ✨

rtable, rdomain β€” routing tables and routing domains. no cap, that’s the whole name.

🌈 DESCRIPTION 🌈

so the old-school kernel routing system had one single table for routes, and it allowed only non-conflicting IP address assignments. the rtable feature is like β€œbestie, what if we had multiple lookup tables for routes?” and the rdomain feature is like β€œand what if we logically segment a router between network paths?” iconic behavior, honestly. 🫢

🧚 Routing tables 🧚

each rtable contains routes for outbound network packets. a routing domain can contain more than one rtable. multiple routing tables are commonly used for Policy Based Routing. the highest ID that can be used for an rtable is 255. so yes, 255 is the ceiling, bestie. πŸ‘‘

πŸ¦‹ Routing domains πŸ¦‹

each rdomain is a completely separate address space in the kernel. an IP address (e.g. 10.0.0.1/16) can be assigned in more than one rdomain, but it cannot be assigned more than once per rdomain. an interface belongs to one and only one rdomain. the interface’s rdomain determines which rdomain an incoming packet will be in. virtual interfaces do not need to belong to the same rdomain as the parent. each rdomain contains at least one routing table.

network traffic within an rdomain stays within the current routing domain. pf(4) is used to move traffic from one rdomain to a different rdomain.

when an interface is assigned to a non-existent rdomain, it gets created automatically. at the same time an rtable with the same ID and a lo(4) interface with a unit number matching the ID get created and assigned to the new domain. literally auto-magic. ✨

an rdomain can be deleted by removing all interfaces from it and then destroying the lo(4) interface with the unit number matching the ID.

the highest ID that can be used for an rdomain is 255. same 255 energy, different vibe check. πŸ’…

πŸ’… EXAMPLES πŸ’…

put em0 and lo4 in rdomain 4:

# ifconfig em0 rdomain 4
# ifconfig lo4 inet 127.0.0.1/8
# ifconfig em0 192.0.2.100/24

list all rdomains with associated interfaces and routing tables:

$ netstat -R

set a default route and localhost reject route within rtable 4:

# route -T4 -qn add -net 127 127.0.0.1 -reject
# route -T4 -n add default 192.0.2.1

start sshd(8) in rtable 4:

# route -T4 exec /usr/sbin/sshd

display the routing table used by each process:

$ ps aux -o rtable

display the routing table of the current process:

$ id -R

a pf.conf(5) snippet to block incoming port 80, and nat-to and move to rtable 0 on interface em1:

block in on rdomain 4 proto tcp to any port 80
match out on rdomain 4 to !$internal_net nat-to (em1) rtable 0

delete rdomain 4 again:

# ifconfig em0 -rdomain
# ifconfig lo4 destroy

πŸ‘‘ SEE ALSO πŸ‘‘

id(1), netstat(1), ps(1), lo(4), route(4), pf.conf(5), ifconfig(8), route(8) β€” that’s the reading list, bestie. iykyk ✨

🌸 HISTORY 🌸

OpenBSD support for rdomain first appeared in OpenBSD 4.9, and IPv6 support first appeared in OpenBSD 5.5. history really said β€œlet there be routing domains,” and then later β€œand also IPv6.” πŸ’–

πŸ’€ CAVEATS πŸ’€

  • no tool is available to assign more than one rtable to an rdomain other than to the default one (0). so no, there is no tool for that β€” don’t go hunting, bestie. πŸ™ˆ
  • an rtable cannot be deleted. deleting an rdomain will move its rtable into the default rdomain. this is the important part: no rtable deletion, periodt. πŸ’€

and that’s the whole page, bestie 🫢 this one’s from Debian, dated July 29, 2022. go forth and route responsibly πŸ’…βœ¨

πŸ“¦ where this page comes from
  • nixpkgs unstable: cvs-export
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms