dietpi-network: new tool for multi interface configuration - #8251
Merged
Conversation
Copilot created this pull request from a session on behalf of
MichaIng
August 15, 2026 19:33
View session
MichaIng
requested changes
Aug 15, 2026
MichaIng
left a comment
Owner
There was a problem hiding this comment.
@copilot
Please address my new comments.
Additionally:
- Add a new CLI option to
dietpi-wifidb, to pass an explicit WiFi interface name, replacing theG_GET_NET -t wlan ifacecall if given. Use that indietpi-networkwhen called from a particular interface submenu. - Migrate
Allo_Mainindietpi/func/dietpi-set_softwareto the newdietpi-networkCLI as well. UseG_GET_NET -t eth ifaceto obtain the interface to apply settings to. - Add an additional option to remove an interface configuration entirely, instead of just disabling it.
- If two interfaces are enabled on the same subnet, they cannot both have the same gateway/default route (unless we implement a
metricoption), and more importantly, the duplicate LAN routes like192.168.1.0/24on two interfaces can cause asymmetric traffic, that way break communication with e.g. a connected SSH client. Until we implement some more complex e.g. routing table based solution for this, it hence needs to be avoided that two interfaces are enabled on the same subnet. Please hence add the following: If another interface does already use the same subnet that is to be applied via static IP, or if an interface is to be enabled with DHCP while a default route is already assigned to another interface, show an additional prompt with this information. Allow to ignore or disable the potentially conflicting interface, to proceed. If the user chooses to disable the conflicting interface, comment out the respectiveallow-hotplug/autoline, andifdown --forcethat interface, before continuing to apply changes/enable the new interface.
Contributor
Author
Addressed all points in ca6012f/9ed570b:
|
MichaIng
force-pushed
the
copilot/move-menu-networkadapters-functionality
branch
2 times, most recently
from
August 17, 2026 12:00
ba91931 to
6e19c15
Compare
MichaIng
force-pushed
the
copilot/move-menu-networkadapters-functionality
branch
5 times, most recently
from
August 20, 2026 20:08
c8f8584 to
36e7cd9
Compare
MichaIng
marked this pull request as ready for review
August 20, 2026 20:28
MichaIng
approved these changes
Aug 20, 2026
MichaIng
left a comment
Owner
There was a problem hiding this comment.
So far so good. Works well now as far as I tested. But surely needs more testing.
I am considering to open an early beta for this.
And 1st run setups with new images need to be tested, also with the DHCP => static auto-conversion.
JappeHallunken
approved these changes
Aug 21, 2026
JappeHallunken
left a comment
Collaborator
There was a problem hiding this comment.
I just did a quick test in a VM.
…menus/CLI Co-authored-by: MichaIng <28480705+MichaIng@users.noreply.github.com>
Co-authored-by: MichaIng <28480705+MichaIng@users.noreply.github.com>
…e text Co-authored-by: MichaIng <28480705+MichaIng@users.noreply.github.com>
…omment Co-authored-by: MichaIng <28480705+MichaIng@users.noreply.github.com>
* remove global WiFi submenu, as it doubles with the options in main menu * clearify virtual vs hardware vs real interfaces: There are "real" interfaces that we can configure, and that exist independently of definitions in the network config. These are the only ones we list in the menu, and after some testing, this should be the only ones the script accepts as input, probably accepting `--force` to override and apply the config in any case. Among the "real" interfaces, there is WiFi, and everything else is interpreted as Ethernet. This includes virtual interfaces provided from container host to guest, because they can be configured just like any true Ethernet interface, without the need for wpasupplicant, and without a way to set it up with hostapd. True WiFi devices are automatically "real" devices, with `/sys/class/net/*/type == 1`. Remove the "hardware" vs "virtual" differentiation, which does not fit, and is not what is important for us. * fix lost credentials in proxy export: looks like Copilot passed this through some internal credentials exposure filter or so. But prevent password from being printed to console when stored to dietpi.txt. * do not attempt to parse /etc/hostapd/hostapd.conf if it does not exist, same with /etc/wpa_supplicant/wpa_supplicant.conf, but print STDERR when parsing fails * use mktemp for temporary interfaces file * write per-interface config in one go, after forging the content in a variable, and skip directives which would be added in commented form only * skip unnecessary `systemctl daemon-reload` when restarting interface * restore ifup@.service ourput to console while restarting an interface * do not stop hostapd and DHCP server if the restarted WiFi interface is not a hotspot, since another interface might be. We currently have no option to toggle an interface between hotspot and client mode from within the script. Instead, it needs to be uninstalled via dietpi-software. Also, stopping the services wouldn't be permanent. Moving this from dietpi-software into this script is a goal, but to be done in a separate PR. * add some input validation to menus, and migrate some from custom validation to G_WHIP_INPUTBOX_REGEX * treat a missing /etc/hostapd/hostapd.conf as error when settings are applied with an declared interface as hotspot, prompting an error message * skip conflicting network check entirely if `--force` was passed, hence settings are applied anyway, but otherwise show the respective dialog as well for CLI calls: CLI does not mean non-interactive across DietPi scripts! * call main menu "Main_Menu" and the menu loop "Menu_Loop" * remove some redundant NEXT_MENU assignments and further code cleanup and formatting * dietpi-installer: do not pre-seed interface definitions in main config
* bring down interface before removing its config, otherwise ifdown is doomed to fail * dietpi-software: WiFi Hotspot: remove WiFi interface configuration when uninstalling the WiFi hotspot, revert Tor Hotspot to use G_GET_NET, and skip redundant `--static` flag, which is implied with `--hotspot`
* extend "--force" flag to apply settings as well if the interface does not exist * detect interfaces named "wlanX" as WiFi interfaces * align WiFi vs Ethernet detection with G_GET_NET, and remove redundant `[[ $type ]]` check * dietpi-wifidb: make clear that "-i <iface>" is relevant for network scanning via menu only * dietpi-firstboot: rework network setup to use dietpi-network CLI * dietpi-firstboot: do not attempt to being up an interface if it does not exist yet, so that it does not disturb ifup@.service in case/once it is attached/detected
dietpi-set_hardware: eth-forcespeed: abort if no Ethernet interface can be found
* dietpi-software: use dietpi-network CLI to apply DHCP assigned IP as static IP (if requested) * dietpi-software: add NanoPi R3S and Zero2 as headless devices, to disable getty@tty1.service * dietpi-set_hardware: keyboard: apply "setupcon --save-only" separately first, before applying the change with "setupcon". Otherwise it throws 4 warnings as of the outdated cache, it seems. * dietpi-set_hardware: apply some comment header above every CLI command's function block, with the literal command name inside, so make searching in the script easier * dietpi-firstboot: gate all setup steps which depend on a certain package by the fact whether this package is installed, and remove now obsolete hardware ID gates * dietpi-firstboot: add some info messages about what is done
* remove test CLI commands: G_CHECK_URL can be used directly. This is mainly relevant during interactive setup, where the result is shown in the main menu. * some CLI help text reorder and alignment * remove redundant CURRENT_IFACE_MODE_TARGET variable, use CURRENT_IFACE_MODE instead, which was an unused duplicate before * detect "allow-auto" as well, which is a valid alias for "auto" * move "Auto Reconnect" to "Additional Options" as it should not be that prominent => mostly needed for mobile devices, not so much for flaky WiFi signal * add WiFi Hotspot uninstall entry as equivalent to "Remove" for the hotspot
"ip" prints e.g. for veth and VLAN interfaces, but it is not part of the actual interface name, hence does not match `/sys/class/net/*` and would fail other commands like `ifup`. Align condition that `/sys/class/net/*` needs to be a directory.
* use CIDR notation for CURRENT_IFACE_IP placeholder value, to indicate what is expected, and match what `ip a` prints when assigning live values * simplify awk script to parse configs, using clarer regex and hardened pattern checks * Some minor code format enhancements
AUTO_SETUP_NET_STATIC_MASK now superseded by optional CIDR notation with AUTO_SETUP_NET_STATIC_IP
* while nagivating the interface menu, do not override change settings from values in config files, until settings are applied, or the interface menu is exited * remove redundant MENU_TARGET variable, use NEXT_MENU directly * rename ENTRY_TARGET => ENTRY_MENU * Bring up Ethernet interfaces before calling ethtool to parse supported link speeds. This is needed e.g. for the RK35xx 2.5 Mbit PCIe ports, where ethtool throws errors if the interface is down. * If supported link speeds cannot be parsed, e.g. in case of bridged VirtIO adapters, offer 10/100/1000/2500 Mbits in the menu, along with a warning that obtaining supported speeds failed, and forcing an unsupported speed can break connectivity. * let `Parse_Interface_Config` return with error code directly, if the interface could not be found in the config, rendering `(( $PARSE_FOUND ))` check in caller functions redundant * remove redundant CLI commands, which /boot/dietpi/func/dietpi-set_hardware can/should be used directly * show Exit or Back on whiptail menu cancel button, depending on whether the menu is the entry menu or not * dietpi-set_hardware: eth-forcespeed: do not show a failure when disabling forced link speeds while /etc/systemd/system/ethtool_force_speed.service.d does not exist, as the script does now take the function's return code as exit code
* Do not assume that interfaces are enabled if they are not defined in any config. This was likely intended as default when applying settings, but it causes confusing status texts and can cause false positives in conflicting network checks. Show interfaces correctly as disabled, when they are. Instead, when applying settings, enable interfaces, unless they were explicitly disabled in their dedicated drop-in config, or requested as disabled via CLI option. That way, the status is shown correctly everywhere, and can be used as condition, while new interfaces are applied as enabled, unless explicitly requested otherwise. * fix CURRENT_IFACE_DNS_STATIC condition, being no integer * restart "auto" mode interfaces correctly via manual `ifdown`/`ifup`, since `ifup@.service` affects hotplug interfaces only. * show boot mode in main menu only if interface is enabled * show Disable/Remove options in interface menus only if the interface is actually defined in a config file already, and enabled respecively * add Enable option to interface menu if interface is disabled * pre-select current Ethernet link speed in respective menu * skip `dietpi-set_hardware eth-forcespeed` as intended when the selection menu with missing supported speed detection warning is cancelled * preserve last selected menu item in WiFi interface menu as well * address shellcheck annotation about quotation in shell conditionals' right-handed value
* add proper input validation for gateway * align "auto" link speed label so that it is shown as recommended from menu already * fix syntax for CURRENT_IFACE_ENABLED check, which is a 0|1 integer * clarify text on enable/disable options, that is is about whether the interface is automatically brought up at boot or not *
MichaIng
force-pushed
the
copilot/move-menu-networkadapters-functionality
branch
from
August 23, 2026 01:49
40ad818 to
60f1c90
Compare
* Assure Apply_Current_Interface returns with a positive return code, else the CLI apply call exits with error * Skip the redundant Load_Interface_State call in Restart_Interface: It is called from Apply_Current_Interface only, which is called from CLI apply and the interface submenu. The prior exits afterwards, hence does not make any use of the updated info. The interface menu does its own Load_Interface_State call. When disabling an interface, the script returns to the main menu. The main menu however calls its own Load_Interface_State function with unconditional Get_Interface_Stored_Settings for all interfaces, to show the correct states. * Use the new systemctl -v flag from Forky on, to show journalctl output during ifup@.service restarts, replacing the manual journalctl -f background job
Also relax the comment in the main config file. Many sort of manual configuration in /etc/network/interfaces does not cause issues like before. dietpi-network detects settings there, and migrates them automatically to drop-ins, when applying changes for a particular interface.
MichaIng
approved these changes
Aug 23, 2026
MichaIng
left a comment
Owner
There was a problem hiding this comment.
Okay, first boot setup works great as well. Merging this now, and starting an early beta to give more time for testing this tool.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DietPi-Config's
Menu_NetworkAdaptershardcoded exactly one Ethernet and one WiFi interface (resolved viaG_GET_NETprefix matching), stored everything in a single/etc/network/interfaces, and had no non-interactive way to change settings.New
dietpi/dietpi-networkscriptMenu_NetworkAdapters/_Ethernet/_Wifi/_Proxyand all exclusive helpers/state out ofdietpi-configinto a standalone script, structured likedietpi-vpn/dietpi-ddns.dietpi-confignow execs/boot/dietpi/dietpi-networkwhereMenu_NetworkAdaptersused to be called; all relatedTARGETMENUIDhandling is removed.Per-interface, name-independent configuration
/sys/class/net/*instead ofG_GET_NET: WiFi = has awirelesssubdir, Ethernet-like = has adevicesubdir but nowireless. Works with systemd predictable names (enp3s0,wlp2s0, ...), not justeth*/wlan*.Storage moved to per-interface drop-ins
/etc/network/interfaces.d/<name>.confinstead of rewriting/etc/network/interfaceswholesale./etc/network/interfaces, its config is read from there for the submenu; applying settings removes that interface's block from/etc/network/interfacesto avoid duplicate definitions.New CLI
dietpi-network <ifname|proxy|wifi|country|test>.dietpi-software WiFi Hotspot
/sys/class/net/*/wirelessand delegates interface configuration todietpi-network apply ... --hotspot/--clientinstead of editing/etc/network/interfacesdirectly.Other
dietpi-networkshell alias alongside the other DietPi CLI tools.dietpi-set_hardware eth-forcespeednow accepts an explicit interface argument, since multiple Ethernet interfaces can exist.