How to Install Ubuntu Server and Set a Static IP Address: Complete Step-by-Step Guide

Are you looking to set up an Ubuntu Server with a fixed IP address? Whether you’re hosting a website, running an application, or managing files, having a static IP is essential for reliable network connections. In this guide, you will learn how to install Ubuntu Server and configure a static IP address using two simple methods:

  1. Set static IP during installation
  2. Configure static IP after installation using Netplan

Why Use a Static IP Address on Ubuntu Server?

A static IP address ensures that your server’s IP does not change over time. This stability is important because:

  • It allows reliable remote access
  • Network devices can always find your server
  • Essential for web hosting, database servers, and network services

Step 1: Download and Prepare Ubuntu Server Installation Media

  1. Download Ubuntu Server ISO:
    Visit the official Ubuntu website at ubuntu.com/download/server and download the latest Long Term Support (LTS) version.
  2. Create a Bootable USB Drive:
    Use tools like Rufus (Windows) or balenaEtcher (Mac/Linux) to flash the ISO image onto a USB stick (minimum 4GB).
  3. Boot from USB:
    Insert the USB drive into your computer or server. Restart and access the boot menu by pressing keys like F12, F2, DEL, or ESC (depending on your system). Choose the USB drive to start the Ubuntu Server installer.

Step 2: Install Ubuntu Server and Set a Static IP Address During Installation

During installation, you can configure your server’s IP address manually to set a static IP.

  1. Select your preferred language and keyboard layout.
  2. At the Network Configuration screen, select Configure network manually instead of DHCP.
  3. Enter your network details based on this example:
Setting Example Value
IP Address 192.168.10.50
Subnet Mask 255.255.255.240 (/28)
Gateway 192.168.10.49
DNS Server 8.8.8.8

The /28 subnet mask corresponds to 16 IP addresses ranging from 192.168.10.48 to 192.168.10.63. The first address (192.168.10.48) is the network address, and the last (192.168.10.63) is the broadcast address. Usable IPs are in between, like 192.168.10.50.

  1. Set your timezone, create a username, and password.
  2. Select the disk for installation (usually Use entire disk).
  3. Finish installation and reboot your server after removing the USB drive.

Step 3: Configure Static IP on Ubuntu Server Using Netplan (After Installation)

If you didn’t set a static IP during installation or want to update it later, you can use Netplan to configure your network.

3.1 Identify Your Network Interface Name

Run the following command in the terminal:

ip a

Look for an interface name such as enp0s3, eth0, or ens160.

3.2 Edit the Netplan Configuration File

Open the Netplan YAML configuration file using a text editor:

sudo nano /etc/netplan/00-installer-config.yaml

Replace or modify the file contents with the following example, adjusting the interface name and IP details as needed:

network:
  version: 2
  ethernets:
    enp0s3:
      dhcp4: no
      addresses:
        - 192.168.10.50/28
      gateway4: 192.168.10.49
      nameservers:
        addresses:
          - 8.8.8.8

Save the file (Ctrl + O), then exit (Ctrl + X).

3.3 Apply the Netplan Configuration

Apply the changes with:

sudo netplan apply

3.4 Verify the Static IP Address

Check the network interface to confirm the new static IP:

ip a

Step 4: Test Network Connectivity

Verify that your network configuration works properly by pinging your gateway and a public website:

ping 192.168.10.49
ping google.com

Additional Tips for Ubuntu Server Network Setup

  • Choose a static IP outside your DHCP server’s range to avoid IP conflicts.
  • Keep your server updated for security and performance improvements:
sudo apt update && sudo apt upgrade -y
  • Use SSH to connect remotely to your Ubuntu Server:
ssh username@192.168.10.50

Conclusion

Setting up a static IP address on Ubuntu Server is simple and critical for stable networking. You can configure a static IP either during installation or afterward using Netplan. Follow the steps in this guide to ensure your server is always reachable on your network.

Leave a Reply

Your email address will not be published. Required fields are marked *