Categories
Linux kernel & processes Network Ubuntu

Configure IP address on Ubuntu 18.04

Check does exist netplan in the current Ubuntu installed distro

$ ls /etc/net <let's tap Tab>
netplan/             network/             networkd-dispatcher/ networks
$ ls /etc/netplan/50-cloud-init.yaml

Edit this *.yaml file

# 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:
        ens18:
            addresses:
            - 192.168.1.100/24
            gateway4: 192.168.1.1
            nameservers:
                addresses:
                - 192.168.1.1
                - 8.8.8.8
    version: 2

So, you can edit address: value in whatever you need, then save and close this file

Finally, apply changes with netplan command:

$ netplan apply
ERROR: cannot create file run/systemd/network/10-netplan-ens18: Failed to create file “/run/systemd/network/10-netplan-ens18.network.J87WE0”: Permission denied
$ sudo netplan apply
[sudo] password for someuser:
$

Oh, yes, sure, you have to have sudo permissions 🙂

For sure let’s do debug:

sudo netplan --debug apply
** (generate:11510): DEBUG: 21:21:36.262: Processing input file /etc/netplan/50-cloud-init.yaml..
** (generate:11510): DEBUG: 21:21:36.262: starting new processing pass
** (generate:11510): DEBUG: 21:21:36.262: ens18: setting default backend to 1
** (generate:11510): DEBUG: 21:21:36.263: Configuration is valid
** (generate:11510): DEBUG: 21:21:36.263: Generating output files..
** (generate:11510): DEBUG: 21:21:36.263: NetworkManager: definition ens18 is not for us (backend 1)
DEBUG:netplan generated networkd configuration changed, restarting networkd
DEBUG:no netplan generated NM configuration exists
DEBUG:ens18 not found in {}
DEBUG:Merged config:
network:
  bonds: {}
  bridges: {}
  ethernets:
    ens18:
      addresses:
      - 192.168.1.100/24
      gateway4: 192.168.1.1
      nameservers:
        addresses:
        - 192.168.1.1
        - 8.8.8.8
  vlans: {}
  wifis: {}

DEBUG:Skipping non-physical interface: lo
DEBUG:device ens18 operstate is up, not changing
DEBUG:{}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for ens18

is it OK? I believe you well done!

Have You More questions? Please be free to ask us your questions in the
Dzhumaiev.Slack.com channel 🙂

Leave a Reply