How to route IP net to interface using netplan

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.

2

1 Answer

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 :

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like