Objective

The objective is to configure static IP address on Ubuntu 18.10 Cosmic Cuttlefish Linux

Operating System and Software Versions

  • Operating System: - Ubuntu 18.10 Cosmic Cuttlefish Linux

Requirements

Privileged access to Ubuntu 18.10 system will be required.

Difficulty

EASY

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

Instructions

Ubuntu Desktop

The simplest approach on how to configure a static IP address on Ubuntu 18.10 Desktop is via GNOME graphical user interface:
Open network settings Ubuntu 18.10
Click on the top right network icon and select settings of the network interface you wish to configure to use a static IP address.


Start network configuration to set static IP address
Click on the settings icon to start configuration.
Static IPv4 IP address Ubuntu 18.10
Select IPv4 tab.
enter your desired static IP address
Select manual and enter your desired static IP address, netmask, gateway and DNS settings. Once ready click Apply button.


apply your new network configuration settings
Turn OFF and ON switch to apply your new network configuration settings.
confirm your new IP address settings
Click on the network settings icon once again to confirm your new IP address settings.

Ubuntu Server

To configure a static IP address on your Ubuntu 18.10 server you need to modify a relevant netplan network configuration file within /etc/netplan/ directory.

For example you might find there a default netplan configuration file called 50-cloud-init.yaml with a following content using the networkd deamon to configure your network interface via DHCP:
# 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:
            addresses: []
            dhcp4: true
    version: 2



Default dynamic IP address settings on Ubuntu 18.10 Server
Default dynamic IP address settings on Ubuntu 18.10 Server
To set your network interface enp0s3 to static IP address 192.168.1.233 with gateway 192.168.1.1 and DNS server as 8.8.8.8 and 8.8.4.4 replace the above configuration with the one below.
WARNING:
You must adhere to a correct code indent for each line of the block. In other words the prefix number of spaces for each line is important. Othersiwe you may end up with an error message similar to: Invalid YAML at //etc/netplan/01-netcfg.yaml line 7 column 6: did not find expected key
# 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:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
     dhcp4: no
     addresses: [192.168.1.233/24]
     gateway4: 192.168.1.1
     nameservers:
       addresses: [8.8.8.8,8.8.4.4]
Ubuntu 18.10 server configured with static IP address.
Ubuntu 18.10 server configured with static IP address.
Once ready apply changes with:
$ sudo netplan apply
In case you run into some issues execute:
$ sudo netplan --debug apply
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME or create a JOB ALERT on LinuxCareers.com job portal.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions