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

4 Answers 4

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

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
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

You can bridge the two interfaces on the server.

  1. Install the bridge utilities package.

apt-get install bridge-utils

  1. Create the bridge.

brctl addbr br0

  1. Remove any IP addresses from the Ethernet interfaces.

ifconfig eth0 0.0.0.0 down

ifconfig eth1 0.0.0.0 down

  1. Enable STP support if required.

brctl stp bra on

  1. Attach the Ethernet interfaces to the bridge.

brctl addif br0 eth0

brctl addif br0 eth1

  1. Bring the bridge and the Ethernet interfaces up.

ifconfig eth0 up

ifconfig eth1 up

ifconfig br0 up

See link for more details.

share|improve this answer
    
Please quote the essential parts of the answer from the reference link, as the answer can become invalid if the linked page changes or the target site is unreachable/permanently offline. –  DavidPostill Sep 26 '14 at 22:31

Your Answer

 
discard

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