This Bash script is designed to simplify the process of changing a dynamic IP address to a static IP address on Ubuntu Server 24.04.
It provides a comprehensive step-by-step walkthrough, making it user-friendly for individuals with limited technical expertise but need their Ubuntu server up and running with a static IP configuration.
- Welcome Message: Provides an initial greeting and a brief overview of the script’s functionality.
- User Authentication: Displays the current user executing the script and prompts for confirmation to proceed.
- Network Interface Detection: Identifies an active network interface (ensure only one connection/ethernet cable is plugged in).
- Current Network Settings: Retrieves and displays the current IP address, netmask, gateway, and checks the status of DHCP4 and DHCP6.
- User Input Prompts: Prompts the user to enter a new static IP, netmask, gateway, DNS servers, and hostname.
- Netplan Configuration Management: Locates the existing netplan configuration file, creates a backup, and generates a new configuration file based on user input.
- Apply Configuration: Prompts the user to apply the new netplan configuration. If the user chooses not to apply, the script reverts to the original configuration and terminates.
- Run the Script: Execute the script as root on your Ubuntu Server 24.04.
- Follow the Prompts: The script will guide you through each step, from detecting the current network settings to applying the new static IP configuration.
- Confirmation: Confirm the changes to apply the new configuration or revert to the original settings if needed.
- Ubuntu Server 24.04
- Bash
Clone the repository:
git clone https://github.com/projects-by-ac/dynamic-to-static-ip.git
Navigate to the script directory:
cd dynamic-to-static-ip
Make the script executable:
sudo chmod +x static-ip.sh
Run the script:
sudo ./static-ip.sh