The objective is to configure static IP address on Ubuntu 18.04 Bionic Beaver Linux

In this tutorial you will learn:
  • How to set static IP address on Ubuntu Desktop and Server
  • How to set static gateway and DNS server
DID YOU KNOW?
By default your current Ubuntu system uses DHCP server to configure its networking settings. Hence, the configuration of your IP address is dynamic. In many scenarios, simply configuring your router or local DHCP server is a preferred way to set a static address to any host regardless of the operating system in use. Check your router manual and assign the static IP address to your host based on its MAC address using the DHCP service.
Static IP address on Ubuntu 20.04 Focal Fossa Desktop/Server
Static IP address on Ubuntu 20.04 Focal Fossa Desktop/Server

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Installed or upgraded Ubuntu 20.04 Focal Fossa
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

How to configure static IP address on Ubuntu 20.04 step by step instructions


SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


Configure Static IP address on Desktop



  1. select settings corresponding to the network interface
    Click on the top right network icon and select settings corresponding to the network interface you wish to assign with the static IP address.


  2. Next, click on the gear box icon next to your network connection you wish to configure. This could be wired or wireless connection.
    Next, click on the gear box icon next to your network connection you wish to configure. This could be wired or wireless connection.


  3. Select IPv4 tab
    Select IPv4 tab.


  4. Set IPv4 Method to Manual
    Set IPv4 Method to Manual. Optionally disable the Automatic method for DNS or Routes to configure them manually.


  5. Enter desired static IP address DNS and Routes.
    Enter desired static IP address DNS and Routes. Click on Apply button.


  6. Restart your network by ON/OFF switch.
    Restart your network by using the provided ON/OFF switch.


  7. Check your new static IP address configuration.
    Check your new static IP address configuration.


Configure Static IP address on Server

In this example we will set a static IP address on the Ubuntu 20.04 server to 192.168.1.202/24 with default gateway to 192.168.1.1 and DNS servers 8.8.8.88.8.4.4192.168.1.1.

  1. Locate and edit with administrative privileges the /etc/netplan/50-cloud-init.yaml file with the following configuration. Update your desired static IP address, DNS server and gateway where appropriate:
    # This file is generated from information provided by
    # the datasource.  Changes to it will not persist across an instance.
    # To disable cloud-init's network configuration capabilities, write a file
    # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
    # network: {config: disabled}
    network:
        ethernets:
            enp0s3:
                dhcp4: false
                addresses: [192.168.1.202/24]
                gateway4: 192.168.1.1
                nameservers:
                  addresses: [8.8.8.8,8.8.4.4,192.168.1.1]
        version: 2
    
    Save the file.
    Configure static IP address on Ubuntu 20.04 Server
    Configure static IP address on Ubuntu 20.04 Server
  2. To apply the new Netplan changes execute:
    $ sudo netplan apply
    
    Alternatively, if you run into some issues run:
    $ sudo netplan --debug apply
    


  3. Confirm your new static IP address by using the ip linux command:
    $ ip a
    
    Check current IP address
    Check current IP address

Troubleshooting

Question mark over the network icon on GNOME desktop

The question mark over the network icon on GNOME desktop means that from some reason the network internal self-check failed.
The workaround is to to disable the Connectivity Checking switch.
The workaround is to to disable the Connectivity Checking switch.
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.