An interactive bash script to configure a static IP address on an Ethernet interface. Automatically detects your distro and uses the appropriate network backend.
| Distro | Backend | Config location |
|---|---|---|
| Ubuntu 22.04 / 24.04 / 26.x | Netplan | /etc/netplan/99-static-<iface>.yaml |
| Debian / Pop!_OS / Linux Mint | Netplan | /etc/netplan/99-static-<iface>.yaml |
| Arch Linux | systemd-networkd | /etc/systemd/network/20-static-<iface>.network |
| Manjaro / EndeavourOS / Garuda | systemd-networkd | /etc/systemd/network/20-static-<iface>.network |
| Unknown distro | Auto-detected | whichever backend is available |
Note: If the script is stored on an NTFS/exFAT mount (e.g.
/mnt/...),chmod +xwon't work. Always run it withbashdirectly:
sudo chmod +x ./*.*
sudo bash run.shThe script is fully interactive — it will prompt you for:
- Which network interface to configure (listed with current state and IP)
- Static IP address (e.g.
192.168.1.100) - Subnet prefix length (e.g.
24for a/24network) - Default gateway (e.g.
192.168.1.1) - DNS servers, space-separated (defaults to
8.8.8.8 1.1.1.1)
After showing a preview of the generated config, it asks for confirmation before applying.
- Detects your distro from
/etc/os-release - Lists all available network interfaces with their current IP and link state
- Validates all IP inputs before writing anything
- Backs up any existing config file before overwriting
- Sets
chmod 600on the config file (required by Netplan, good practice for networkd) - On Arch: automatically handles conflicts with
NetworkManageranddhcpcd, and restartssystemd-resolvedif present - On Ubuntu: validates the config with
netplan generatebefore applying; rolls back on failure
Ubuntu / Debian:
sudo rm /etc/netplan/99-static-<iface>.yaml
sudo netplan applyArch Linux:
sudo rm /etc/systemd/network/20-static-<iface>.network
sudo systemctl restart systemd-networkdReplace <iface> with your interface name, e.g. ens18, eth0, enp3s0.
If you apply the config over SSH, your session will drop when the network restarts. Reconnect using the new static IP you configured.
- Bash 4+
iproute2(ipcommand) — present on all modern distros- Root / sudo access