Article

Table of Contents
Theme:
Was this article helpful?
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $300 by adding new articles!

Configure Ubuntu with Multiple IP Addresses

Last Updated: Wed, Jun 17, 2020
Networking System Admin Ubuntu

Introduction

A basic network configuration at Vultr consists of a single IPv4 address, configured by DHCP. If you have advanced networking requirements, Vultr supports multiple public IPs and up to five private networks. You need to manually configure these advanced scenarios. Refer to the networking configuration page in the customer portal for your exact configuration. This example demonstrates three public IPv4 addresses, two private IPv4 networks, and two public IPv6 addresses.

IPv4 Info

MultipleIP

IPv6 Info

MultipleIP

Example for Ubuntu 17.10 - 20.xx

Configure the public network with three public IPv4 addresses and two public IPv6 addresses.

Populate /etc/netplan/10-ens3.yaml with:

network:
version: 2
renderer: networkd
ethernets:
    ens3:
    dhcp4: no
    addresses: [192.0.2.101/23,192.0.2.102/32,192.0.2.103/32,'2001:db8:1000::100/64','2001:db8:1000::200/64']
    gateway4: 192.0.2.1
    nameservers:
        addresses: [192.0.2.200]
    routes:
    - to: 169.254.0.0/16
        via: 192.0.2.1
        metric: 100

Configure the first private network. Populate /etc/netplan/10-ens7.yaml with:

network:
version: 2
renderer: networkd
ethernets:
    ens7:
    match:
        macaddress: 5a:00:02:d6:f7:7a
    mtu: 1450
    dhcp4: no
    addresses: [10.1.1.100/20]

Configure the second private network. Populate /etc/netplan/10-ens8.yaml with:

network:
version: 2
renderer: networkd
ethernets:
    ens8:
    match:
        macaddress: 5a:01:02:d6:f7:7a
    mtu: 1450
    dhcp4: no
    addresses: [10.1.1.200/20]

Update networking or reboot.

# netplan apply

Example for Ubuntu 16.xx & 17.04

Configure the public network with three public IPv4 addresses and two public IPv6 addresses.

Populate /etc/network/interfaces with:

auto lo
iface lo inet loopback

auto ens3
iface ens3 inet static
    address 192.0.2.101
    netmask 255.255.254.0
    gateway 192.0.2.1
    dns-nameservers 192.0.2.200
    post-up ip route add 169.254.0.0/16 dev ens3

iface ens3 inet6 static
    address 2001:db8:1000::100
    netmask 64
    up /sbin/ip -6 addr add dev ens3 2001:db8:1000::200
    dns-nameservers 2001:db8:1000::1

auto ens3:1
iface ens3:1 inet static
    address 192.0.2.102
    netmask 255.255.255.255

auto ens3:2
iface ens3:2 inet static
    address 192.0.2.103
    netmask 255.255.255.255

# Private network: net5eea3b295857e
auto ens7
iface ens7 inet static
    address 10.1.1.100
    netmask 255.255.240.0
    mtu 1450

# Private network: net5eea4e6f7f6c8
auto ens8
iface ens8 inet static
    address 10.1.1.200
    netmask 255.255.240.0
    mtu 1450

Restart networking or reboot to activate the network changes.

# ifup ens3
# ifup ens7
# ifup ens8    

Example for Ubuntu 12.xx - 15.xx

Populate /etc/network/interfaces with:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 192.0.2.101
    netmask 255.255.254.0
    gateway 192.0.2.1
    dns-nameservers 192.0.2.200
    post-up ip route add 169.254.0.0/16 dev eth0

iface eth0 inet6 static
    address 2001:db8:1000::100
    netmask 64
    up /sbin/ip -6 addr add dev eth0 2001:db8:1000::200
    dns-nameservers 2001:db8:1000::1

auto eth0:1
iface eth0:1 inet static
    address 192.0.2.102
    netmask 255.255.255.255

auto eth0:2
iface eth0:2 inet static
    address 192.0.2.103
    netmask 255.255.255.255

# Private network 1
auto eth1
iface eth1 inet static
    address 10.1.1.100
    netmask 255.255.240.0
    mtu 1450

# Private network 2
auto eth2
iface eth2 inet static
    address 10.1.1.200
    netmask 255.255.240.0
    mtu 1450

Restart networking or reboot to activate the network changes.

# ifup eth0
# ifup eth1
# ifup eth2

Nameservers

Verify that /etc/resolv.conf has your preferred nameservers for IPv4, and optionally IPv6.

domain       example.com
nameserver   2001:db8:1000::1
nameserver   192.0.2.200

More Resources

Want to contribute?

You could earn up to $300 by adding new articles