I have a server that has 2 ethernet NICs, eth0 and eth1. For the purposes of this question, I will refer to each network with the interface that is physically connected to. I would like to configure the server in such a way that its services are available on both LANs.
eth0 Link encap:Ethernet HWaddr x:x:x:x:x:01 inet addr:192.168.1.67 Bcast:192.168.1.255 Mask:255.255.255.01 inet6 addr: fe80::2e0:52ff:fee0:eb9e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:516139 errors:0 dropped:0 overruns:0 frame:0 TX packets:511230 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:128341461 (128.3 MB) TX bytes:266227842 (266.2 MB) Interrupt:20 Base address:0x6000
eth1 Link encap:Ethernet HWaddr x:x:x:x:x:02 inet addr:192.168.1.109 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::213:d3ff:fe52:c568/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:5430 errors:0 dropped:0 overruns:0 frame:0 TX packets:2466 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:784989 (784.9 KB) TX bytes:503071 (503.0 KB) Interrupt:20 Base address:0xdc00
route -n results:
Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth1 192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 eth1
Currently on eth0 I can access my server at 192.168.1.109 and 192.168.1.67, despite the fact that the router only lists a device at 192.168.1.67. On eth1 I get a "destination net unreachable" error when pinging from other LAN machines unless eth0 is down, in which case I can reach the server at 192.168.1.109. The gateway for eth1 is 192.168.1.1. Pretty much everything I know about routing was learned trying to figure out this problem, so this is mindboggling to me.
So here's the problem: According to https://kindlund.wordpress.com/2007/11/19/configuring-multiple-default-routes-in-linux/ I need to set up a second routing table for eth1. However, since both networks are on the same subnet, the ip rule method will not work. Is there a way to change the routing table based on the interface? Am I forced to change the subnet on one of my LANs and thus losing the ability to set up the same IP for my server on both networks? Is there a completely different solution that I've missed?