33 lines
678 B
Markdown
33 lines
678 B
Markdown
# **Netplan for Ubuntu VMs**
|
|
## Change DHCP to Static IP
|
|
### Edit /etc/netplan/50-cloud-init.yaml (change to match your netplan .yaml file)
|
|
|
|
```
|
|
network:
|
|
version: 2
|
|
ethernets:
|
|
enp6s18: # replace with your interface name
|
|
dhcp4: false
|
|
addresses:
|
|
- x.x.x.x/24 # your desired static IP
|
|
routes:
|
|
- to: default
|
|
via: x.x.x.x # your gateway
|
|
nameservers:
|
|
addresses:
|
|
- 1.1.1.1 # DNS — your gateway or preferred resolver
|
|
- 8.8.8.8
|
|
```
|
|
|
|
---
|
|
|
|
## Test and Apply changes
|
|
|
|
**Test if config takes**
|
|
|
|
```netplan try```
|
|
|
|
**Apply config**
|
|
|
|
```netplan apply```
|