GEN-RESCUE-NETSCRIPT(1)
π GEN-RESCUE-NETSCRIPT(1) π
okay bestie so this is the manual page for gen-rescue-netscript, and it's genuinely one of the most useful little gremlins in your toolbox. pull up a chair. π«Ά
β¨ NAME β¨
gen-rescue-netscript β generate a rescue system network configuration script π
πΈ SYNOPSIS πΈ
gen-rescue-netscript [--output PATH] [--efi] [--interface IFACE]
[--prefer {ipv4,ipv6}]
gen-rescue-netscript -h
π¦ DESCRIPTION π¦
So gen-rescue-netscript makes a shell script that configures a rescue system's network to match whatever the currently-running system's network looks like. It peeks at the network config of the machine you're on right now, through ip(8) (specifically ip -json), and writes out a standalone POSIX /bin/sh script to standard output that recreates that exact configuration. It's built for moments like: you booted a rescue image and now you gotta get this box back onto its usual network, but you don't have DHCP and honestly you don't want DHCP. π€
Only one network interface gets configured. By default that's whichever interface is currently carrying the default route β more on that in INTERFACE SELECTION below. π
The generated script is fully self-contained, no cap: it does not depend on gen-rescue-netscript or Python being available wherever it ends up being run. All it needs is a POSIX shell and ip(8). It is totally safe to re-run. And the values you're most likely to wanna hand-edit (the interface name, addresses, gateways, and nameservers) are exposed as shell variables near the top of the file instead of being copy-pasted as literals all over the place. iconic behavior, honestly. β¨
π OPTIONS π
--output PATHβ Without--efi, this writes the generated script to PATH instead of standard output, and the file is created mode0755. With--efi, PATH gets interpreted relative to the root of the EFI partition instead (go look at EFI PARTITION DISCOVERY below). The default comes from theoutputkey in the config file, orrescue-net/network.shif that isn't set either β see CONFIG FILE. π--efiβ Writes the generated script onto the partition whose filesystem label or GPT partition label isEFI,ESP,efi, oresp, mounting it first if it isn't mounted already. See EFI PARTITION DISCOVERY below, and--outputabove for where exactly on it the script lands. π--interfaceβ Configure IFACE instead of auto-detecting the interface via the default route. See INTERFACE SELECTION below. π--preferβ When the IPv4 and IPv6 default routes name two different interfaces, prefer the one belonging to FAMILY, which is eitheripv4oripv6. See INTERFACE SELECTION below. Default:ipv6. π-h,--helpβ Shows a brief usage message and dips. π
π§ INTERFACE SELECTION π§
The interface that gets configured is chosen in this exact order:
- The
--interfacecommand-line option, if you gave one. - The
interfacekey in/etc/gen-rescue-netscript.conf, if that file exists and sets it. - Otherwise, whichever interface carries the default route. Both the IPv4 and IPv6 default routes get considered. If they name the same interface (or only one family has a default route at all), that interface wins. If they name different interfaces, the interface belonging to the preferred family is used instead β see
--preferabove and thepreferconfig key below β rather than refusing to guess. π―
heads up though:gen-rescue-netscriptstill exits with an error,--preferor no--prefer, if there's no default route in either family, or if a single family's default route alone already points at more than one interface. that second one is a conflict no family preference can resolve. π
π CONFIG FILE π
/etc/gen-rescue-netscript.conf is an optional ini-style file. Right now it supports a single section, [gen-rescue-netscript], plus these top-level keys:
interface: eth0
output: rescue-net/network.sh
prefer: ipv6
efi: True
These get taken as defaults and can all be overridden from the command line. periodt. π
π ADDRESS AND ROUTE FILTERING π
Not every single address and route that ip addr show and ip route show report actually makes it into the generated script. Here's the filter, bestie:
- IPv6 link-local addresses that match the interface's standard EUI-64-derived address (computed from its MAC address) are treated as the kernel's auto-assigned address and omitted. Any other link-local address present is kept, on the assumption that somebody explicitly configured it.
- IPv4 link-local addresses (
169.254.0.0/16, zeroconf/APIPA) are always omitted. - IPv6 SLAAC-derived global addresses are omitted, including privacy extension ("temporary") addresses, since these regenerate on their own and should not be pinned as static.
- DHCP-obtained addresses are kept, pinned as static addresses in the generated script, with a comment noting where they came from.
- Routes with
not me noticing that last bullet justβ¦ ends π the source really does trail off mid-sentence there. keeping it exactly as it is, no notes.
π /ETC/RESOLV.CONF π
The generated script also (re)writes /etc/resolv.conf. The nameserver(s) it writes get determined at generation time, in this order:
- If systemd-resolved is in use,
resolvectl(1)is queried for the resolver(s) currently in effect for the target interface (falling back to the global resolver if no per-link resolver is set). - Otherwise, whatever
nameserverlines are already present in the current/etc/resolv.confare used β ignoring loopback stub-resolver addresses (like systemd-resolved's127.0.0.53), because those would be meaningless outside the system they were captured on. π΅ - If neither of those yields anything,
1.1.1.1is used as a last-resort fallback.
If the current system's /etc/resolv.conf is a symlink (which is typical under systemd-resolved, e.g. pointing at /run/systemd/resolve/stub-resolv.conf), the generated script resolves that symlink at generation time and writes to the resolved target instead β creating the containing directory first. slay. π
β EFI PARTITION DISCOVERY β
With --efi, gen-rescue-netscript hunts down a partition whose filesystem label or GPT partition label is EFI, efi, ESP, or esp, via blkid(8): first by filesystem label and then by partition label, using blkid. Either match is treated as "the EFI partition". If neither is found, gen-rescue-netscript exits with an error. π¨
If the partition is already mounted, the script is written directly under its existing mountpoint, at the path described under --output above. Otherwise the partition gets mounted at a temporary directory, the script is written, and then the partition is unmounted again before gen-rescue-netscript exits. clean. π§Ή
π¦ GENERATED SCRIPT LAYOUT π¦
The generated script kicks off with a comment block giving the generation timestamp, the generating host's FQDN, and the selected interface name. Then a diagnostic comment block containing the plain-text (non-JSON) output of ip addr show, ip route show, ip -6 route show, ip rule show, and ip -6 rule show at generation time gets appended at the end of the file, for human reference. That text is purely informational β it is never parsed, never executed. it's just vibes for your eyes. π
Between those two blocks, the script defines shell variables for the values most likely to need hand-editing. Lists are each a single space-separated list (e.g. ADDR="192.0.2.10/24 2001:db8::10/64"). The script loops over those with the commands that follow. π
π₯ EXIT STATUS π₯
0β Success. π1β An error occurred. π2β Invalid command-line arguments. π
πΈ FILES πΈ
/etc/gen-rescue-netscript.confβ Optional config file; see CONFIG FILE above. π
π REQUIREMENTS π
ip(8) with -json support (iproute2 β₯ 4.9, released 2017). With --efi, you also need blkid(8) and mount(8)/umount(8). resolvectl(1) is used opportunistically if it's present β its absence is not an error. π«Ά
π BUGS π
Report bugs at the project's issue tracker. π
π SEE ALSO π
ip(8), ip-address(8), ip-route(8), ip-rule(8), resolvectl(1), blkid(8), mount(8), resolv.conf(5)
and that's the whole thing, bestie β this was gen-rescue-netscript 1.0.0, dated 2026-07-17. go save a machine, you absolute icon. π
β¨π¦
π¦ where this page comes from
- ubuntu stonking: gen-rescue-netscript 1.0.1-1 Β· 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