TransWikia.com

netplan: ignore routes, keep gateway

Ask Ubuntu Asked by Matthias Lohr on December 15, 2021

I have a Ubuntu 20.04 server which has three network interfaces/connections:

  • eth0 is configured via DHCP, should have the default route, everything fine so far.
  • wg0 is a wireguard interface wich incoming traffic from a certain subnet, let’s say it’s a.c.b.d/24.
  • eth1 is another uplink which is configured via DHCP, but I only want to have traffic routed to this interface when it’s coming from wg0.

Is there any way to tell netplan to (a) push all routes it gets by DHCP to a special routing table or, alternatively, (b) a way for ignoring the routes but using the default gateways IP address for custom routes?

This is how my netplan configuration could look like if (a) would work:

network:
  ethernets:
    eth1:
      dhcp4: true
      dhcp4-overrides:
        use-table: 1000
      routing-policy:
        - from: 10.11.12.0/24
          table: 1000

Alternatively, in the case that (b) would work:

network:
  ethernets:
    eth1:
      dhcp4: true
      dhcp4-overrides:
        use-routes: false
      routes:
        - to: 0.0.0.0/0
          via: $DEFAULT_GATEWAY
          table: 1000
      routing-policy:
        - from: 10.11.12.0/24
          table: 1000

Both seems not to be supported by netplan (couldn’t find anything like a default gateway variable or a notation which will then use the gateway, also there does not seem to be an option for pushing the DHCP routes to a specific routing table).

I hope it’s clear what I want to achieve. Any idea how to do that?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP