A Bash script that simplifies converting a dynamic IP address to a static IP configuration on Ubuntu Server 24.04. It walks you through every step interactively and is designed to be accessible to users with limited networking experience.
- Welcome & overview – Greets the user and explains what the script will do before making any changes
- User authentication – Displays the current user and requests explicit confirmation to proceed
- Network interface detection – Automatically identifies the active network interface (ensure only one cable is plugged in)
- Current settings display – Shows existing IP address, netmask, gateway, and DHCP4/DHCP6 status
- Guided input prompts – Prompts for new static IP, netmask, gateway, DNS servers, and hostname
- Netplan config management – Locates the existing Netplan file, creates a timestamped backup, and writes a new configuration
- Safe apply with rollback – Asks for confirmation before applying; if declined, automatically reverts to the original configuration
- Ubuntu Server 24.04
- Bash
- Root / sudo access
git clone https://github.com/masterlog80/dynamic-to-static-ip.git
cd dynamic-to-static-ip
sudo chmod +x static-ip.sh
sudo ./static-ip.shThe script creates a backup of your original Netplan configuration before making any changes. To restore it manually:
# The backup is saved alongside the original, e.g.:
sudo cp /etc/netplan/00-installer-config.yaml.bak /etc/netplan/00-installer-config.yaml
sudo netplan apply- Run the script as root on your Ubuntu Server 24.04 machine.
- Confirm the active network interface detected by the script.
- Enter your desired static IP, subnet mask, gateway, DNS server(s), and hostname when prompted.
- Review the summary and confirm to apply, or decline to revert all changes automatically.