# 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
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1419_image-2023-4-24_12-48-9.png" alt="" height="57" width="800">

#### 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
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1420_image-2023-4-24_12-50-46.png" alt="" height="22" width="800">

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1421_image-2023-4-24_12-53-6.png" alt="" height="208" width="800">

* 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.

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1422_image-2023-4-24_13-2-26.png" alt="" height="365" width="800">

* Apply the changes using the following command:

```
sudo netplan apply
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1423_image-2023-4-24_13-4-3.png" alt="" height="32" width="800">

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

```
ip addr show dev ens3
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1424_image-2023-4-26_13-7-6.png" alt="" height="86" width="800">

### 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;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.acecloud.ai/knowledge-base/tutorials/how-to-configure-static-ip-on-ubuntu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
