Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

NetworkManager dispatcher scripts let you run local tasks in response to connection and device events. To use them safely, install a root-owned executable in the dispatcher directory, branch on the event and validate its inputs, keep blocking work short, and account for delayed or overlapping events. The precise behavior can vary with the NetworkManager build and distribution.

Install scripts with the required protections

NetworkManager runs scripts from /etc/NetworkManager/dispatcher.d and /usr/lib/NetworkManager/dispatcher.d, including subdirectories. An entry in /etc takes precedence over an identically named entry in /usr/lib; scripts run in alphabetical order. The NetworkManager reference manual says each script should be a regular executable file owned by root, not writable by group or others, and not setuid.

  1. Create a regular script in a documented dispatcher directory, using a clear filename.
  2. Set root ownership and executable permissions. For example, an administrator could use chown root:root /etc/NetworkManager/dispatcher.d/20-local-task and chmod 755 /etc/NetworkManager/dispatcher.d/20-local-task; ensure the resulting file is not group- or other-writable and has no setuid bit.
  3. Review the parent directory and any symlink targets as well as the script itself. Prevent untrusted users from replacing code that will run with administrator authority.
  4. Keep secrets out of logs, and treat event values as data rather than interpolating them unsafely into shell commands.

Choose an event and validate its inputs

Each script receives two arguments: the interface name and the action. The interface argument is not always a conventional interface name. Depending on the event, it may correspond to VPN_IP_IFACE, DEVICE_IP_IFACE, or DEVICE_IFACE. For hostname, the device argument is none; for connectivity-change and dns-change, it is empty.

Documented actions include pre-up, up, pre-down, down, dhcp4-change, dhcp6-change, connectivity-change, reapply, dns-change, hostname, and device-add. The reference manual describes a special generic-device handler path for device-add in which only one script is executed. Handle each action deliberately rather than assuming every invocation represents a connection with a populated interface name.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Use environment variables defensively

Depending on the event, the environment can include NM_DISPATCHER_ACTION, CONNECTION_UUID, CONNECTION_ID, CONNECTION_DBUS_PATH, CONNECTION_FILENAME, CONNECTION_EXTERNAL, DEVICE_IFACE, and DEVICE_IP_IFACE. VPN-related events can provide VPN-prefixed address variables. Connection user data is exported in encoded CONNECTION_USER_... variables; for example, the manual maps test.foo-Bar2 to CONNECTION_USER_TEST__FOO_055_BAR2. Availability depends on context, so test whether variables are unset or empty before using them.

Example: branch on the action

A minimal shell handler can reject unexpected or incomplete input before doing work:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
#!/bin/sh
iface=$1
action=$2

case "$action" in
  up)
    [ -n "$iface" ] || exit 0
    # Validate current state before consequential work.
    ;;
  down)
    [ -n "$iface" ] || exit 0
    ;;
  connectivity-change|dns-change)
    # The interface argument may be empty for these actions.
    ;;
  *)
    exit 0
    ;;
esac

This illustrates input handling only; add the task-specific state checks and actions you actually need.

Choose timing that will not block network changes

Action or mode Effect When it fits
up or down Runs in response to activation or disconnection without making that transition wait for the task. Use for most follow-up work that need not happen before the transition.
pre-up Runs before NetworkManager reports the interface fully activated; NetworkManager waits for the script. Only when work must complete before activation and can finish promptly.
pre-down Runs before disconnection; NetworkManager waits. It is not emitted for forced disconnections such as carrier loss or fading wireless signal. Only for work that must happen before a cleanly handled disconnection.
Symlink into no-wait.d Runs immediately without waiting for preceding scripts, and in parallel with them. Only when the handler is safe under concurrent execution and altered ordering.

Scripts run one at a time asynchronously from the main NetworkManager process and are killed if they run too long. The manual recommends spawning a child and allowing the dispatcher parent to return when work may take an arbitrary amount of time. It does not establish one universal timeout duration, so do not assume a fixed limit across distributions or builds.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Design for repeated, concurrent, and stale events

A queued script can run after another event has made its triggering event obsolete—for example, an up handler may run after the interface has gone down again. The event is therefore not a guarantee that the reported state remains current when your code acts.

  • Make operations idempotent where possible, so a repeated invocation does not cause harmful duplicate effects.
  • Before consequential changes, query the current device or connection state and act on that state rather than trusting the old event alone.
  • If using no-wait.d, protect shared files and other shared resources against overlapping runs, and do not depend on alphabetical completion order.
  • Keep pre-event work short because it delays activation or disconnection.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot a script that did not run or delayed networking

  1. Check installation and permissions. Confirm the exact dispatcher path, regular-file status, executable bit, root ownership, group/other write permissions, and setuid state. Check parent-directory and symlink-target protections too.
  2. Confirm the event inputs. Log the action and arguments safely, without secrets, then verify that the action and interface value match the case your handler expects. Account for an empty or special device argument.
  3. Look for blocking work. A pre-up or pre-down script delays the corresponding transition. A handler that runs too long can be terminated; the timeout is not a universal documented number.
  4. Check for stale events or overlap. Compare the current interface state with the event that triggered the script. If the script is linked into no-wait.d, account for parallel execution.
  5. Check your distribution’s installed version and manual. Ubuntu’s Noble manual identifies its packaged version as NetworkManager 1.46.0-1ubuntu2.8 and describes the general sequential, timeout, and no-wait behavior. Red Hat’s RHEL 8 networking guide also directs readers to the NetworkManager manual for dispatcher actions and environment variables.

The project reference manual documents the dispatcher interface; consult the manual for the NetworkManager package installed on your system when distribution-specific details matter.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.