Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is a routing question. I want to set up a block of IPs ( in the following configuration:

                                           /(eth1)-- (Main (
Router ( --(eth0)(Load balancer or Router) (
                                           \(eth2)-- (Alt (

With the Load balancer or Router ( taking all traffic going to and for ports 1-50000 forwarding those packets over eth1 to the main servers. But for requests from 50001-65535 forward that packet to eth2.

The trickiest part of this is the network Main and the Network Alt both need to have the same IP addresses.

The idea being a server in Main with IP ( and a server in Alt with the same IP ( can both be running, and make a request out of the network (say using port 3115 and port 53115) to the same target (like a web server). That web server would see two requests come in from the same IP address, just from two different ports, and would respond to both, and those packets would go back, one to each of the two servers (3115 would go to the server on the main network, 53115 response would go to the server on Alt network).

Both servers would need to be run without ever knowing the other exists.

Actually, in a best case scenario I wouldn't even want to need the split to happen based on ports. Ideally you would just have Alt and Main. If a request comes in that is not a response, it gets routed to eth1 (main) (so most traffic). The server Alt though could make a request, and that would go out showing from, as that's what the IP is of the machine in ALT. it would get routed back to eth2, the response to the packet, even though there is also a on eth1. I wasn't thinking this situation was possible, which is why I figured that segregating based on port was the best that could be done.

share|improve this question

migrated from Sep 13 '12 at 23:04

This question came from our site for professional and enthusiast programmers.

Have you evaluated NAT and found it lacking? – arootbeer Sep 13 '12 at 22:54

Both scenarios you describe could be achieved using IPTables on Linux, but the configuration would be pretty gnarly.

The real question is, why do you need the networks behind the device to be on the same IP range as the network in front of the device? You be better off running different IP ranges behind the device and doing IP address translation in the device. This way you can have all the devices on a single network behind the device and direct traffic to different machines based on dest port, or whether or not the connection is a reply to an existing connection or not.

share|improve this answer

Your Answer


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