How to setup two IP addresses on Ubuntu 18, in the same NIC?

Asked by Valerio Pregnolato

Hi folk,

I would like to learn how to setup my network card with two IP addresses
In the Ubuntu 18.04 using netplan, I cannot use alias to the same network interface.
I need to setup a nic with two IP addresses, and each IP needs a distinct default gateway

In the Ubuntu 16.04 I can to configure as bellow:

auto ens160
iface ens160 inet static
address 192.168.98.248
netmask 255.255.255.0
gateway 192.168.98.5
dns-nameserver 192.168.98.247 8.8.4.4 208.67.222.222
dns-domain xyz.local

auto ens160:0
iface ens160:0 inet static
address 172.16.10.2
netmask 255.255.0.0
gateway 172.16.10.1

How can I do it in the Ubuntu 18.04 using netplan?
Could you please help me?

Thanks,

Valerio Pregnolato (from Brazil)

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

https://www.howtoforge.com/tutorial/ubuntu-minimal-server-install/2/#g0.0.7

Has an OK explanation of the config files and the files themselves

Can you help with this problem?

Provide an answer of your own, or ask Valerio Pregnolato for more information if necessary.

To post a message you must log in.