IP Address Configuration on Ubuntu
IP Address Configuration on Ubuntu
Disable Cloud Init Network Config
By default, Ubuntu replaces network configuration on every reboot. To make your config persistent, create this file:
1
sudo nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
Add the following content:
1
network: {config: disabled}
Remove the old config:
1
sudo rm /etc/netplan/50-cloud-init.yaml
Create Network Configuration File
Create a new netplan configuration:
1
sudo nano /etc/netplan/10-netcfg.yaml
Static IP example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
network:
ethernets:
enp6s18:
addresses:
- 192.168.30.67/24
nameservers:
addresses:
- 192.168.30.250
search:
- dmnsn.com
routes:
- to: default
via: 192.168.30.254
version: 2
DHCP example:
1
2
3
4
5
network:
ethernets:
enp6s18:
dhcp4: true
version: 2
Set secure permissions on the file:
1
sudo chmod 600 /etc/netplan/10-netcfg.yaml
Apply the configuration:
1
2
sudo netplan apply
ip addr
Note: On a minimal Ubuntu install you may get an error about
ovswitch. Fix it with:
1 2 sudo apt-get install openvswitch-switch-dpdk sudo netplan apply
This post is licensed under CC BY 4.0 by the author.