1. Introduction
Setting up an IP address on Ubuntu is a crucial process for improving network stability and performance. Proper IP address management is essential, especially when using Ubuntu in server environments or specific network setups. This guide provides a step-by-step explanation of how to check and configure IP addresses on Ubuntu, including both dynamic and static settings, in a way that is easy for beginners to understand. Master IP address configuration and optimize your Ubuntu network environment.
2. Basic Knowledge of IP Addresses
An IP address is a unique identifier used for communication between devices on the Internet or a local area network (LAN). It plays a vital role in sending and receiving data across networks, including the Internet. There are two main types of IP addresses: IPv4 and IPv6.
Differences Between IPv4 and IPv6
- IPv4: A 32-bit address, typically represented in decimal format, such as “192.168.1.1.” IPv4 has been the standard for many years, but due to the exhaustion of available addresses, there is an ongoing transition to IPv6.
- IPv6: A 128-bit address, written in a format like “2001:0db8:85a3:0000:0000:8a2e:0370:7334.” Since IPv6 provides a vastly larger address pool, it is unlikely to run out in the foreseeable future.
This guide primarily focuses on configuring IPv4 addresses on Ubuntu.
3. How to Check Your IP Address on Ubuntu
Before configuring an IP address, you should first check your current IP address. On Ubuntu, you can check your IP address using either the command line or the GUI.
Checking via Terminal
Enter the following command in the terminal to display information about network interfaces and IP addresses:
ip address
This command will list the IP addresses assigned to each interface (e.g., eth0
, wlan0
). This information is useful for both configuration and troubleshooting.
Checking via GUI
You can also check your IP address using the graphical interface by following these steps:
- Click the network icon in the top right corner and select “Settings.”
- Go to the “Network” menu, select your current network connection, and click “Details.”
- Your IP address, subnet mask, gateway, and other details will be displayed.
This method is recommended for beginners as it provides an easy way to check IP settings.

4. Configuring a Dynamic IP Address (DHCP)
By default, Ubuntu assigns a dynamic IP address using DHCP (Dynamic Host Configuration Protocol). Here’s how to configure it.
Configuring with netplan
Starting from Ubuntu 18.04, netplan
is used for network configuration. Follow these steps to set up a dynamic IP address:
- Locate the configuration file, usually found at
/etc/netplan/01-netcfg.yaml
or a similar path. - Edit the
netplan
file as follows:
network:
version: 2
ethernets:
eth0:
dhcp4: true
- Apply the configuration.
sudo netplan apply
Configuration File Location and Editing
Configuration files are stored in the /etc/netplan/
directory. Always create a backup before editing. If you encounter errors when applying changes, double-check the settings for any mistakes.
5. Configuring a Static IP Address
If you want to use a specific IP address instead of a dynamically assigned one, you need to configure a static IP address.
Configuring with netplan
- Edit the configuration file with the following settings:
network:
version: 2
ethernets:
eth0:
dhcp4: no
addresses:
- 192.168.1.100/24
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
- Save the configuration file and apply the changes with
netplan apply
. - Your Ubuntu system will now use the specified static IP address.
Configuring via GUI
If you prefer to configure a static IP using the graphical interface, follow these steps:
- Open the network settings.
- Select your current connection and choose the “Manual” option.
- Enter the desired IP address, gateway, and DNS servers.

6. Important Considerations When Changing IP Settings
There are several important factors to consider when modifying IP address settings.
Backing Up Configuration Files
Before making any changes, always create a backup of the configuration file. This precaution helps prevent network issues caused by misconfigurations.
Verifying Network Connection After Applying Settings
After applying changes, check whether the new IP address is correctly assigned by running the ip address
command. If the connection is lost, verify the settings for errors.
Troubleshooting Connection Issues Due to Configuration Errors
If a configuration error prevents network connectivity:
- Restore the backup file.
- Apply the original settings again using
netplan apply
. - Use
journalctl
to check for error messages and troubleshoot the issue.
7. Frequently Asked Questions (FAQ)
What to Do If the Settings Are Not Applied?
If netplan apply
does not apply the settings, check for indentation errors or syntax mistakes in the configuration file.
How to Resolve netplan
Errors?
Use sudo journalctl -xe
to inspect error logs and identify the issue. YAML formatting errors are a common cause of configuration problems.
How to Configure Multiple Network Interfaces?
If your system has multiple network interfaces, you must define separate configurations for each. For example, if your system has eth0
and eth1
, assign specific settings to each interface within the netplan
configuration file.
8. Conclusion
This guide has provided a detailed explanation of how to configure an IP address on Ubuntu. By following the step-by-step instructions, you can easily manage network settings, whether you need a dynamic or static IP address.