I have an ubuntu 18.04 VPS with 2 additional IPs, this is the config file I'm using which config all IPs on ens3:

network:
  version: 2
  renderer: networkd
  ethernets:
    ens3:
      dhcp4: no
      addresses: [a.a.a.a/23,b.b.b.b/23,c.c.c.c/23]
      gateway4: d.d.d.d
      nameservers:
        addresses: [108.61.10.10]
      routes:
      - to: 169.254.0.0/16
        via: d.d.d.d
        metric: 100

I want b.b.b.b and c.c.c.c to be on a different interface (like ens4), how should I change the config file?

This didn't help me: netplan config for two network interfaces no new interface in the output of "ifconfig -a" even after reboot

By the way, my vps is from vultr.com

Not sure i understand the question... I'd say:

ethernets:
ens3:
  dhcp4: no
  addresses: [a.a.a.a/23,c.c.c.c/23]
  gateway4: d.d.d.d
  nameservers:
    addresses: [108.61.10.10]
  routes:
  - to: 169.254.0.0/16
    via: d.d.d.d
    metric: 100
ens4:
     dhcp4: no
     addresses: [b.b.b.b/23]

?

ps. I think your:

  routes:
  - to: 169.254.0.0/16
    via: d.d.d.d

is not needed?, since it is set by default gateway already? ( unless more is going on ...)

  • The config file I'm using is suggested by the hosting. Your config didn't add new interface for b.b.b.b – Hamed Sepehr Jul 12 at 16:45

What you're looking for could previously be done with the non-netplan system by doing subinterfaces (such as ens3.1, ens3.2, etc.)

Netplan does not support subinterfaces like this. The closes you would be able to get is what you have - multiple addresses on one individual ethernet device.

There's no way to spawn 'more' devices than actually exist on your system, so you can't reliably/sanely create "new interfaces" which don't actually exist anywhere. Not without setting up bridges and then virtual ethernet interfaces, but that's a bit beyond Netplan at that point, and probably overly complicated for what you need.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.