Network Configurations

I'm using the command nmcli for set the IP of a ubuntu 18.04.5

"nmcli device modify ens33 ipv4.method manual ipv4.address X.X.X.X/X ipv4.gateway X.X.X.X ipv4.dns X.X.X.X"

and the ip changes wihthout problem, but after if I reboot the ubuntu after the IP goes to DHCP (fresh instalation of ubuntu).

with the grahical interface manager I have no problem but the code is for running in a server withtout GUI.

  • is a server but I use the nmcli to manage the wifi network card saids and passwords. One eth0 and a wan0

Solution 1:

In a server, without a desktop environment, set your details in the file found in /etc/netplan. Here are some examples:

ls /usr/share/doc/netplan/examples

Most likely, your template is:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s0:
      addresses:
        - 10.10.10.2/24
      gateway4: 10.10.10.1
      nameservers:
        search: [mydomain, otherdomain]
        addresses: [10.10.10.1, 1.1.1.1]

Netplan is strict about indentation, spacing, etc., so proofread carefully twice. Follow with:

sudo netplan generate
sudo netplan apply

You should be all set.