Please notice that it is a duplicate, but the solution given before doesn't work for me! Everything explained below.I got two networks with Internet... would like them both to work... if request is to network#1, network#2 should answer that request through it's gateway... same with network#2 - it should answer to requests through it's gateway.ifconfigeth0      Link encap:Ethernet  HWaddr b8:27:eb:82:ca:0c          inet addr:192.168.1.200  Bcast:192.168.1.255  Mask:255.255.255.0          inet6 addr: fe80::57ac:b6e:33c1:8bbb/64 Scope:Link          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:797 errors:0 dropped:0 overruns:0 frame:0          TX packets:797 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000          RX bytes:219915 (214.7 KiB)  TX bytes:117516 (114.7 KiB)wlan0     Link encap:Ethernet  HWaddr b8:27:eb:d7:9f:59          inet addr:192.168.2.200  Bcast:192.168.2.255  Mask:255.255.255.0          inet6 addr: fe80::6463:5ba:3b28:6d39/64 Scope:Link          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:1532 errors:0 dropped:1215 overruns:0 frame:0          TX packets:201 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000          RX bytes:364160 (355.6 KiB)  TX bytes:29417 (28.7 KiB)ip route show table maindefault via 192.168.1.1 dev eth0  metric 202default via 192.168.2.1 dev wlan0  metric 303192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.200  metric 202192.168.2.0/24 dev wlan0  proto kernel  scope link  src 192.168.2.200  metric 303I got partially working solution:ip route add default via 192.168.1.1 dev eth0 table 100ip route add default via 192.168.2.1 dev wlan0 table 200ip rule add from all lookup main suppress_prefixlength 0ip rule add from 192.168.1.0/24 lookup 100ip rule add from 192.168.2.0/24 lookup 200This makes for example Apache (after port redirection on routers) answer to requests from both networks, but... only from outside. Local connection via 192.168.1.200 or 192.168.2.200 stops working... I mean... I can't connect to Apache from local network anymore.Could anybody help me with that?I tried also THIS solution, but it did not work... I can't connect through LINKs2 public IP to Apache server... maybe I am doing something wrong? Port forwarding seems to work, as I can see my request via iftop. Never getting an answer, tho'.rt_tables200 LINK1201 LINK2route.ship route add 192.168.1.0/24 dev eth0 src 192.168.1.200 table LINK1ip route add 192.168.2.0/24 dev wlan0 src 192.168.2.200 table LINK2ip route add default via 192.168.1.1 table LINK1ip route add default via 192.168.2.1 table LINK2ip rule add from 192.168.1.1 table LINK1ip rule add from 192.168.2.1 table LINK2After that:sigma@sigma:~/temp $ ip route show table LINK1default via 192.168.1.1 dev eth0192.168.1.0/24 dev eth0  scope link  src 192.168.1.200sigma@sigma:~/temp $ ip route show table LINK2default via 192.168.2.1 dev wlan0192.168.2.0/24 dev wlan0  scope link  src 192.168.2.200sigma@sigma:~/temp $ ip route show table maindefault via 192.168.1.1 dev eth0  metric 202default via 192.168.2.1 dev wlan0  metric 303192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.200  metric 202192.168.2.0/24 dev wlan0  proto kernel  scope link  src 192.168.2.200  metric 303sigma@sigma:~/temp $ routeKernel IP routing tableDestination     Gateway         Genmask         Flags Metric Ref    Use Ifacedefault         192.168.1.1     0.0.0.0         UG    202    0        0 eth0default         fiber.home     0.0.0.0         UG    303    0        0 wlan0192.168.1.0     *               255.255.255.0   U     202    0        0 eth0192.168.2.0     *               255.255.255.0   U     303    0        0 wlan0sigma@sigma:~/temp $ ip route show table alldefault via 192.168.1.1 dev eth0  table LINK1192.168.1.0/24 dev eth0  table LINK1  scope link  src 192.168.1.200default via 192.168.2.1 dev wlan0  table LINK2192.168.2.0/24 dev wlan0  table LINK2  scope link  src 192.168.2.200default via 192.168.1.1 dev eth0  metric 202default via 192.168.2.1 dev wlan0  metric 303192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.200  metric 202192.168.2.0/24 dev wlan0  proto kernel  scope link  src 192.168.2.200  metric 303broadcast 127.0.0.0 dev lo  table local  proto kernel  scope link  src 127.0.0.1local 127.0.0.0/8 dev lo  table local  proto kernel  scope host  src 127.0.0.1local 127.0.0.1 dev lo  table local  proto kernel  scope host  src 127.0.0.1broadcast 127.255.255.255 dev lo  table local  proto kernel  scope link  src 127.0.0.1broadcast 192.168.1.0 dev eth0  table local  proto kernel  scope link  src 192.168.1.200local 192.168.1.200 dev eth0  table local  proto kernel  scope host  src 192.168.1.200broadcast 192.168.1.255 dev eth0  table local  proto kernel  scope link  src 192.168.1.200broadcast 192.168.2.0 dev wlan0  table local  proto kernel  scope link  src 192.168.2.200local 192.168.2.200 dev wlan0  table local  proto kernel  scope host  src 192.168.2.200broadcast 192.168.2.255 dev wlan0  table local  proto kernel  scope link  src 192.168.2.200local ::1 dev lo  proto kernel  metric 256fe80::/64 dev eth0  proto kernel  metric 256fe80::/64 dev wlan0  proto kernel  metric 256unreachable default dev lo  table unspec  proto kernel  metric 4294967295  error -101local ::1 dev lo  table local  proto none  metric 0local fe80::57ac:b6e:33c1:8bbb dev lo  table local  proto none  metric 0local fe80::e94f:8405:bbc7:20f5 dev lo  table local  proto none  metric 0ff00::/8 dev eth0  table local  metric 256ff00::/8 dev wlan0  table local  metric 256unreachable default dev lo  table unspec  proto kernel  metric 4294967295  error -101
Two default gateways on Debian Jessie
debian;networking;routing
Assuming that I understand the problem correctly: You have two internet connections via two local interfaces and you'd like for responses to go through the same path they were received from.I can think of two clean solutions:1) Do policy routing based on the source IP. If the source IP is the one from eth0 then it should use one gateway, otherwise the other.  That's similar to what you've done. From the top of my head:ip route add default via GW1 table gw1ip route add default via GW2 table gw2ip rule from IP1 table gw1ip rule from IP2 table gw22) Tag incoming packets with iptables, connection tracking and the CONNMARK target. Restore that mark on every outgoing packet and do policy routing based on the mark. Again, from the top of my head:iptables -A INPUT -i wlan0 -t mangle -j MARK --set-mark 1iptables -A INPUT -i eth0 -t mangle -j MARK --set-mark 2iptables -A INPUT -j CONNMARK --save-markiptables -A OUTPUT -j CONNMARK --restore-markip route add default via GW1 table gw1ip route add default via GW2 table gw2ip rule fwmark 1 table gw1ip rule fwmark 2 table gw2The above may need some fiddling but that's the general idea.