Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

ifconfig results:

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?

share|improve this question
3  
It is architecturally wrong to assign the same IP range to two different links. Why do you need that? –  Tibor Jul 15 '12 at 17:46
1  
Why do you have two separate 192.168.1.0/24 subnets? As far as your server cares, it has two connections to the same subnet - that's how IP was designed to function. –  Shane Madden Jul 15 '12 at 17:46
    
I have two DSL connections set up, each on a their own LAN. So the gist of this is that I should be using a unique subnet for each LAN instead of trying to get them to work together? The point of having the same IP on both networks is to make it easier to switch between networks without having to re-configure anything that is set up based on the server's IP address. –  Tyler Jul 15 '12 at 17:51
    
@Tibor I can see two interfaces on the same subnet (webserver with different SSL certificates), but one would have no gateway and I'd probably just bond them and/or create an alias. –  gravyface Jul 15 '12 at 18:07

2 Answers 2

Two DSL connections are better served using the multi-WAN load balancing/failover feature that's available in most business class edge firewall/routers.

One LAN, two WAN, one default gateway for the LAN (router). Let the router determine which route (Internet connection) to take depending on pre-defined conditions being met (weighted, policy routing, failover, etc.).

share|improve this answer
    
Thank you for the quick response. I wanted to avoid the extra expense if possible, but sometimes you just have to deal. On the other hand, it may be just as viable to just use a second IP and figure something out for applications that don't support hostnames. It also avoids some QoS concerns of mine; a whole other problem. Though, out of intellectual curiosity, I must wonder how the router could forward to 192.168.1.109 when it was connected to that network as 192.168.1.67. –  Tyler Jul 15 '12 at 18:24
1  
I think the extra expense in maintaining a non-standard configuration makes the cost of acquiring a multi-WAN capable firewall (pfSense is free if you have the hardware; D-Link's DSR series are very inexpensive and capable) seem trivial in comparison. –  gravyface Jul 15 '12 at 18:45
    
Actually the cost overhead is likely less than an hour contracted net admin. –  TomTom Jul 15 '12 at 19:40

This can be handled, but isn't handled out of the box. I have reviewed the Shorewall and Multiple Internet Connections documentation a couple of times, but haven't needed to implement it. As noted in that documentation, this is not a trivial setup.

However, you implement Multi ISP configuration you will likely want to read over the documentation. There is a risk you will route traffic out a different interface than it arrives on. This can create interesting situations where some connections work, but others don't. Marking traffic so that it returns on the same interface it came in on is important.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.