Ubuntu Network Configuration Guide: Setup, Troubleshooting, and Tips

目次

1. Getting Started

When is Network Configuration Necessary in Ubuntu?

Ubuntu is a popular Linux distribution widely used for everything from desktop use to server operations. In most cases, the network is configured automatically, but there are many situations where manual network configuration is required.

For example:

  • Setting a static IP address when operating as a server
  • When you want to manually specify a DNS server
  • When a special network configuration such as a VPN is required
  • When configuring from the CLI in an environment where the GUI is not available

In such cases, understanding Ubuntu’s network configuration is crucial.

Is Ubuntu’s Network Configuration a Bit Complex?

In older versions of Ubuntu, it was common to edit the configuration file /etc/network/interfaces, but now Netplan, a new method, is the standard, and NetworkManager is often used in GUI environments.

This has led to an increase in users wondering, “Which method should I use to configure?”

  • Beginners who want to easily configure via the GUI
  • Intermediate and advanced users who want to operate freely with the command line
  • Administrators who want a minimal configuration for cloud or server use

It is necessary to choose the appropriate configuration method according to each user’s needs.

What You Will Learn in This Article

This article explains network configuration in Ubuntu in an easy-to-understand manner for beginners, while comprehensively introducing the following:

  • Configuration procedures for both GUI (NetworkManager) and CLI (Netplan, nmcli)
  • How to connect to wired LAN and Wi-Fi
  • How to set a static IP address
  • How to specify DNS servers and connect to VPNs
  • Troubleshooting common network problems
  • FAQ regarding network configuration

By reading this article, your concerns about Ubuntu’s network configuration will be resolved, and you will be able to perform the appropriate settings according to your purpose.

2. Understanding Ubuntu’s Network Configuration Mechanism

Basic Structure of Network Management in Ubuntu

In Ubuntu, network configuration and management are done through NetworkManager or Netplan. A characteristic feature is that the tool used differs depending on the version and usage (desktop or server).

NetworkManager is Mainstream in Desktop Environments

In versions with a GUI, such as Ubuntu Desktop (e.g., Ubuntu 22.04 LTS), NetworkManager manages network settings. This is a highly convenient tool that can be operated graphically, allowing even beginners to configure network settings intuitively.

NetworkManager has the following features:

  • Automatic connection to wired/wireless networks
  • Manual IP address configuration
  • DNS and proxy management
  • VPN connection management

In addition, nmcli and nmtui are also provided as CLI tools for terminal operation. This allows for flexible configuration even in situations where the GUI is not available.

Netplan is Used for Server Purposes

On the other hand, in configurations without a GUI, such as Ubuntu Server, a new network configuration system called Netplan is adopted. Netplan is a mechanism that describes configuration details in YAML format files and applies them to the system with netplan apply.

The background for introducing Netplan includes the following reasons:

  • Easy to centrally manage configuration files
  • Good compatibility with infrastructure automation tools (such as Ansible)
  • Excellent integration with systemd, supporting modern configurations

Netplan allows switching between lower-level renderers such as NetworkManager and systemd-networkd, enabling flexible operation according to the environment.

/etc/network/interfaces is Deprecated

In Ubuntu, /etc/network/interfaces, which was previously used for network configuration, is now deprecated in most environments.

This file is used only in older versions (Ubuntu 16.04 and earlier) and in some special cases. Currently, Netplan’s YAML configuration files (e.g., /etc/netplan/01-netcfg.yaml) are the standard.

3. How to Connect to a Network in Ubuntu

There are two ways to connect to the internet in Ubuntu: using a GUI tool and using the command line (CLI). Here, we will explain the specific steps to connect to wired LAN or Wi-Fi using either method.

Network Connection Using GUI (NetworkManager)

Connecting to Wired LAN

Wired LAN is usually automatically recognized and connected simply by plugging in the cable. However, if you want to manually set the IP address, follow these steps:

  1. Click the network icon in the upper right corner of the screen
  2. Select “Wired Connection” → “Settings”
  3. Open the “IPv4” tab
  4. Change “Automatic (DHCP)” to “Manual”
  5. Enter the IP address, subnet, gateway, and DNS
  6. Save and apply

Connecting to Wi-Fi

Connecting to Wi-Fi is also very easy. You can connect to an access point by following these steps:

  1. Click the network icon
  2. A list of available Wi-Fi networks will be displayed
  3. Select the SSID you want to connect to
  4. Enter the password and connect

Network Connection Using CLI (Command Line Interface)

In server environments where the GUI is not available, or when operating remotely via SSH, you need to configure network connections from the CLI. Here, we will mainly use the nmcli command.

Checking and Enabling Wired Connection

nmcli device status
nmcli device connect enp0s3

Steps to Connect to Wi-Fi

nmcli device wifi list
nmcli device wifi connect "SSID name" password "password"

Checking Connection Status

nmcli connection show --active

Understanding both GUI and CLI allows you to flexibly handle any Ubuntu environment.

4. How to Configure a Static IP Address

Setting a static IP address is necessary when operating an Ubuntu server or building a specific communication environment. Here, we will introduce both methods: using the GUI (NetworkManager) and using the CLI (Netplan).

How to Set a Static IP Using GUI (NetworkManager)

In the Ubuntu desktop environment, you can graphically change network settings. You can set a static IP using the following steps:

Configuration Steps

  1. Click the network icon in the upper right corner of the screen
  2. Select “Settings” or “Connected Network”
  3. Switch to the “IPv4” tab
  4. Change “Automatic (DHCP)” to “Manual”
  5. Enter the following information in the “Addresses” field
  • IP Address (e.g., 192.168.1.100)
  • Netmask (e.g., 255.255.255.0)
  • Gateway (e.g., 192.168.1.1)
  1. Specify DNS (e.g., 8.8.8.8, etc.) if necessary
  2. Click the “Save” button and reconnect

To apply the settings, turn the network connection off and on again, or restart your computer.

How to Set a Static IP Using CLI (Netplan)

In environments without a GUI, such as Ubuntu Server, you will use Netplan for configuration. With Netplan, you describe the information in a YAML format configuration file and then apply it with a command.

1. Check the Location of the Configuration File

Usually, the configuration file is located in one of the following:

  • /etc/netplan/00-installer-config.yaml
  • /etc/netplan/01-netcfg.yaml

Edit it as follows:

2. Example of YAML File Editing

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: no
      addresses:
        - 192.168.1.100/24
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 1.1.1.1]

enp0s3 may vary depending on your environment. Please check with the ipa command.

3. Apply the Configuration

sudo netplan apply

Checking Configuration and Troubleshooting

After setting, you can check if it has been applied correctly with the following command:

ip a

If you cannot connect to the network, try using the ping command to see if you can communicate with the gateway or an external DNS.

ping 8.8.8.8

5. How to Change DNS Servers

If your internet connection in Ubuntu is unstable or name resolution takes time, reviewing the DNS server settings can be effective. Also, in corporate networks or privacy-focused environments, you may want to use specific DNS servers.

Here, we will introduce how to change DNS servers using both GUI (NetworkManager) and CLI (Netplan).

How to Specify DNS Servers in GUI

To change the DNS settings on Ubuntu Desktop, follow these steps:

Steps:

  1. Click the network icon in the upper right corner
  2. Open “Settings” or “Wi-Fi/Wired Connection”
  3. Select the “IPv4” or “IPv6” tab
  4. Manually enter the DNS address in the “DNS” field (e.g., 8.8.8.8, 1.1.1.1)
  5. Uncheck “Automatic DNS” (may be automatically disabled depending on your Ubuntu version)
  6. Save and reconnect to the network

After applying the settings, you can check the DNS operation by opening the terminal and using the following command:

dig www.google.com

Or

systemd-resolve --status

How to Change DNS Using CLI (Netplan)

If you are using Netplan on a server or other environment, you will also specify the DNS within the YAML file.

1. Open the Configuration File

sudo nano /etc/netplan/01-netcfg.yaml

2. Example: Manually Setting DNS

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: no
      addresses:
        - 192.168.1.100/24
      gateway4: 192.168.1.1
      nameservers:
        addresses:
          - 8.8.8.8
          - 1.1.1.1

3. Apply the Configuration

sudo netplan apply

4. Check the DNS Status

resolvectl status

Or,

cat /etc/resolv.conf

resolv.conf is a symbolic link, and direct editing is not recommended. Always configure through Netplan or NetworkManager.

Relationship Between systemd-resolved and DNS

In Ubuntu, systemd-resolved is responsible for DNS resolution, and /etc/resolv.conf is generated by this service. If you want to specify your own DNS, you need to be aware of the behavior of systemd-resolved.

You can also restart it as follows:

sudo systemctl restart systemd-resolved

6. How to Configure a VPN Connection

When using Ubuntu, you may need to set up a VPN (Virtual Private Network) connection. This could be for secure access to a corporate network, ensuring security when using public Wi-Fi, or bypassing regional restrictions.

Ubuntu supports multiple VPN protocols, such as OpenVPN and L2TP/IPsec, and can be configured through both GUI and CLI. Here, we will explain the configuration steps for typical VPN connections.

How to Configure OpenVPN in GUI (Using NetworkManager)

Install Necessary Packages

sudo apt update
sudo apt install network-manager-openvpn-gnome

After installation, it is best to restart Ubuntu once.

Configuration Steps

  1. Right-click the network icon → Select “VPN Connections” or “Add a VPN Connection…”
  2. Choose “OpenVPN” and click “Create…”
  3. Enter the configuration information provided by your VPN server:
  • Server address
  • Authentication method (Username + Password or Certificate)
  • CA certificate and private key (if required)
  1. Configure proxy and DNS settings if necessary
  2. Save the settings and enable the connection

Once the connection is successful, a “lock” icon will appear in the upper right corner of the screen.

How to Configure L2TP/IPsec in GUI

Install Additional Packages

sudo apt install network-manager-l2tp-gnome

Restarting after installation will display the L2TP options.

Configuration Steps

  1. Select “L2TP” from “Add a VPN Connection…”
  2. Enter the server address, username, and password
  3. Go to “IPsec Settings” → Enter the Pre-shared Key
  4. In advanced settings, check options such as MPPE (Microsoft Point-to-Point Encryption)
  5. Save and try to connect

How to Configure OpenVPN in CLI

In environments without a GUI, you can also establish an OpenVPN connection from the command line.

1. Install Packages

sudo apt install openvpn

2. Execute the Connection Command

If you have received a .ovpn file from your VPN service provider, connect as follows:

sudo openvpn --config your-config.ovpn

※ If password authentication is required, you will be prompted for it in the terminal.

Troubleshooting VPN Connection Issues

If the VPN connection fails, check the following:

  • Is the server address and port number correct?
  • Are there any firewall settings (ufw) or ISP restrictions?
  • Are the necessary certificate files correctly placed?
  • Check error logs with journalctl -xe or /var/log/syslog

Even when configuring via the GUI, NetworkManager logs the information in the background, so you can check the status using the nmcli command or systemctl status NetworkManager.

7. Common Network Problems and Solutions

Even with network configuration in Ubuntu, you may encounter issues such as “Why can’t I connect to the internet?” or “Wi-Fi networks are not displayed.” Here, we will introduce the common causes of these problems and their specific solutions.

Basic Checks When the Network is Not Connecting

If you cannot connect to the network, troubleshoot the problem in the following order:

1. Check Hardware Connections

  • Is the wired LAN cable securely connected?
  • Is the wireless adapter enabled (is the Wi-Fi switch ON)?

Check the device status with the command:

nmcli device status

If the Wi-Fi adapter shows “unavailable” or “disconnected,” the hardware may not be recognized.

2. Check if an IP Address Has Been Obtained

ip a

If a network interface (e.g., enp0s3 or wlp2s0) has not been assigned an IP address correctly, DHCP failure or configuration errors may be the cause.

3. Check Network Reachability

Check if you can reach the gateway with the following command:

ping 192.168.1.1

Checking connectivity to an external site like Google’s DNS is also effective:

ping 8.8.8.8

If it works with the IP address but not with the domain name, there is a DNS configuration issue.

Wi-Fi is Not Recognized / SSID is Not Displayed

If the Wi-Fi chip is not recognized correctly, the driver may be missing.

Solution:

lshw -C network

If this command shows “UNCLAIMED,” the driver is not loaded.

You can check if proprietary drivers are available with the following command:

sudo ubuntu-drivers devices

If a recommended driver is displayed, install it and restart:

sudo apt install [recommended driver name]

Name Resolution Fails Due to DNS Issues

  • If you can connect via IP address but not by domain name, there is a problem with the DNS settings.
  • Check the current DNS settings with resolvectl status or cat /etc/resolv.conf.

Solution:

Specify a public DNS server like Google’s (8.8.8.8, etc.) in the Netplan or NetworkManager settings and reconnect.

Changes to Settings Are Not Applied

  • If the network does not respond even after making changes in the GUI, you need to reconnect or restart.
  • In a CLI environment, apply the changes explicitly with the following command:
sudo netplan apply

Restarting NetworkManager can also be effective:

sudo systemctl restart NetworkManager

8. Frequently Asked Questions About Ubuntu Network Configuration

Here are some frequently asked questions about Ubuntu network configuration that many users, from beginners to intermediate users, tend to have. The following FAQ is based on commonly searched queries and troubleshooting cases.

Q1: Wi-Fi is not displayed in Ubuntu. What should I do?

A1:
The Wi-Fi adapter may not be recognized correctly. First, check the device status with the following command:

lshw -C network

If “UNCLAIMED” or “DISABLED” is displayed, there may be a driver issue. Take the following steps:

  1. Check for available drivers:
sudo ubuntu-drivers devices
  1. Install the recommended driver:
sudo apt install [displayed recommended driver]
  1. After restarting, check if Wi-Fi is enabled

Q2: I set a static IP address, but I can’t connect to the internet. Why?

A2:
Please double-check the following:

  • Is the gateway IP address correct (e.g., 192.168.1.1)?
  • Is the DNS server configured correctly (e.g., 8.8.8.8)?
  • Is the subnet mask (prefix) setting appropriate (e.g., /24)?

Typos in the YAML file or failure to execute netplan apply can also be the cause.

Q3: Can I complete network configuration using only the CLI?

A3:
Yes, it is possible. In server environments without a GUI, the following two are mainly used:

  • nmcli: Network configuration based on NetworkManager
  • netplan: YAML-based configuration method (Ubuntu 18.04 and later)

For example, you can connect to Wi-Fi as follows:

nmcli device wifi connect "SSID" password "password"

To set a static IP, edit the YAML file with Netplan and then apply it with:

sudo netplan apply

Q4: Is a restart required to apply configuration changes?

A4:
There are ways to apply settings without restarting:

  • In a GUI environment, turn the network off and on again
  • In a CLI environment, you can apply the changes with the following command:
sudo netplan apply

Or,

sudo systemctl restart NetworkManager

Q5: How can I reset network settings to default?

A5:
If you are using NetworkManager, you can reset by deleting existing connection profiles.

nmcli connection show
nmcli connection delete <connection name>

If you are using Netplan, edit the configuration files to reset their content and then run netplan apply again.

9. Conclusion

Ubuntu’s network configuration involves multiple methods depending on the purpose and environment, which can be confusing at first. However, by understanding the content introduced in this article, you will gain solid knowledge applicable to users from beginners to advanced.

Main Points Covered in This Article

  • Intuitive network connection and configuration using GUI (NetworkManager)
  • Flexible configuration in server environments using CLI (nmcli and Netplan)
  • Detailed methods for setting static IP addresses and DNS
  • Procedures for VPN connections such as OpenVPN and L2TP/IPsec
  • Specific examples of troubleshooting common problems
  • Answers to frequently searched questions (FAQ)

Choose the Method That Suits Your Environment

The optimal method for network configuration changes depending on how you are using Ubuntu.

Usage ScenarioRecommended Configuration Method
Desktop UseIntuitive operation with GUI (NetworkManager)
Server/Cloud UseReliable configuration with CLI (Netplan)
Remote OperationManagement with SSH + nmcli or YAML configuration
Security FocusedEnhanced security with VPN + manual DNS configuration

A Stable Network Greatly Impacts Work Efficiency

Ubuntu’s appeal lies in its flexible customization, but on the other hand, configuration errors can cause communication issues. By utilizing this guide, you can eliminate any “vague anxieties” regarding network configuration and operate with confidence.

If you encounter any unclear points or difficulties during the configuration process, please refer back to this article as many times as needed. It contains systematically organized information from basic to advanced levels.

This concludes the complete guide to “Ubuntu Network Configuration.”
As a next step, we recommend progressing to more advanced security management, such as configuring network monitoring tools and firewalls.