Group: comp.os.linux.networking
From: Tauno Voipio
Date: Tuesday, April 08, 2008 3:31 PM
Subject: Re: Confused about defining a gateway

James H. Newman wrote:
> I have a Linux box with two NICs; one for my LAN and the other
> for the external world. The latter is in the 192.168.2 network (IP
> address 192.168.2.2) directly connected by a cable to another device in
> the same network (IP address 192.168.2.1.) In turn, this device also has
> two NICs, and via its second NIC (IP address 192.168.3.2) it is directly
> connected to a gateway in network 192.168.3 (IP address 192.168.3.1).
>
> My question is, would it possible to define the default gateway
> for my Linux box to be 192.168.3.1? I would have thought that this is not
> possible, for not only they are different in networks but, in addition,
> both devices are not directly connected. My gut feeling is that the
> default gateway in the Linux must be 192.168.2.1, and the default gateway
> in the second device must be 192.168.3.1. Is this the only way to reach
> the 192.168.3.1 device from the Linux box?
>
> Comments from savvy contributors would be welcome.

For most cases, there is a simple rule:

Put the next hop host toward the Net as the default
gateway.

In your case the default gateway for the most remote
computer would be 192.168.2.1. The default gateway
must always be in an address directly accessible
from the host it is gateway for.

You need to turn IP forwarding on in the box relaying
the traffic. Also, there may be addressing problems,
as the 192.168.x.y addresses are not routed in the
public Net (see RFC 1918).

--

Tauno Voipio
tauno voipio (at) iki fi

Safety Articles | Usenet Groups | Usenet News | Bluegrass