TL;DR
To configure a static IP address on Ubuntu, you can follow these steps:
- View your current IP address using
ifconfigand check its details like subnet mask and gateway. - List all network interfaces on Ubuntu with
ip link show, showing their names and status. - Check the status of the desired interface with
ip a show [interface]. - Ensure the selected static IP falls within your network’s range but outside the DHCP pool to avoid conflicts.
- Edit the netplan configuration file, adding the desired static IP address, subnet mask, gateway, and DNS settings. Save the changes, restart the networking service, and verify the new static IP using
ifconfig
To configure a static IP address on your network, follow best practices like regularly reviewing and updating IP settings, keeping a log of network changes, implementing additional security measures, and planning for network scalability. Be cautious of common errors such as IP conflicts, incorrect settings, inactive interfaces, and typos in configuration files to ensure a smooth and stable static IP configuration on your Ubuntu system.
Continue reading the guide below to learn the step-by-step method to configure a static IP address on Ubuntu. also , learn abou the common errors that can occur during configuration and the best practices to follow.
Configuring a static IP address on your Ubuntu machine is the way to go! A static IP address eliminates the risk of IP conflicts, which can disrupt network communication. It ensures that your device is always accessible at the same address, reducing downtime. In this comprehensive guide, I’ll walk you through the step-by-step process to configure static IP address on Ubuntu system. I will also explore some best practices and common errors that can occur when configuring the static IP address.
How to Configure a Static IP Address on Ubuntu
To configure a static IP address on Ubuntu, you need administrative privileges and access to a functional network interface. Ensure there are available IP addresses within the network’s range to avoid conflicts. Modifying network configuration files or using the Network Manager GUI allows you to assign a stable IP address, enhancing network stability, secure hosting, and performance.
- Open a Terminal.

- Run the following command to view your current IP address:
<strong>ifconfig</strong> - This will show you the IP address, subnet mask, and gateway address of your current network interface.

- Use the following command to list all network interfaces on your Ubuntu system:
<strong>ip link show</strong> - This will show you a list of all the network interfaces on your system, including their names and status.

- Check the status of each interface with by running the following command to ensure they are up and running.
<strong>ip a show [interface]</strong> Replace interface with the interface name of which you want to check the status of.

- Know your network’s subnet mask and gateway address for proper IP assignment. Select an IP address that falls within your network’s address range but outside the DHCP pool. Avoid using IP addresses that are already assigned to other devices.
- Run the following command to check for any conflicting responses.
<strong>ping [static IP address]</strong> - If you receive responses, the IP address is already in use, and you should choose another.

- Run this command to list netplan configuration file:
<strong>ls /etc/netplan/</strong> - The command will list the netplan configuration file.

- Now run the following command:
<strong>sudo cp /etc/netplan/01-network-manager-all.yaml /etc/netplan/01-network-manager-all.yaml.bak</strong> - The command will create a backup of netplan configura .

creating-backup-of-netplan-configuration-file
- Now execute the command:
<strong>sudo nano /etc/netplan/01-netcfg.yaml</strong> - The command will open the netplan configuration file.

- Add the following lines below it, adjusting the values accordingly:
<strong>network:</strong>
<strong> version: 2</strong>
<strong> renderer: NetworkManager</strong>
<strong> ethernets:</strong>
<strong> enp0s3: # Change this to your interface name if different</strong>
<strong> dhcp4: no</strong>
<strong> addresses: [10.0.2.100/24] # Replace with your desired static IP and subnet mask (e.g., "192.168.1.100/24")</strong>
<strong> gateway4: 10.0.2.1 # Replace with your gateway address</strong>
<strong> nameservers:</strong>
<strong> addresses: [8.8.8.8, 8.8.4.4] # Replace with your DNS server ad</strong> - Applying Changes and Restarting the Network Service. Save the changes and exit the text editor (press Ctrl + X, then Y, and Enter).

applying-changes-to-netplan-configuration-file
- Restart the networking service using the command: