Skip to main content

Command Palette

Search for a command to run...

Network settings for Ubuntu server

Updated
2 min read

Connecting to Network via Ethernet (Setting a Static IP Address and DNS):

Why Should You Set a Static IP on Ubuntu Server?
Assigning a static IP ensures your server retains the same address across reboots.

Step 1: Identify Your Ubuntu Server Network Interface

List your network interfaces by running the following command:

ip link

You’ll usually see names like eth0ens33, or enp0s3.

Step 2: Edit the Netplan Configuration

netplan is the modern, recommended tool for configuring a static IP in Ubuntu Server.

Netplan configurations are stored at /etc/netplan/. View the files with:

ls /etc/netplan/

Next, edit the YAML file (replace with your actual file name):

sudo vi /etc/netplan/config.yaml

Here’s an example static IP configuration for Ubuntu Server:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: false
      addresses:
        - 192.168.1.100/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses:
          - 8.8.8.8

Replace eth0 with your interface name. Adjust the IP, gateway, and DNS to match your network.

Step 3: Apply the Static IP Ubuntu Configuration

Once you have finished editing, apply the changes with:

sudo netplan apply

Step 4: Confirm your network connectivity with:

ip a

You can see your assigned IP Address.