# Step-by-Step Guide to Configuring a Static IP on Ubuntu Server

## Overview

Goal: Assign a **static IP** to the Ubuntu server so it **remains the same across reboots**, allowing consistent SSH access from other devices. Problem: router DHC, Ubuntu server uses **cloud-init**, which can override the manual network settings after reboot.

1. Check Network Interface
    

```plaintext
ip a
```

* Find the Ethernet interface connected to your router
    
* Example output
    

```plaintext
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host noprefixroute valid_lft forever preferred_lft forever 
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:e0:4c:64:d4:90 brd ff:ff:ff:ff:ff:ff altname enp3s0 inet 192.168.1.*/24 metric 100 brd 192.168.1.255 scope global dynamic ens33 valid_lft 86151sec preferred_lft 86151sec inet6 2400:1a00:b030:29c2:2e0:4cff:fe64:d490/64 scope global dynamic mngtmpaddr noprefixroute valid_lft 949sec preferred_lft 949sec inet6 fe80::2e0:4cff:fe64:d490/64 scope link valid_lft forever preferred_lft forever
```

✅Interface name to use: ens33

2. Disable Cloud-init Network management
    
    Cloud-init may reset network changes on reboot. Disable it permanently:
    

```plaintext
sudo bash -c 'echo "network: {config: disabled}" > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg'
```

3. Configure Static IP with Netplan
    
    1. Open Netplan config file Netplan configuration file location is set to /etc/netplan/ directory. Depending on your Ubuntu installation Netplan configuration file can take one of the following three forms:
        
        * 01-netcfg.yaml
            
        * 01-network-manager-all.yaml
            
        * 50-cloud-init.yaml Now, open your configuration file:
            
        
        ```plaintext
        sudo vim /etc/netplan/50-cloud-init.yaml
        ```
        
    2. Replace the content with:
        
    
    ```plaintext
    network:
    	version: 2
    	ethernets:
    	ens33:
    		dhcp4: false
    		dhcp6: false
    		addresses:
    		- 192.168.1.*/24
    		routes:
    		- to: default
    		  via: 192.168.1.254
    		nameservers:
    			addresses: [8.8.8.8, 1.1.1.1]
    ```
    
    * Replace:
        
        * ens33: your interface name
            
        * 192.168.1.\* -&gt; desired static IP (outside router DHCP range)
            
        * 192.168.1.254 -&gt; your router's gateway IP
            
4. Apply the configuration
    

```plaintext
sudo netplan apply
```

* If using SSH, be aware that your connection may drop when IP changes.
    
* Verify new IP:
    

```plaintext
ip a
ping -c 4 8.8.8.8
```

5. Test SSH access from another device:
    

```plaintext
ssh <username>@192.168.1.*
```

* Confirm you can connect with the new static IP
    

6. Verify Persistence
    

* Reboot server
    

```plaintext
sudo reboot
```

* Check that the static IP is still active
    

```plaintext
ip a
```

7. Tips / Notes
    

* Always pick a static IP outside your router's DHCP range to avoid conflicts
    
* Using cloud-init disable ensures **manual network config is persistent.**
    
* You can also add **extra DNS servers** if needed.
