Static IP Configuration - Ubuntu 22.04.2
By default Ubuntu will create a file called 00-installer-config.yaml under /etc/netplan/ you can either create another yaml file but I like to adjust the configuration of the default one since its easier.
1. Open up the config file in nano or your preferred editor.
sudo nano -K /etc/netplan/00-installer-config.yaml
2. Use the example configuration pages below to adjust your settings. The difference between the two examples is just formatting, either will work.
Example 1:
network:
version: 2
ethernets:
ens160: #Interface, you can run (ip -a) in the shell to find the exact one you want
dhcp4: no
addresses:
- 10.1.0.20/24 #IP Address with subnet
routes:
- to: default
via: 10.1.0.1 #Routers IP
nameservers:
search: [in.rem.pub, dmz.rem.pub] #Allows host name lookup without FQDN
addresses: [10.1.0.50, 10.1.0.51] #DNS Servers, Primary and Secondary
Example 2:
network:
version: 2
ethernets:
ens160: #Interface, you can run (ip -a) in the shell to find the exact one you want
dhcp4: no
addresses:
- 10.1.0.20/24 #IP Address with subnet
routes:
- to: default
via: 10.1.0.1 #Routers IP
nameservers:
search: #Allows host name lookup without FQDN
- in.rem.pub
- dmz.rem.pub
addresses: #DNS Servers, Primary and Secondary
- 10.1.0.50
- 10.1.0.51
If you are using IPv6, the addresses must be inside quotes.
3. Apply the configuration.
sudo netplan apply
No Comments