Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This is my situation:

Router A: IP 192.168.1.1 Mask 192.168.1.0/24 - Connected to the internet.

Server: - Interface eth0: inet addr:10.1.1.125 Mask:255.255.255.0 (connected to router B) - Interface ra0: inet addr:192.168.1.125 Mask:255.255.255.0 (connected to router A)

Router B: IP 10.1.1.254 Mask 10.1.1.0/24 - Connected to Server's eth0

Computer: connected to Router B via WiFi connection.

I configured a static route on Router B that use as default gateway 192.168.1.125 and i can ping that ip from computer.

The problem is: how i can connect to the internet ? In other words, traffic coming from Server eth0 should use ra0 as gateway.

Any suggestion ?

Thank you

share|improve this question
    
is there some reason you need to route through the server? why not connect the routers directly and let them handle routing between the subnets? –  quack quixote Dec 24 '09 at 20:41
add comment

3 Answers 3

I believe you need to enable routing on the server (I'm assuming Linux) for it to be route packets not destined for itself. See the information in this article for how to do it.

share|improve this answer
add comment

Echoing the comment from ~quack, why not connect the routers directly and let them handle the routing? Especially if they are NAT routers, then packets have a better chance of flowing, because not only does Computer01 need to know how to reach the Internet, RouterA needs to know how to reach Computer01.

It may be as simple as turning your server into a NAT router, either with Windows's Interface Sharing or with various Linux configurations. And while I'm not opposed to using a server as a router, doing so does put additional load on the server.

share|improve this answer
    
I couldn't connect the 2 routers because of the distance and because 1 of them are preconfigured router, with not so much customization capabilities. –  Dario Dec 29 '09 at 9:41
add comment
up vote 0 down vote accepted

I found a solution using iptables (just 2 lines):

iptables --table nat --append POSTROUTING --out-interface ra0 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT

Thank you all!

share|improve this answer
    
Does the --append FORWARD line enable packet forwarding on the box? –  pcapademic Dec 29 '09 at 21:49
add comment

Your Answer

 
discard

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