Setup static ip on ubuntu-server
·1 min
Table of Contents
Setup static ip on ubuntu-server #
Using netplan
- First checkout your interface name:
$ ip a
Image 2. Now edit your netplan config file:
$ sudo nano /etc/netplan/netplan-config.yaml
- 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.
NOTE: YAML files are highly space sensitive.
- 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.