Error message

  • Warning: preg_match(): Unknown modifier '2' in os_check() (line 193 of /var/www/custom/tools/tools.inc).
  • Warning: preg_match(): Unknown modifier 'T' in os_check() (line 193 of /var/www/custom/tools/tools.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