How to Configure Network on Ubuntu Server

Step-by-Step Guide: To configure Temporary & Permanent Network Configuration

Configuring network settings is one of the most essential tasks for any system administrator working with Ubuntu or Linux servers. Whether you need a quick temporary fix for troubleshooting or a permanent setup for production, Ubuntu provides powerful tools to manage network interfaces, IP addresses, gateways, and DNS servers.

This guide walks you through both temporary and permanent network configurations with clear commands and explanations.

1. Adding Network Adapters to Your Ubuntu VM

In our previous post, we created a virtual machine and installed the Ubuntu Server OS. Now, we’ll extend its networking capabilities by adding two network adapters: one for internet connectivity and another for private/internal communication.

 

Steps to Add Network Adapters

  1. Edit VM Settings.
  2. Add Two Network Adapters.
    • Click AddNetwork AdapterOK
  3. Configure the Adapters.
    • Adapter 1 (Internet Access): Set to Bridge Mode. This allows the VM to connect directly to your physical network and access the internet.
    • Adapter 2 (Private Network): Set to Custom or Host‑Only. This creates an isolated virtual network for internal communication between VMs and Host.
  4. Confirm the settings and click OK. Configure Network on Ubuntu Server - Add network Adaptor

With the adapters added, you’re ready to start the VM and configure the network interfaces inside Ubuntu. This will involve assigning IP addresses, setting up routes, and ensuring both internet and private connectivity work seamlessly. If you’d like to watch a step‑by‑step walkthrough of these steps, please visit our YouTube Video.

2. Check Network Interfaces on Ubuntu Server.

Before making changes, identify your network devices and their names. Knowing the correct interface name is crucial before applying configurations.

  • Run the following command to list all physical network adapters:
  • Command: –   sudo lshw -class network
  • This will display details of all available network interfaces. At this stage, you’ll notice that both Ethernet interfaces are in a disabled state.
  • Ubuntu assigned names like ens36 or ens37 to ethernet interfaces. Network Configuration on Ubuntu Server - Eth disabled
  • ensXX → Ethernet interface with a system‑assigned identifier.

Knowing these names ensures you apply the correct configuration to the right adapter.

 

3. Temporary Network Configuration on Ubuntu Server

As we’ve seen, both network adapters are initially in a disabled state. We’ll enable them temporarily and apply test configurations. These settings will be lost after a reboot, but temporary settings are useful for testing network or troubleshooting.

 

    1. Set Ethernet State.
      • sudo ip link set dev ens36 up      (Use up to enable, ens36 is the interface name).
      • sudo ip link set dev ens36 down      (Use down to disable, ens36 is the interface name).
    2. Ethernet interface is enabled now but there is no IPv4 address on Bridge network.Network Configuration on Ubuntu Server - Enabled Eth
    3. Renew IP via DHCP.
      • sudo dhclient ens36      (ens36 is the interface name).
      • This requests a fresh IP address from the DHCP server for the specified interface.
    4. Check IP and Interface Details.
      • ip a  – shows all interfaces and their IPs.
      • ethtool ens36  – provides detailed hardware information.
      • ip address show dev ens36  – displays IP details for a specific interface.Network Configuration on Ubuntu Server - IP Renew
    5.  IPv4 is assigned now, you can test the internet connectivity.
      • Ping -c 4 google.com     (“-c 4” to send 4 ICMP packets).Network Configuration on Ubuntu Server - ping web
    6. Assign a Temporary Static IP to Secondary ethernet interface (ens37).
      • sudo ip addr add 192.168.137.10/24 dev ens37
      • This assigns a temporary static IP (192.168.137.10) to ens37.
      • Check the status and connectivity with Host via Private VNet. (ping -c 4 192.168.137.1).
        Network Configuration on Ubuntu Server - Static IP
    7. View and Configure Routes or Gateway IP if required.
      • ip route show  – This lists current routes/gateways.
      • sudo ip route del default  – To delete current routes.
      • sudo ip route add default via 192.168.137.1 dev ens37   – Add default gateways as needed, here gateway IP is 192.168.137.1 and ens37 is the interface name.Network Configuration on Ubuntu Server - Add routes

4. Permanent Network Configuration with Netplan on Ubuntu Server

For persistent network settings, Ubuntu relies on Netplan. Any changes made here are written into the Netplan configuration files and will survive system reboots. This ensures that your IP addresses, routes, and adapter states remain consistent across sessions.

 

Steps:-

    1. Backup Netplan Config before editing.
      • sudo cp /etc/netplan/00-installer-config.yaml 00-installer-config.yaml.copy
      • This will create a copy (00-installer-config.yaml.copy) of original file (00-installer-config.yaml).
      • Useful in case of accidental misconfiguration.
    2. Edit Netplan Config for permanent network configuration.
      • Edit the Netplan configuration file with a text editor such as nano or vim. Here, we’ll use nano.
      • sudo nano /etc/netplan/00-installer-config.yaml
      • Use spaces only—no tabs—in YAML formatting and use the format as it is else configuration will be corrupted.
      • Example configuration: – (copy without backticks`
				
					```
network:
  version: 2
  ethernets:
    ens36:
      dhcp4: true
    ens37:
      dhcp4: false
      addresses: [192.168.137.10/24]
      routes:
        - to: 0.0.0.0/0
          via: 192.168.137.1
          metric: 200
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]
```

				
			
      • In the above config file, ens36 → uses DHCP for automatic IP assignment.
      • ens37 → has a static IP, gateway, and DNS servers defined.
      • Routes and nameservers can be customized or removed as per requirement.Network Configuration on Ubuntu Server - Netplan Config
    1. Save the config file.
      • Press Ctrl+X key → Press Y for confirm
      • Press Enter with same name.
    2. Apply NetPlan changes.
      • sudo netplan apply
    3. Verify the Network configuration.
      • ip a
    4. Reboot and verify configuration.
      • ip a
      • ip route show
      • ping -c 2 google.com
      • ping -c 2 192.168.137.1Network Configuration on Ubuntu Server - Permanent IP

With these steps, your Ubuntu server’s network configuration is complete. You now have both temporary commands for quick troubleshooting and permanent Netplan settings for production stability.

 

Pro Tip: Always test connectivity after applying changes and keep a backup of your Netplan configuration.

We have successfully configured both external and private networks on Ubuntu server with temporary and permanent methods.

Discover more:

Head over to our Blog page for the latest posts.

Share Your Thoughts

Your email address will not be published. Required fields are marked *

Scroll to Top