Setup static ip on ubuntu-server 22.04 lts

Using netplan

  1. First checkout your interface name:

$ ip a  

Image 2. Now edit your netplan config file:

$ sudo nano /etc/netplan/netplan-config.yaml  
  1. Now enter the following:

network:
  version: 2
  rendered: networkd
  ethernets:
    [interface name]:
      dhcp4: no
      addresses: 
        - 192.168.1.10/24
      gateway4: 192.168.1.1
      nameservers:
        addresses: 
	- 8.8.8.8
	- 8.8.4.4
	- 8.8.4.4

Here we have disabled DHCP and given a local ip with gateway and nameservers. 4. After saving the above file:

$ sudo netplan try netplan-config.yaml

This will test the configuration and will ask to revert to default if some error is seen.

Last updated