# How to configure static IP on Ubuntu?

{% embed url="<https://youtu.be/zksMjvLVbeQ>" %}

### Overview

This is a step-by-step tutorial on how to configure a static IP address on an Ubuntu server using netplan and a desktop computer with NetworkManager. For servers, a static IP address is advised since it is more reliable than a dynamic IP address assigned by a DHCP server.

Some service providers may provide two separate customers the same IP address due to a lack of IP addresses or to cut costs. In this case, the customer might face some connection issues. While static IP numbers are user-specific, they do not result in the same issues, but you should still be cautious because your IP address might be used inappropriately in a number of ways.

All recent Ubuntu releases, including the most current are compatible with this guide. Both the GUI and command line methods for setting a static IP address that Ubuntu provides are discussed here.

### Prerequisites

There are certain prerequisites that need to be met before you begin:

* An ubuntu system or server
* Root privilege or access via sudo command

### Get Started&#x20;

#### Step-1: Accessing the .yaml file

* Type the following command to check the name of your system network interface:

```
ip a
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1418_image-2023-4-24_12-45-47.png)

* Type the following command to go to the netplan directory:

```
cd /etc/netplan
```

* Type the following command to list the files in the netplan directory:

```
ls
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1419_image-2023-4-24_12-48-9.png)

#### Step-2: Changing the network configuration in .yaml file

* Type the following command to open the configuration file, replace the file name with your .**yaml** file:<br>

```
sudo nano 50-cloud-init.yaml
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1420_image-2023-4-24_12-50-46.png)

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1421_image-2023-4-24_12-53-6.png)

* Change the following configurations in the file.&#x20;

```
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:    #Modify this line according to your preferred network interface name.
      dhcp4: false
      addresses:
        - 192.168.1.10/24    #Replace with your IP Address
      gateway4: 192.168.1.1
      nameservers:
        addresses:
          - 8.8.8.8
          - 8.8.4.4
```

* After making the modifications shown above, press ctrl+x then Y and press enter to save the changes done.

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1422_image-2023-4-24_13-2-26.png)

* Apply the changes using the following command:

```
sudo netplan apply
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1423_image-2023-4-24_13-4-3.png)

* Type the following command to verify the changes and network configuration.

```
ip addr show dev ens3
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1424_image-2023-4-26_13-7-6.png)

### Conclusion

Now you can access your Ubuntu server using the static IP you have set in this process. You can also set up multiple IPs using this process.&#x20;
