Back

Configuring IP Addresses in Ubuntu: Quick Reference

Networking in Ubuntu has always been frustrating and inconsistent for me. Hope this helps you as much as it helps me.

1. /etc/NetPlan/<any file>:

#### This file commonly shows up as '00-installer-config.yaml'
#### but it may also show up starting with a '50' or something
#### else. If no such file exists, try a different configuration
#### file.
#### NOTE: Because YAML is YAML, indentation must be spaces and
#### must be precise.
network:
  ethernets:
    eth0:
      addresses:
        - 10.2.3.4/24
      nameservers:
        addresses: [10.2.3.2,8.8.8.8]
      routes:
        - to: default
          via: 10.2.3.1
    # DHCP Example
    eth1:
      dhcp4: true
  version: 2

#### Apply your configuration using 'sudo netplan apply'.

2. /etc/network/interfaces:

#### Can also put these in files in /etc/network/interfaces.d/

auto iface eth1

3. ip

#### Note: I don't recommend using ip. See the words for more.

sudo ip link set dev eth0 address 10.2.3.4/24
sudo ip link set dev eth1 address dhcp

4. The Words

Hello!