You have to edit the netplan’s yaml file to configure static IP address on the system. Give your attention please. It’s required to use all chars as spaces in this yaml file. You have to copy and paste below lines to your file without any modification. Please give your attention to this point. Otherwise the system will throw an error when you try to apply netplan settings. Error could be look like “Error in network definition //etc/netplan/x.yaml line y column z: expected mapping“
Now cd into /etc/netplan/ directory and in this directory for reference, backup the original .yaml extensioned file and edit the .yaml extensioned file with sudo privileges. For example
And replace content with below lines.
Change A.A.A.A with your static IP Address and “/24” at this line defines your subnet mask. So that you do not need to enter subnet mask manually in another line.
Change G.G.G.G with your gateway’s IP address.
Change N.N.N.N with your preferred DNS’ IP address.
AND AGAIN DO NOT FORGET TO CHECK .yaml file for any more whitespaces or any other wrong or missmatching characters.
If modification done and all checks are as required than you can apply settings to your netplan with below command
if this command finishes succesfully that’s all for setting a static IP address on an Ubuntu 18.04 LTS Server or Desktop System via netplan.
If any error encounters then you can check with this command for detailed error information.