Draft
dietpi-network: new tool for multi interface configuration#8251
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
from
August 16, 2026 20:30
9ed570b to
3f2f5e4
Compare
…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`
MichaIng
force-pushed
the
copilot/move-menu-networkadapters-functionality
branch
from
August 17, 2026 12:00
ba91931 to
6e19c15
Compare
* 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
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.