1. The Configuration File
Netplan configurations are stored in .yaml files within /etc/netplan/. Common filenames include 01-netcfg.yaml or 50-cloud-init.yaml.
2. Standard Configuration Template
Below is the corrected version of your configuration. Note that in modern Netplan, gateway4 is deprecated in favor of the explicit routes block.
YAML
network:
version: 2
renderer: networkd
ethernets:
ens1:
dhcp4: false
addresses:
- 10.11.17.5/24
nameservers:
addresses:
- 8.8.8.8
- 1.1.1.1
routes:
- to: default
via: 10.11.17.1
3. Key Parameters Explained
Parameter | Description |
|---|---|
| The name of the physical network interface. Use |
| Disables automatic IP assignment from a DHCP server. |
| Your static IP address in CIDR notation (e.g., |
| Defines the default gateway ( |
| Specifies DNS servers (in this case, Google Public DNS). |
4. Applying the Changes
To avoid losing connection due to a syntax error, follow these three steps:
Step A: Test the configuration
This command will check for errors and automatically roll back if you don't confirm the changes within 120 seconds.
Bash
sudo netplan try
Step B: Apply the configuration
If the test is successful, apply the settings permanently:
Bash
sudo netplan apply
Step C: Verify the status
Confirm that the IP address has been assigned to the interface:
Bash
ip addr show ens1
Important Note on YAML Formatting:
Netplan is extremely sensitive to indentation. Always use spaces, never tabs. Ensure that each level of the hierarchy is indented by exactly two spaces relative to the level above it.