How to Configure IP Addresses in Ubuntu: A Complete Beginner-Friendly Guide

1. Introduction

Configuring IP addresses in Ubuntu is a crucial process for improving network stability and performance. In particular, when using Ubuntu in server environments or specialized networks, proper IP address management becomes essential. This guide explains how to check and configure IP addresses on Ubuntu, from dynamic to static settings, in a beginner-friendly, step-by-step format. By understanding IP address configuration, you can optimize your Ubuntu network environment effectively.

2. Basic Knowledge of IP Addresses

An IP address is a unique identifier used when devices communicate over the Internet or a LAN (Local Area Network). It plays a vital role in sending and receiving data across networks, including the Internet. There are two types of IP addresses: IPv4 and IPv6.

Differences Between IPv4 and IPv6

  • IPv4: A 32-bit address commonly represented in decimal format, such as “192.168.1.1.” IPv4 has long served as the standard for Internet communication, but due to address exhaustion, migration to IPv6 is ongoing.
  • IPv6: A 128-bit address notation such as “2001:0db8:85a3:0000:0000:8a2e:0370:7334.” IPv6 provides an extremely large address space, making exhaustion unlikely for the foreseeable future.

This guide focuses primarily on configuring IPv4 addresses in Ubuntu.

3. How to Check IP Addresses in Ubuntu

Before configuring an IP address, it is important to verify the current settings. Ubuntu allows you to check IP address details using both the command line and the GUI.

Checking via Terminal

Enter the following command in the terminal to display network interface and IP address information:

ip address

This command lists IP addresses assigned to each interface (e.g., eth0, wlan0). The displayed information is useful for configuration and troubleshooting.

Checking via GUI

The GUI method is as follows:

  1. Click the network icon in the upper-right corner of the screen and select “Settings.”
  2. Open the “Network” menu, select the active connection, and click “Details.”
  3. IP address, subnet mask, gateway, and other details will be displayed.

This method is recommended for beginners because it allows easy IP address verification without using commands.

4. Configuring Dynamic IP Addresses (DHCP)

By default, Ubuntu assigns dynamic IP addresses using DHCP (Dynamic Host Configuration Protocol). The following explains how to configure DHCP settings.

Configuration Using netplan

Starting from Ubuntu 18.04, network settings are managed using netplan. Follow the steps below to configure a dynamic IP address.

  1. Locate the configuration file. Typically, a file such as /etc/netplan/01-netcfg.yaml is used.
  2. Edit the netplan file as follows:
   network:
     version: 2
     ethernets:
       eth0:
         dhcp4: true
  1. Apply the configuration.
   sudo netplan apply

File Location and Editing

Configuration files are stored in the /etc/netplan/ directory. Always create a backup before making changes. If an error occurs after applying the configuration, review the file contents carefully for mistakes.

5. Configuring Static IP Addresses

To use a fixed IP address instead of a dynamically assigned one, configure a static IP address.

Configuration Using netplan

  1. Edit the configuration file as shown below:
   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]
  1. Save the changes and apply them using netplan apply.
  2. The configured static IP address will now be assigned.

Configuring via GUI

To configure a static IP address using the GUI, open the network settings, select “Manual,” and enter the IP address, gateway, and DNS server values directly.

6. Important Notes When Changing Network Settings

There are several precautions to consider when modifying IP address settings.

Backing Up Configuration Files

Create a backup before editing configuration files to prevent connectivity issues caused by configuration mistakes.

Verifying Network Connectivity After Changes

After applying new settings, run the ip address command again to confirm that the changes were applied correctly. If the connection is lost, review the configuration for errors.

How to Fix Issues Caused by Configuration Mistakes

If connectivity problems occur due to incorrect configurations, restore the backup file and reapply the settings with netplan apply. You can also use journalctl to review error messages and identify the cause of the issue.

7. Frequently Asked Questions (FAQ)

What should I do if the configuration is not applied?

If netplan apply does not apply your settings, ensure that there are no indentation or syntax errors in the configuration file.

How do I resolve netplan errors?

Run sudo journalctl -xe to check logs and identify the details of the error. YAML formatting mistakes are a common cause of configuration failures.

How do I configure multiple network interfaces?

If your system has multiple interfaces, define settings separately for each interface. For example, configure eth0 and eth1 individually within the netplan file.

8. Summary

This guide explained how to configure IP addresses in Ubuntu. By following the step-by-step methods for both dynamic and static IP configurations, managing network settings in Ubuntu becomes much easier and more efficient.