LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   can I setup a personal route through a server to a gateway using iptables (https://www.linuxquestions.org/questions/linux-networking-3/can-i-setup-a-personal-route-through-a-server-to-a-gateway-using-iptables-636333/)

wastingtime 04-18-2008 05:58 PM

can I setup a personal route through a server to a gateway using iptables
 
I would like to setup my machine such that it uses another non-dedicated server as a route to the network's gateway.

On my machine I want to setup the default gateway to be the other server.
On that server I want to set routing such that any packets from my machine whose destination is not that server will be forwarded to the actual gateway.

The motivation for this setting is that direct communication between the gateway and my machine is very slow, but communication between my machine and that server, and between that server and the gateway, is really fast.

dkm999 04-20-2008 07:41 PM

The cleanest way to do this is to cut the slow link between your machine and the gateway, and then set your default route to point at the "other machine". If you fail to cut your slow link, you may be able to send packets outward through the fast path, but the replies will very likely return along the slow path. (It's a bummer, but this communication stuff goes both ways.)

The down side of this is that you will now be dependent on the "other machine" to be up in order to get connectivity to the rest of the world. A workaround is to write yourself a script that sets the slow link down and makes the default route change, and a corresponding one that reverses these steps. It's not pretty, but will save you some typing.

A more complex way to achieve somewhat the same result is to learn about routing protocols, and to get that set up on your machine, the "other machine" and the gateway. If all three are participants in the routing protocol, you might be able to tweak the parameters so that you could leave both links up and failover would be automatic, but I guess that is a good deal of work. For starters, you will need to use a protocol that is more complex than RIP, so that you can get the protocol to consider link speeds as well as the number of hops. Depending on your network arrangement, this possibly means using OSPF, BGP, or something else.

Good luck.


All times are GMT -5. The time now is 05:25 AM.