# Static IP configuration on Ubuntu 20.04
### Netplan
Ubuntu 17.10 and later uses Netplan as the default network management tool. The previous Ubuntu versions were using ```ifconfig``` and its configuration file ```/etc/network/interfaces``` to configure the network.
### Configuring Static IP address on Ubuntu Server
In Ubuntu 20.04 LTS server, network configuration is controlled and managed by netplan utility. But during the installation, cloud-init configure a dynamic ip to interface on server if the dhcp server is available. so, to configure a static ip, first we must make sure and confirm that network interface is not managed by cloud-init.
```
$ cat /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
```
and make sure entry ```network: {config: disabled}``` is here.
The first step toward setting up a static IP address is identifying the name of the ethernet interface you want to configure. To do so, use the ```ip link``` command, as shown below:
```
$ ip link
```
The command prints a list of all the available network interfaces. In this example, the name of the interface is ```enp3s0f1```:
```
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp3s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 80:fa:5b:37:8e:36 brd ff:ff:ff:ff:ff:ff
3: wlp4s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether b0:c0:90:5e:0e:b1 brd ff:ff:ff:ff:ff:ff
```
To assign a static IP address on the network interface, open the YAML configuration file with your text editor.
```
sudo vim /etc/netplan/00-installer-config.yaml
```
As it is an yaml file, so while making the changes in the file we must follow correct indentation. Add the following lines to the yaml file,
```
network:
ethernets:
enp3s0f1:
addresses: [140.112.XX.XX/24]
gateway4: 140.112.XX.254
nameservers:
addresses: [1.1.1.1, 8.8.8.8]
version: 2
```
save and close the file.
Run the following ```sudo netplan apply``` command to make the above changes into the effect.
### Reference
https://www.linuxtechi.com/assign-static-ip-address-ubuntu-20-04-lts/
https://linuxize.com/post/how-to-configure-static-ip-address-on-ubuntu-20-04/