---
title: "Dive Deep into this Ubuntu Network Configuration Guide"
description: "Learn the ins-and-outs of a Ubuntu network through this Ubuntu network configuration guide to take your networking game to the next level!"
canonical: "https://adamtheautomator.com/ubuntu-network-configuration-guide/"
---

# Dive Deep into this Ubuntu Network Configuration Guide

> Learn the ins-and-outs of a Ubuntu network through this Ubuntu network configuration guide to take your networking game to the next level!

Source: https://adamtheautomator.com/ubuntu-network-configuration-guide/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Dive Deep into this Ubuntu Network Configuration Guide](https://adamtheautomator.com/wp-content/uploads/2022/09/Dive-Deep-into-this-Ubuntu-Network-Configuration-Guide.jpg)

# Dive Deep into this Ubuntu Network Configuration Guide

[![](https://secure.gravatar.com/avatar/b4cd4a109fc359fca6ccc8a192dd75bf9a440677bb2a87da8c23f48d76b3bb39?s=192&d=mm&r=g)Edem Afenyo](https://adamtheautomator.com/author/edem-afenyo/)19 September 20228 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Networking](/tag/networking/)[Ubuntu Linux](/tag/ubuntu-linux/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Configuring Network via the CLI](#configuring-network-via-the-cli)
*   [Changing the Hostname for Network Identification](#changing-the-hostname-for-network-identification)
*   [Disabling Dynamic Host Control Protocol (DHCP) for All Interfaces](#disabling-dynamic-host-control-protocol-dhcp-for-all-interfaces)
*   [Adding a Temporary MAC Address](#adding-a-temporary-mac-address)
*   [Adding a Temporary Static IP address](#adding-a-temporary-static-ip-address)
*   [Configuring a Temporary Name Resolution](#configuring-a-temporary-name-resolution)
*   [Configuring Persistent Networking with NetworkManager](#configuring-persistent-networking-with-networkmanager)
*   [Configuring Persistent Name Resolution with NetworkManager](#configuring-persistent-name-resolution-with-networkmanager)
*   [Configuring Static Name Resolution](#configuring-static-name-resolution)
*   [Configuring Persistent Networking with Netplan](#configuring-persistent-networking-with-netplan)
*   [Configuring Networking via the GUI](#configuring-networking-via-the-gui)
*   [Conclusion](#conclusion)

Network configuration is valuable for an administrator or even a regular user to help troubleshoot issues with internal and external connectivity. But what are the various ways of configuring networking? No worries! This Ubuntu network configuration guide has got you covered.

In this tutorial, you will learn how to set up various Ubuntu networking components to control your network better and how your host connects to the internet.

Ready? Stay tuned to level up your Ubuntu networking skills!

## Prerequisites

This tutorial will be a hands-on demonstration. If you would like to follow along, be sure you have the following:

*   An Ubuntu machine as the host – This tutorial uses version [Ubuntu 22.04](https://adamtheautomator.com/install-ubuntu/).

Related:[How to Install Ubuntu 20.04 \[Step-by-Step\]](https://adamtheautomator.com/install-ubuntu/)

*   A user with sudo privileges.

## Configuring Network via the CLI

Network configuration is somewhat of a complex task, especially when you do not know which platform to use. But if you are on a command-line environment most of the time, configuring your network via the CLI suits you best.

But first, you must check your machine’s hostname for network identification.

Fire up your terminal, and run the below [hostnamectl](https://man7.org/linux/man-pages/man1/hostnamectl.1.html) command to see the current hostname of your machine.

```bash
hostnamectl
```

Below, you can see the machine’s hostname is the generic **localhost**.

![Listing hostname details](https://adamtheautomator.com/wp-content/uploads/2022/09/image-364.png)

Listing hostname details

### Changing the Hostname for Network Identification

While localhost may be okay when working with just one machine, identifying machines gets confusing when you have to work with more than one machine, and all are called localhost.

1\. Run the below hostnamectl command again, but this time, with the set-hostname switch to change the hostname (atamach01).

This tutorial uses atamach01 as the hostname, but you can choose any that works for you or your organization’s naming policy.

```bash
hostnamectl set-hostname atamach01
```

2\. Next, reboot your machine to apply the changes.

3\. After reboot, rerun the following command to confirm the changes have taken effect

```bash
hostnamectl
```

As you can see below, the hostname has changed to atamach01.

![Verifying the hostname change](https://adamtheautomator.com/wp-content/uploads/2022/09/image-365.png)

Verifying the hostname change

Related:[How to Update Ubuntu IP and Hostname via Bash](https://adamtheautomator.com/change-linux-ip-hostname-bash-script/)

### Disabling Dynamic Host Control Protocol (DHCP) for All Interfaces

Before configuring Internet Protocol (IP) settings, you must disable [DHCP](https://www.techtarget.com/searchnetworking/definition/DHCP) for multiple interfaces. Disabling DHCP creates a scenario where no working configuration is present on a machine, and you have to configure networking from scratch for better control over your network.

> _Since your machine configuration may differ, you may not have the same network interface names. Ensure you replace the network interface names throughout this tutorial with yours accordingly._

To disable DCHP on your network configuration:

1\. Run the following ip a command to list all network interfaces on your machine with their corresponding network addresses (a).

```bash
ip a
```

You will see a list of network interfaces, as shown below. The machine in this tutorial has three network interfaces, and the default loopback interface — yours may differ.

Take note of the interfaces; you will need to disable DCHP on each of them later.

![Listing network interface details](https://adamtheautomator.com/wp-content/uploads/2022/09/image-366.png)

Listing network interface details

2\. Next, open the default [Netplan](https://netplan.io/) configuration file (_/etc/netplan/01-network-manager-all.yaml_) on your preferred code editor, and add the following code. Netplan is a network configuration generator for Ubuntu.

Ensure you replace the interfaces under ethernets with the ones you noted in step one.

```yaml
network:
  version: 2
  renderer: NetworkManager
  # Disabling DCHP on all network interfaces
  ethernets:
    enp0s3:
	    dhcp4: no
    enp0s8:
      dhcp4: no
    enp0s9:
      dhcp4: no
```

3\. Lastly, execute the below [netplan apply](https://man.archlinux.org/man/netplan-apply.8.en) command, which does not provide output but applies the changes immediately.

```bash
sudo netplan apply
```

### Adding a Temporary MAC Address

[Layer 2 networking](https://www.helpsystems.com/blog/basics-layer-2) involves nodes with Media Access Code (MAC) addresses. Though the MAC address is permanently mapped to the device, you can change the MAC address in modern operating systems if you are privacy conscious ([MAC spoofing](https://en.wikipedia.org/wiki/MAC_spoofing)).

But note that because hardware manufacturers permanently assign MAC addresses, changes to the MAC address are temporary.

Execute the [ip link](https://man7.org/linux/man-pages/man8/ip-link.8.html) command below to set the temporary MAC address to the enp0s9 network interface to 22:11:33:AA:BB:CC.

```bash
sudo ip link set dev enp0s9 address 22:11:33:AA:BB:CC
```

Now, run the `ip a` command to confirm the changes have taken effect.

```bash
ip a 
```

As in the screenshot below, your MAC address should have changed. Notice that the original address is still attached to the interface.

![Ubuntu network configuration guide : Displaying network interface details](https://adamtheautomator.com/wp-content/uploads/2022/09/image-367.png)

Ubuntu network configuration guide : Displaying network interface details

### Adding a Temporary Static IP address

Up to this point, you have seen how to configure non-IP-related networking components. Now, it is time to configure your machine to communicate over the network using IP, starting with assigning an IP address.

Run the ip a command below to add an IPv4 address (192.168.100.16) to the enp0s3 interface.

> _IP addresses must conform to networking standards and match the subnet details of the network your machine is joined to._

```bash
sudo ip a add 192.168.100.16/24 dev enp0s3
```

Now, run the following `ip a` command without parameters to confirm that the change has taken effect.

```bash
ip a
```

Your screen should have output akin to the one below.

![](https://adamtheautomator.com/wp-content/uploads/2022/09/image-368.png)

Displaying network interface details

Related:[Get an IP Address on Linux : Discover the Many Ways](https://adamtheautomator.com/get-an-ip-address-on-linux/)

> _Perhaps you plan to direct all traffic without an explicitly specified route to the address of the internet-facing router on your network. If so, run the following command to add a default route via an IP address (192.168.100.1)._

```bash
sudo ip route add default via 192.168.100.1
```

### Configuring a Temporary Name Resolution

After the previous configurations you made, you can now reach the internet. But right now, you cannot install packages or browse the web effectively without domain name resolution.

Related:[How to Set Up PowerDNS on Ubuntu Linux](https://adamtheautomator.com/powerdns/)

To set up a temporary name resolution, add a public name server to _/etc/resolv.conf_ as follows:

1\. Open _/etc/resolve.conf_ in your editor, add the address of [CloudFlare](https://www.cloudflare.com/)’s public nameserver (nameserver 1.1.1.1), save the changes, and return to the terminal.

Place CloudFlare’s nameserver above the first nameserver to ensure your entry is used for resolution, similar to the one below.

![Editing Nameserver configuration in /etc/resolv.conf](https://adamtheautomator.com/wp-content/uploads/2022/09/image-369.png)

Editing Nameserver configuration in /etc/resolv.conf

2\. Now, open your favorite web browser, and navigate to [www.google.com](https://www.google.com/) (or any reliable website) to confirm your machine is fully configured. You will see [Google](https://www.google.com/)’s homepage on your screen if all goes well, as shown below.

![Testing network access](https://adamtheautomator.com/wp-content/uploads/2022/09/image-370.png)

Testing network access

3\. Finally, reboot your machine to clear all the transient network settings.

### Configuring Persistent Networking with NetworkManager

Configuring the network with temporal settings is only useful for running tests and troubleshooting. How do you persist configuration on Ubuntu? By using [NetworkManager](https://manpages.debian.org/unstable/network-manager/NetworkManager.conf.5.en.html) via its Text User Interface (TUI) tool.

To persist network configuration with NetworkManager:

1\. Execute the [nmtui](https://man.archlinux.org/man/nmtui.1) command below to access NetworkManager TUI.

```bash
sudo nmtui
```

2\. Select the Edit a connection option, and hit ENTER when greeted with the text-based UI below to access the list of network interfaces available on your host.

![Accessing the NetworkManager TUI](https://adamtheautomator.com/wp-content/uploads/2022/09/image-371.png)

Accessing the NetworkManager TUI

3\. Navigate with the arrow keys on your keyboard to select a network interface (netplan-enp0s3), select <Edit…>, and press ENTER to configure network settings for the selected interface.

![Selecting a specific connection to configure](https://adamtheautomator.com/wp-content/uploads/2022/09/image-372.png)

Selecting a specific connection to configure

As shown below, you will see a list of editable properties for the selected interface (enp0s3).

![Editing a Network Connection: Displaying interface parameters](https://adamtheautomator.com/wp-content/uploads/2022/09/image-373.png)

Editing a Network Connection: Displaying interface parameters

4\. Now, navigate to and select <Link-Local> adjacent to IPv4 CONFIGURATION to select the configuration mode for the interface, as shown below.

![Editing a Network Connection: Changing the IP addressing mode](https://adamtheautomator.com/wp-content/uploads/2022/09/image-374.png)

Editing a Network Connection: Changing the IP addressing mode

5\. Lastly, select Automatic from the menu to direct NetworkManager to use DHCP for the interface.

![Enabling DHCP addressing mode](https://adamtheautomator.com/wp-content/uploads/2022/09/image-375.png)

Enabling DHCP addressing mode

### Configuring Persistent Name Resolution with NetworkManager

If your DHCP server is working fine, your machine should be ready for use. But note that the NetworkManager allows you to do more finetuning, like persisting name resolution.

1\. Select <Show> as in the shot below to expand a list of IP settings options you can manually configure.

![Accessing extra IP settings](https://adamtheautomator.com/wp-content/uploads/2022/09/image-376.png)

Accessing extra IP settings

![Displaying additional network settings](https://adamtheautomator.com/wp-content/uploads/2022/09/image-377.png)

Displaying additional network settings

2\. Next, navigate to the DNS servers option and enter 1.1.1.1 to override the DNS settings provided by DHCP persistently. Once you have set the DNS server, select <OK> and press ENTER to accept the changes.

The Edit Connection screen closes, and you will return to the network interface selection screen (step three).

![Setting DNS Servers](https://adamtheautomator.com/wp-content/uploads/2022/09/image-378.png)

Setting DNS Servers

3\. Select <Back> and press ENTER to return to the homepage.

![Returning to the home page](https://adamtheautomator.com/wp-content/uploads/2022/09/image-379.png)

Returning to the home page

4\. Now, select Activate a connection to reload the network connection and cause your changes to take effect immediately.

![Activating a network connection](https://adamtheautomator.com/wp-content/uploads/2022/09/image-380.png)

Activating a network connection

5\. Select the Deactivate option once to deactivate the connection you configured (netplan-enp0s3), as shown below.

![Deactivating a network connection](https://adamtheautomator.com/wp-content/uploads/2022/09/image-381.png)

Deactivating a network connection

6\. Next, select the <Activate>and press ENTER to re-activate the connection with your provided settings.

![Re-activating a network connection](https://adamtheautomator.com/wp-content/uploads/2022/09/image-382.png)

Re-activating a network connection

7\. Select Back to revert to the home page.

![Returning to the homepage](https://adamtheautomator.com/wp-content/uploads/2022/09/image-383.png)

Returning to the homepage

8\. Now, select Quit to return to the command line.

![Closing NetworkManager TUI](https://adamtheautomator.com/wp-content/uploads/2022/09/image-384.png)

Closing NetworkManager TUI

9\. Finally, navigate to [www.google.com](http://www.google.com/) on your web browser to confirm the settings work correctly.

![Testing the network connection status](https://adamtheautomator.com/wp-content/uploads/2022/09/image-370.png)

Testing the network connection status

### Configuring Static Name Resolution

Typically, you require DNS resolution for resources not covered by configured DNS servers. In such scenarios, you can edit the _hosts_ file to make such DNS mappings available to your system. A _hosts_ file also allows you to specify custom mappings as needed.

Open your _hosts_ file (_/etc/hosts_) in your text editor, and add your host’s IP address to domain name mapping, as shown below.

Note that the domain name **otherhost** and IP address **192.168.8.15** are arbitrary.

![Setting up static hostname resolution](https://adamtheautomator.com/wp-content/uploads/2022/09/image-386.png)

Setting up static hostname resolution

Next, execute the `ping` command to confirm that the DNS resolution for `otherhost` is as desired.

```bash
ping otherhost
```

If the change has taken effect, you will see the name you specified automatically resolved to the IP address you provided, as in the shot below.

![Testing static hostname resolution](https://adamtheautomator.com/wp-content/uploads/2022/09/image-387.png)

Testing static hostname resolution

### Configuring Persistent Networking with Netplan

In Ubuntu, you can also use Netplan YAML files to implement persistent networking configuration. Netplan’s use of YAML files provides an opportunity for automation with tools like [Ansible](https://www.ansible.com/).

Related:[Highly Effective Automation with Ansible AWX](https://adamtheautomator.com/ansible-awx/)

To configure persistent networking with Netplan:

1\. Open the Netplan’s default configuration file (_/etc/netplan/01-network-manager-all.yaml_) in a text editor and add the following snippet. Replace the values with yours accordingly, save the changes, and close the file.

The directives give enp0s8 a static IP with a default route and configure the machine with DNS servers 1.1.1.1 and 8.8.8.8

```yaml
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp0s8:
      dhcp4: no
      addresses:
        - 192.168.8.115/24
      routes:
        - to: default
          via: 192.168.8.1        
      nameservers:
          addresses: [1.1.1.1,8.8.8.8]
```

2\. Next, execute the netplan apply command to apply the changes immediately. Note that this command does not provide output, but you will verify the changes in the following step.

```bash
sudo netplan apply
```

3\. Now, execute the below ip a command to confirm the changes have taken effect.

```bash
ip a
```

If all goes well, you will see the network assignments, as in the screenshot below, confirming the configuration was successful.

![Verifying Netplan changes are applied](https://adamtheautomator.com/wp-content/uploads/2022/09/image-388.png)

Verifying Netplan changes are applied

## Configuring Networking via the GUI

You have seen that network configuration via the CLI works. But if you are more into a graphical interface that you can navigate around, you can also opt to set up networking using the Ubuntu **Settings’** GUI application.

1\. Open the Settings app, select the About tab in the navigation pane, and click Device Name to initiate renaming the hostname.

![Viewing the system’s information](https://adamtheautomator.com/wp-content/uploads/2022/09/image-389.png)

Viewing the system’s information

2\. Provide a new hostname and click Rename to save the hostname change.

![Changing hostname](https://adamtheautomator.com/wp-content/uploads/2022/09/image-390.png)

Changing hostname

3\. Next, select the Network tab to list all interfaces on your machine, and click the cog icon of an interface entry (enp0s9) to bring up the interface configuration window (step four).

![Editing network interface configuration](https://adamtheautomator.com/wp-content/uploads/2022/09/image-391.png)

Editing network interface configuration

4\. Now, configure IPv4 settings with the following:

*   Select the **IPv4** tab to switch to **IPv4** configuration mode.
    
*   Select the **Automatic** option to allow the interface to receive **DHCP** settings automatically. By default, these settings include the IP address, DNS servers, and route information.
    
*   Turn off the corresponding **Automatic** toggle buttons and supply the needed static values for **DNS** servers and IP **Routes**.
    
*   Once configured, click on **Apply** to immediately apply the changes.
    

![Switching to DHCP IP addressing mode and setting up IP routes and DNS servers](https://adamtheautomator.com/wp-content/uploads/2022/09/image-392.png)

Switching to DHCP IP addressing mode and setting up IP routes and DNS servers

5\. Finally, select the cog icon for the interface again (enp0s9) to verify the changes have taken effect.

![Verifying network configuration](https://adamtheautomator.com/wp-content/uploads/2022/09/image-393.png)

Verifying network configuration

If all is well, the correct details populate the Details tab, as shown below.

![Viewing network interface details](https://adamtheautomator.com/wp-content/uploads/2022/09/image-394.png)

Viewing network interface details

## Conclusion

By coming this far, you have learned to manage the network configuration of your Ubuntu machines with this Ubuntu network configuration guide. At this point, you can confidently manage how your host connects to the internet and troubleshoot your network if something goes haywire.

Network configuration management should always come in pair with securing your network. So why not set up a firewall for your Ubuntu machine or server?

Related:[How To Set Up the UFW Firewall on Linux](https://adamtheautomator.com/ufw-firewall/)

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fubuntu-network-configuration-guide%2F&text=Dive%20Deep%20into%20this%20Ubuntu%20Network%20Configuration%20Guide)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fubuntu-network-configuration-guide%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fubuntu-network-configuration-guide%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2022/07/How-to-Update-Ubuntu-IP-and-Hostname-via-Bash.jpg)

### [How to Update Ubuntu IP and Hostname via Bash](/change-linux-ip-hostname-bash-script/)

Discover and learn how to change a Linux IP and Hostname via a Bash script in this new tutorial by ATA Learning!

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

![](https://adamtheautomator.com/wp-content/uploads/2024/03/openldap-4.jpg)

### [How to Install and Configure an OpenLDAP Ubuntu Server](/openldap/)

Unlock the power of OpenLDAP on Ubuntu for centralized user authentication, seamless access control management, and enhanced directory services!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
