0

I have a Ubuntu 18.04 server that has three NICs, each connected to a different LAN, and each receiving network information from a DHCP server. By default, from what I can tell, is one interface gets set as the default and will correctly route outbound traffic, but any inbound traffic coming to the non-default interface will essentially get dropped as the response is sent out a different interface. In my scenario, I need to be able to access the server via SSH on each interface.

After a lot of digging around and playing with netplan, this is what I ended up with:

network:
  version: 2
  renderer: networkd
  ethernets:
    ens192:
      dhcp4: yes
    ens224:
      dhcp4: yes
      dhcp4-overrides:
        use-routes: no
      routes:
        - to: 0.0.0.0/0
          via: 192.168.2.1
          metric: 100
          table: 2
      routing-policy:
        - from: 192.168.2.0/24
          table: 2
    ens256:
      dhcp4: yes
      dhcp4-overrides:
        use-routes: no
      routes:
        - to: 0.0.0.0/0
          via: 192.168.1.1
          metric: 100
          table: 3
      routing-policy:
        - from: 192.168.1.0/24
          table: 3

It seems convoluted, but it does solve my original problem statement. I'm wondering if I'm just missing something obvious here or if this is indeed the right answer.

1

The configuration you're using now allows complete routing for all traffic through each interface because you are using source-based routing. If the requirement is that you be able to access the machine via ssh from any remote address to any of the local addresses, regardless of which network interfaces are currently up, then this is the simplest way to express this currently in netplan.

If you only needed ens224 and ens256 to be used as backup interfaces in the event that ens192 was down, and you otherwise only needed them to be reachable from (and to reach) their respective local networks, you could use this simplified configuration instead:

network:
  version: 2
  renderer: networkd
  ethernets:
    ens192:
      dhcp4: yes
    ens224:
      dhcp4: yes
      dhcp4-overrides:
        route-metric: 200
    ens256:
      dhcp4: yes
      dhcp4-overrides:
        route-metric: 200
| 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.