SMCROUTED(8)
π SMCROUTED(8) β System Manager's Manual π
okay so bestie, meet smcrouted: SMCRoute, a static multicast router, from the section 8 system manager's manual. this page is long so we're doing it in parts, and part 1 starts right now. π
β¨
π¦ NAME π¦
smcrouted β SMCRoute, a static multicast router
β¨ SYNOPSIS β¨
smcrouted [-nNhsv] [-c SEC] [-d SEC] [-e CMD] [-f FILE] [-F FILE]
[-i NAME] [-l LVL] [-m SEC] [-p USER:GROUP] [-P FILE] [-t ID]
[-u FILE]
πΈ DESCRIPTION πΈ
smcrouted is a static multicast routing daemon, and the way it gives you fine grained control over the multicast forwarding cache (MFC) in the UNIX kernel? iconic. both IPv4 and IPv6 are fully supported. no cap.
It can be your alternative to dynamic multicast daemons like mrouted(8), pimd(8) or pim6sd(8) in situations where static multicast routes should be maintained and/or no proper IGMP or MLD signaling exists. lowkey perfect for that.
Multicast routes exist in the UNIX kernel only as long as a multicast routing daemon is running. On Linux, multiple multicast routers can run simultaneously using different multicast routing tables. To run smcrouted and mrouted at the same time, set the former to use a routing table other than the default (0).
smcrouted modifies the kernel routing table and needs either full superuser rights, or CAP_NET_ADMIN on Linux. This also applies to the friendly control tool smcroutectl(8). so yeah, permissions are giving main character energy. π
π¨ Warning π¨
Be careful when creating multicast routes. You can easily flood your networks by inadvertently creating routing loops. Either direct loops listing an inbound interface also as an outbound, or indirect loops by going through other routers. seriously, do not play with this. π
π OPTIONS π
The following command line options are available:
-c SECβ Flush unused dynamic(*,G)multicast routes everySECseconds.
This option is intended for systems with topology changes, i.e., when inbound multicast may change both interface and source IP address. E.g. in a setup with at least two VRRP routers. If there is no way of detecting such a topology change this option makes sure to periodically flush all dynamically learned multicast routes so that traffic may resume. Flushing of a specific route only occurs if it was unused during the last flush interval, i.e. there was no traffic matching it. This avoids toggling between different inbound interfaces if traffic arrives on several interfaces simultaneously. In this case, the first selected inbound interface is retained until traffic on it ceases.
Default is 60 sec, set to 0 to disable. See also the smcroutectl flush command, which can be called manually on topology changes.
-d SECβ Daemon startup delay. Delays the probe of interfaces and parsing of the configuration file. Note, the PID file is also not created, since the daemon is not ready yet.
This command line option, although useful in some use-cases, is fragile. It is almost always better to rely on an init or process supervisor that handles dependencies properly, like finit(8), which can wait for interfaces to come up and files to be created before starting a service.
-e CMDβ Specify external script or command to be called whensmcroutedhas loaded/reloaded all static multicast routes from the configuration file, or when a source-less (ANY) rule has been installed.-f FILEβ Alternate configuration file, default/etc/smcroute.conf-F FILEβ Check configuration file syntax, use-l LEVELto increase verbosity. Returns non-zero on error.-hβ Show summary of command line options and exit.-i NAMEβ Set daemon identity. Used to create unique PID, IPC socket, and configuration file names, as well as set the syslog identity. E.g.,-I foowould makesmcroutedlook for/etc/foo.conf, write its PID to/var/run/foo.pidand create an IPC socket forsmcroutectlin/var/run/foo.sock.
For smcroutectl the same option can be used to select the proper smcrouted instance to send IPC to.
This option is required for both daemon and client when running multiple smcrouted instances, using multiple routing tables, on Linux.
-l LEVELβ Set log level:none,err,notice,info,debug. Default isnotice.-m SECβ Modify Multicast Router Discovery (mrdisc) announcement interval. Default20sec. This option is only available whensmcroutedis built with mrdisc support (Linux, and IPv4, only). RFC4286.-nβ Run daemon in foreground, do not detach from controlling terminal-Nβ By defaultsmcroutedenables multicast routing on all available, and multicast capable, interfaces in the system. These interfaces are enumerated as VIFs, virtual interfaces, of which most UNIX systems have a very limited amount, usually32. This daemon option inverts the behavior so no interfaces are enabled by default. Useful on systems with many interfaces, where multicast routing only makes use of a few.
The config file setting phyint IFNAME enable is required to enable the required interfaces.
-p USER [:GROUP]β Drop root privileges toUSER:GROUPafter start and retainCAP_NET_ADMINcapabilities only. The:GROUPis optional. This option is only available whensmcroutedis built with libcap support.-P FILEβ Set PID file name, and optionally full path, in case you need to override the default identity, or the identity set with-i NAME. Regardless, setting this option overrides all others, but it is recommended to use the ident option instead.-sβ Let daemon log to syslog, default unless running in foreground.-t IDβ Set multicast routing table ID. Remember to also create routing rules directing packets to the table. This example uses routing table ID123:
ip mrule add iif eth0 lookup 123
ip mrule add oif eth0 lookup 123
Note: Only available on Linux.
-u FILEβ UNIX domain socket path, used for the IPC betweensmcroutedandsmcroutectl. Use this to override the default socket path, derived from the daemon identity,-i NAME. This option can be useful when overriding the identity is not sufficient, e.g. for testing. The default depends on howsmcroutedis configured at build time, see βFILESβ.-vβ Show program version and support information.
The -e CMD option is useful if you want to trigger other processes to start when smcrouted has completed installing dynamic multicast routes from (*,G) rules in /etc/smcroute.conf, or when a source-less (ANY) route, a.k.a (*,G) multicast rule, from /etc/smcroute.conf. is matched and installed. For instance, calling conntrack on Linux to flush firewall connection tracking when NAT:ing multicast.
The script CMD is called with an argument reload or install to let the script know if it is called on SIGHUP/startup, or when a (*,G) rule is matched and installed. In the latter case smcrouted also sets two environment variables: source, and group. Beware that these environment variables are unconditionally overwritten by smcrouted and can thus not be used to pass information to the script from outside of smcrouted.
π OPERATION
π« Introduction
Okay so picture this: smcrouted boots up and immediately goes snooping around for every network interface that's got the MULTICAST flag turned on. As long as you didn't set the -N flag, each one of those interfaces gets enumerated as a virtual interface (VIF) β and that's the thing the kernel's multicast routing stack actually talks to. π
On some operating systems, the enumeration process also wants each interface to have an IP address. But Linux and FreeBSD? They're low maintenance besties β they only need the ifindex and the MULTICAST flag. Periodt.
Now, if an interface doesn't exist yet when smcrouted starts, you can use the -d SEC flag to delay startup. Otherwise? You're gonna have to reload smcrouted (like, with SIGHUP) once a new interface gets added to the system. π
Since VIFs are a limited resource β most operating systems only support 32 in total, which is giving scarcity era β the administrator might need to declare which interfaces to use for multicast routing via the /etc/smcroute.conf phyint directive. And ngl, the recommended move is to always start smcrouted with the -N flag, disabling VIF creation by default, and then selectively enable each interface you're going to route between. It's giving curated. β¨ See smcroute.conf(5) for more.
π§ Multicast Scoping
Because multicast is inherently broadcast, there's an obvious need to limit it. On a LAN this is usually handled automatically by bridges (switches) with built-in multicast snooping β that's IGMP and MLD, iykyk.
Between LANs though, there's also a need to scope multicast, because often the same multicast groups get used for totally different purposes on different LANs. And this? This must be managed by administrators. At least three options exist:
- TTL scoping β the traditional way of "raising walls" between zones. The outbound interfaces of routers are given a TTL threshold greater than the hop it represents. The default TTL threshold is
1. Managing the routers is a lot easier than adjusting the TTL value of each multicast sender. The only real downside? It scales poorly with the number of routers, and it affects all multicast traversing the router's interfaces. π - Administrative scoping (RFC2365) β this one is among the current best practices, defining boundaries for sets of multicast groups instead of limiting all multicast (which is what TTL scoping does). In the case of
smcrouted, this is left to the administrator to manage. Seemrouted(8)andmrouted.conf(5)for more details. π - Filtering β some sort of filtering mechanism, like a firewall (Linux netfilter) or a low-level filter (Linux
tcor eBPF) that may even have some hardware offloading support (TCAM). The firewall is likely the most common, since it's also often used to set up SNAT or 1:1 NAT (Linux netmap). π₯
π¦ Multicast Routes
A multicast route is defined by an input interface IFNAME, the sender's unicast IP address SOURCE (which is optional), the multicast group GROUP, and a list of β at least one β output interfaces IFNAME [IFNAME ...]. It's a whole little ensemble cast. π
mroute from eth0 group 225.1.2.3 to eth1 eth2
mroute from eth0 source 1.2.3.4 group 225.3.2.1 to eth1 eth2
mroute from eth0 group ff2e::42 to eth1 eth2
mroute from eth0 source 2001:3::1 group ff2e::43 to eth1 eth2
Big rule, no exceptions: the sender address and the multicast group must both be either IPv4 or IPv6 addresses. Don't mix, bestie, that's not the vibe. π
The output interfaces are not needed when removing routes using the smcroutectl remove command. The first three parameters are sufficient to identify the source of the multicast route. Easy.
The intended purpose of smcrouted is to aid in situations where dynamic multicast routing does not work properly. However, a dynamic multicast routing protocol is in nearly all cases the preferred solution. The reason? Their ability to translate Layer-3 signaling to Layer-2 and vice versa (IGMP or MLD). So like, respect the classics. πΈ
Note: the optional source address multicast routes are not installed in the kernel multicast forwarding cache (MFC) bysmcrouted. Instead, it dynamically installs new routes to the kernel MFC β matching the group and inbound interface β when the kernel notifiessmcroutedusing "upcalls" calledNOCACHEmessages. This feature was grafted ontosmcroutedfrommrouted(8), and may not work as intended in all use-cases. π«Ά
π― Multicast Groups
smcrouted is capable of simple group join and leave by sending commands to the kernel. The kernel then handles sending Layer-2 IGMP/MLD join and leave frames as needed. This can be used for testing, but it's also useful sometimes to open up multicast from the sender if located on a LAN with switches equipped with IGMP/MLD Snooping.
Here's the tea: such devices will prevent forwarding of multicast unless an IGMP/MLD capable router or multicast client is located on the same physical port as the one you run smcrouted on. But β and this is important β this feature of smcrouted is only intended as a workaround. Some platforms impose a limit on the maximum number of groups that can be joined, and some of these systems can be tuned to increase that limit. For bigger installations, it is strongly recommended to instead address the root cause β e.g. enable multicast router ports on intermediate switches, either statically or by enabling the multicast router discovery feature of smcrouted. Slay the actual problem, not the symptom. π
To emulate a multicast client using smcrouted, you use the join and leave commands to issue join and leave commands for a given multicast group on a given interface IFNAME. The GROUP may be given in an IPv4 or IPv6 address format. π
The command is passed to the daemon, which passes it to the kernel. The kernel then tries to join the multicast group GROUP on interface IFNAME by starting IGMP β or MLD, for an IPv6 group address β signaling on the given interface. This signaling may be received by routers/switches connected on that network supporting IGMP/MLD multicast signaling and, in turn, start forwarding the requested multicast stream, eventually reaching your desired interface. It's giving community effort. β¨
π―βοΈ Multiple Daemon Instances
When running multiple smcrouted instances β using the -t ID command line flag, one per routing table on Linux β it is required to use the -i NAME option for both daemon and client. Why? Because the name of the IPC socket used for communicating is composed from the identity. Matchy matchy or it simply won't work, bestie. π
π DEBUGGING
The most common problem when attempting to route multicast is the TTL. Always start by verifying that the TTL of your multicast stream is not set to 1, because the router decrements the TTL of an IP frame before routing it. Rude, but that's just how it is. π
Test your setup using ping(8) or iperf(1) β either of which is capable of creating multicast traffic with an adjustable TTL. Iperf in particular is useful since it can act both as a multicast source (sender) and a multicast sink (receiver). Main character energy, honestly. π
For more advanced IP multicast testing, the mcjoin(1) tool can be used. π§
π Note
A lot of extra information is sent under the daemon facility and the debug priority to the syslog daemon. Use smcrouted -s -l debug to enable. Yes, that's the whole tip. Go look at your logs, bestie. π
π¦ SIGNALS
For convenience in sending signals, smcrouted writes its process ID to /var/run/smcroute.pid upon startup β unless the -p FILE or -i NAME options are used to change the identity or file name used.
The following signals are supported:
HUPβ tellsmcroutedto reload its configuration file and activate the changes. πINTβ terminates execution gracefully. ποΈTERMβ the same asINT. π
π FILES
/etc/smcroute.confβ optional configuration file forsmcrouted. Defined interfaces to use, groups to join, and routes to set when starting, or reloading,smcroutedonSIGHUP. Like the PID file, the name of the configuration file may be different depending on command line options given to the daemon. Most notably,-I IDENTdefines the full suite of files used by thesmcrouteddaemon. Seesmcroute.conf(5)for details. π/etc/smcroute.d/*.confβ optional configuration directory, path defined by convention only. The actual configuration directory, or file(s) to include, is defined by/etc/smcroute.conf. Seesmcroute.conf(5)for details. π/var/run/smcroute.pidβ default PID file (re)created bysmcroutedwhen it has started up and is ready to receive commands. See also the-i NAMEor-P FILEoptions, which can change the default name. π/var/run/smcroute.sockβ IPC socket created bysmcroutedfor use bysmcroutectl. Same caveats apply to this file as the previous two; command line options-i NAMEand-S FILEto the daemon can be used to change the socket file name. π/proc/net/ip_mr_cacheβ Linux specific, holds active IPv4 multicast routes. π§/proc/net/ip_mr_vifβ Linux specific, holds the IPv4 virtual interfaces used by the active multicast routing daemon. π§/proc/net/ip6_mr_cacheβ Linux specific, holds active IPv6 multicast routes. π§/proc/net/ip6_mr_vifβ Linux specific, holds the IPv6 virtual interfaces used by the active multicast routing daemon. π§/proc/net/igmpβ Linux specific, holds active IGMP ASM (*,G) joins. π§/proc/net/igmp6β Linux specific, holds active MLD ASM (*,G) joins. π§/proc/net/mcfilterβ Linux specific, holds active IGMP SSM (S,G) joins. π§/proc/net/mcfilter6β Linux specific, holds active MLD SSM (S,G) joins. π§/proc/sys/net/ipv4/igmp_max_membershipsβ Linux specific tuning of max IGMP ASM (*,G) per socket, default20. ποΈ/proc/sys/net/ipv4/igmp_max_msfβ Linux specific tuning of max IGMP SSM (S,G) per socket, default10. ποΈ
BSD systems may consult the netstat(1) tool for stats on virtual multicast interface tables and multicast forwarding caches, and VIF/MIF allocation, as well as the ifmcstat(8) tool for querying group membership. π¦
EXIT STATUS π
okay so smcrouted leverages BSD sysexits.h exit codes (the 64β78 range), which process supervisors like systemd(1) and finit(8) understand. Here's the full rundown of what each code is used for and how to interpret it, bestie:
0βEX_OKβ Success. The happy ending, we love to see it π β¨64βEX_USAGEβ Invalid command line option, or missing argument. Bestie forgot the assignment π69βEX_UNAVAILABLEβ Multicast routing socket (or table) already in use. Somebody else is holding the aux, literally π«Ά79βEX_SOFTWAREβ Internal error, bug insmcrouted. Not me, not you, it's the code π71βEX_OSERRβ Failedfork(),daemon(),getifaddrs(),malloc(), etc. The system said no π76βEX_PROTOCOLβ Kernel does not seem to support multicast routing. The kernel is not giving what it's supposed to give π77βEX_NOPERMβ Not enough permissions to run. Permission denied vibes, no cap π78βEX_CONFIGβ Parse error in configuration file. The config file is giving syntax error realness π
SEE ALSO π¦
go read these next, bestie, they're the supporting cast:
AUTHORS π
SMCRoute was originally created by Carsten Schill <carsten@cschill.de>. Initial IPv6 support by Todd Hayton <todd.hayton@gmail.com>. Initial FreeBSD support by Micha Lenk <micha@debian.org>.
SMCRoute is currently maintained by Joachim Wiberg <troglobit@gmail.com>, and Micha Lenk <micha@debian.org> at GitHub: https://github.com/troglobit/smcroute.
give them their flowers, fr fr π
and that's the whole page, bestie! source: Debian Β· date: November 28, 2021 Β· page: SMCROUTED(8). stay slay, keep routing πβ¨
π¦ where this page comes from
- debian bookworm: smcroute 2.5.6-1 Β· GPL-2.0-or-later
- debian trixie: smcroute 2.5.7-1 Β· GPL-2.0-or-later
- fedora 43: smcroute 2.5.7-4.fc43 Β· GPL-2.0-or-later AND BSD-2-Clause AND BSD-3-Clause AND ISC AND LicenseRef-Fedora-Public-Domain
- fedora 44: smcroute 2.5.7-5.fc44 Β· GPL-2.0-or-later AND BSD-2-Clause AND BSD-3-Clause AND ISC AND LicenseRef-Fedora-Public-Domain
- nixos 26.05: smcroute 2.5.7
- opensuse-leap 16.0: smcroute 2.5.7-bp160.1.6 Β· GPL-3.0-only
- opensuse-leap 16.0: smcroute 2.5.7-bp160.1.6 Β· GPL-3.0-only
- opensuse-leap 16.0: smcroute 2.5.7-bp160.1.6 Β· GPL-3.0-only
- opensuse-leap 16.0: smcroute 2.5.7-bp160.1.6 Β· GPL-3.0-only
- ubuntu noble: smcroute 2.5.6-3 Β· GPL-2.0-or-later
- ubuntu questing: smcroute 2.5.7-1
- ubuntu resolute: smcroute 2.5.7-1build1 Β· GPL-2.0-or-later
- ubuntu stonking: smcroute 2.5.7-2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms