I'm a bit confused on how to configure my Ubuntu 18 server with two NICS using Netplan. Each NIC is on a separate subnet. They are directly connected to separate router interfaces on the router (this is a SMB router so each interface is configurable as a different subnet).

So for example on my server I have two NICs named below with the appropriate information they need:

eth0 -
       gateway -
       dns -

eth1 -
       gateway -
       dns -

I was playing around with the source routing example at netplan.io, but its not quite what I want. I don't want to route all outgoing traffic through just one interface. I need to be able to route traffic out of eth0 through eth0's gateway and I need to be able to route traffic out of eth1 through eth1's gateway.

I'll let the router handle routing between the two subnets via firewall rules. I just need Neplan to play nice with my two NICs and let me setup two subnets each with its own gateway information. Any ideas?


Edit: Unfortunately, my own answer is incorrect after further testing.

The way the below is setup, it's still routing all traffic destined for an external IP (internet traffic) through the eth1 device which is not want I wanted. I needed traffic routed out of each NIC respectively. So, if eth1 needs to get out to the internet, it needs to send those packets out of the gateway that is directly connected to eth1. Likewise, if eth2 needs to get out to the internet, then it also needs to send its own packets to the directly connected gateway that is connected to eth2.

I ended up dumping Netplan and went back to standard networking tools (ifconfig and /etc/network/interfaces) and setup a routing table/policy that does want I want. I'll never go back to Netplan. They made it way too complicated for what should be simple stuff. I spent days trying to get Netplan to work only to give up on that abortion of an abstraction layer. I'm leaving my incorrect answer below for documentation.

**** Wrong answer below ****

So it appears this seems to work:

   - to:
     metric: 100
     table: 101
   - from:
     table: 101
    addresses: []

I was attempting to list a gateway4 for each NIC stanza and that was incorrect from what I've been reading. One must setup static routes to for the other NICs/subnets attached directly to different gateways. You only need one gateway4 listing if you do it this way.

Hope this helps someone else in the future (or me when I need to set this up again a few years later and will have forgotten it).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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