Error message

  • Warning: include(secrets.inc): Failed to open stream: No such file or directory in include() (line 20 of /var/www/ashonthe.net/custom/include/functions.inc).
  • Warning: include(): Failed opening 'secrets.inc' for inclusion (include_path='.:/var/www/custom') in include() (line 20 of /var/www/ashonthe.net/custom/include/functions.inc).

How to configure IP address with Netplan on Ubuntu 18.04

Forums: 



Firstly edit the netplan config file

sudo nano /etc/netplan/*.yaml

Format

     version: 2
     Renderer: NetworkManager/ networkd
     ethernets:
        eth0:
          dhcp4: yes/no
          addresses: [IP_ADDRESS/NETMASK]
          gateway4: GATEWAY
          nameservers:
              addresses: [NAMESERVER_1, NAMESERVER_2]



Example for DHCP

     version: 2
     renderer: networkd
     ethernets:
        eth0:
          dhcp4: yes



Example for static IP address:

     version: 2
     renderer: networkd
     ethernets:
        eth0:
          dhcp4: no
          addresses: [192.168.1.1/24]
          gateway4: 192.168.1.254
          nameservers:
              addresses: [1.1.1.1, 8.8.8.8]



Apply the new config

sudo netplan apply