2

I'd like to add a new IP address to an existing interface on an Ubuntu 16.04 LTS server. I've looked at the file /etc/network/interfaces which defines the current IP addresses/interfaces and it has the following line at the top:

source /etc/network/interfaces.d/*

Is the right thing to do to place a new file into that directory with the configuration options, and then restart the networking service?

Also, is there a reason why the source directive is at the top of the file? Given that I'll be placing extra information into interfaces.d/*, I'd expect those files to be sourced after my existing interfaces.

The remainder of the /etc/network/interfaces (excluding comments) is:

auto lo
iface lo inet loopback

auto ens3
iface ens3 inet dhcp
pwaring
  • 209
  • 2
  • 7
  • Kinda related (/ duplicate): https://serverfault.com/questions/390085/static-virtual-ip-in-debian-6-0-4?rq=1 – Lenniey Aug 30 '18 at 13:44
  • Did my answer sufficiently answer your question? If so, could you mark is as correct and accepted? If not, please elaborate how I can improve my answer. – Tommiie Jan 07 '19 at 10:31

1 Answers1

2

I believe you can create "subinterfaces" that contain the additional IP addresses, e.g. in /etc/network/interfaces:

auto ens3:0
iface ens3:0 inet static
    address ...
    netmask ...
auto ens3:1
iface ens3:1 inet static
    address ...
    netmask ...

This link points to an older article (from 2013) so it might be there are now better ways to add additional IP addresses.

Tommiie
  • 5,547
  • 2
  • 11
  • 45