The VLAN of eth0 holds 2 IP nets, from the machine with IP 10.64.0.101/27 (eth0@machine-1) I used to connect to the openVPN server at 10.0.0.41/27 (eth0@machine-2) with the IP range 192.168.0.0/24.

The following sniplet in the /etc/network/interfaces:

post-up /sbin/route add -net 10.0.0.32/27 dev eth0
post-up /sbin/route add -net 192.168.0.0/24 gw 10.0.0.41

worked fine. Of course machine-2 with 10.0.0.41 also had post-up /sbin/route add -net 10.64.0.96/27 dev eth0 in its /e/n/i and ip forwarding enabled.

How to translate it into netplan?

My first shot was

   - to: 10.0.0.32/27
     via: 10.64.0.101
     on-link: true
   - to: 192.168.0.0/24
     via: 10.0.0.41

Any ideas?

Kind Regards Maniac

PS: growing the nets to /9 is not an option...

PPS: Yes, anycasts will be visible on both IP nets.

  • Your gateway is different between your ifupdown route and your netplan route (10.0.0.41 vs. 10.64.0.41). Is this a typo in your post? – slangasek Nov 13 at 16:40
  • @slangasek: yep, fixed, THX! – maniac_on_moon Nov 15 at 16:26

Heres the example.

I tryed to just comment but it wont let me.

network:
  version: 2
  renderer: networkd
  ethernets:
    ens3:
      addresses:
       - 192.168.3.30/24
      dhcp4: no
      routes:
       - to: 192.168.3.0/24
         via: 192.168.3.1
         table: 101
      routing-policy:
       - from: 192.168.3.0/24
         table: 101
    ens5:
      addresses:
       - 192.168.5.24/24
      dhcp4: no
      gateway4: 192.168.5.1
      routes:
       - to: 192.168.5.0/24
         via: 192.168.5.1
         table: 102
      routing-policy:
        - from: 192.168.5.0/24
          table: 102

Read more here : https://netplan.io/examples#source-routing

  • Hi, I think you are talking about 2 interfaces on one machine, this does not match my reqest exactly. – maniac_on_moon Nov 2 at 15:31

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.