I'm trying to get working following:
Have 2 subnets (ie. 192.168.15.0/24 and 192.168.19.0/24) and two gateways (192.168.105.1/24, 192.168.109.1/24), and Ubuntu 18.04 server with netplan as router (.1/24 in subnets, .2/24 in gateway subnets). Goal is to use one gateway for for one subnet and other gateway for second subnet. Even if I'm using source-based routing as in netplan docs, ending with two gateways (random order) and only one subnet can access internet.
Please, how can I make it work?
edit: - added settings
with this setting, works from 192.168.105.xx to internet, but nothing from 192.168.109.xx.
And with route there are two gateways for 0.0.0.0/0
# Generated by iptables-save v1.6.1 on Sat Aug 22 10:38:15 2020 *nat :PREROUTING ACCEPT [386:180180] :INPUT ACCEPT [0:0] :OUTPUT ACCEPT [1:76] :POSTROUTING ACCEPT [1:76] -A POSTROUTING -s 192.168.15.0/24 -o br105 -j MASQUERADE -A POSTROUTING -s 192.168.19.0/24 -o br109 -j MASQUERADE COMMIT # Completed on Sat Aug 22 10:38:15 2020 # Generated by iptables-save v1.6.1 on Sat Aug 22 10:38:15 2020 *filter :INPUT ACCEPT [4:1760] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [28:2536] -A INPUT -i br105 -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -i br109 -m state --state RELATED,ESTABLISHED -j ACCEPT COMMIT # Completed on Sat Aug 22 10:38:15 2020
# This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: enp7s0: dhcp4: no enp7s1: dhcp4: no enp1s0f0: dhcp4: no enp1s0f1: dhcp4: no bridges: br15: dhcp4: no interfaces: [ enp7s0 ] addresses: [ 192.168.15.1/24 ] br19: dhcp4: no interfaces: [ enp7s1 ] addresses: [ 192.168.19.1/24 ] br105: dhcp4: no interfaces: [ enp1s0f0 ] addresses: [ 192.168.105.2/24 ] nameservers: addresses: [ 188.8.131.52 ] gateway4: 192.168.105.1 br109: dhcp4: no interfaces: [ enp1s0f1 ] addresses: [ 192.168.109.2/24 ] routes: - to: 0.0.0.0/0 from: 192.168.109.2 via: 192.168.109.1 on-link: true