Routing between two subnets using a Linux box with two NICs

100

Solution 1

You should set up the following static routes:

On 192.168.1.1 router:

192.168.2.0/24 next hop 192.168.1.2

On 192.168.2.1 router:

192.168.1.0/24 next hop 192.168.2.2

This way the other computers in those networks send packets to their default gateway (.1), which then uses its static routing table entry to forward the packet to Linux box, which then forwards the packet to the other network.

Solution 2

If I got it right, you have this network:

+-------+       +----------+       +-----------+       +----------+       +-------+
| LAN A | <---> | Router A | <---> | Linux Box | <---> | Router B | <---> | LAN B |
+-------+       +----------+       +-----------+       +----------+       +-------+

So, this is true:

  • All hosts in LAN A have their default gateway configured to 192.168.1.1;
  • All hosts in LAN B have their default gateway configured to 192.168.2.1;

The fact is that neither the hosts in LAN A, nor the hosts in LAN B know the existence of other network, so they'll send the packet to the default gateway. If the default gateway knows it and has a route to get in there, they'll use it. So, basically, what you have to do is create these routes in your routers, or change the default gateway of your hosts to the Linux Box. You should go to the second option if your routers don't have the option of creating static routes or you simply don't have access to them.

If I got it wrong, please clarify a little bit...

Cya!

Share:
100

Related videos on Youtube

S.S.Prabhu
Author by

S.S.Prabhu

Updated on September 18, 2022

Comments

  • S.S.Prabhu
    S.S.Prabhu over 1 year

    **

    • Scenario 1: sum

    ** I found that when working on 2d arrays in numpy, I realised that summing up has different options - i.e., Python built-in method sum provides summation along the axes only, whereas the numpy sum provides summation on the total 2d array (matrix).

    **

    • Scenario 2: and versus &

    **

    I noticed that logical and (and) bitwise and (&) both work on the same data element but produce different results. In fact, Logical and and does not work within series of dataframe whereas bitwise and & works just fine.

    Why does this happen ? Can anybody provide insights based on the language's history, design, purpose, etc so one can understand better ?

    Regards Ssp

    • Zoredache
      Zoredache about 10 years
      No idea, but this is a case where you need to look at a traceroute, and you need to fire up tcpdump. tcpdump is usually very useful for solving routing issues.
    • CIA
      CIA about 10 years
      Does NIC1 connect to ROUTER1 and NIC2 connect to ROUTER2? Or do both NICs connect to a switch that is then connected to ROUTER1 and ROUTER2?
    • fukawi2
      fukawi2 over 9 years
      Have you configured any firewall rules? Post the output of iptables-save
    • Willem Van Onsem
      Willem Van Onsem over 4 years
      and just takes the truthiness of the left operand. If that truthiness is False it "returns" te first operand, otherwise it returns the right operand. But not all objects have truthiness.
    • chepner
      chepner over 4 years
      Regarding sum, that function simply sums up the elements from the given argument. An array iterates by yield its rows one at a time, so sum(a) is adding rows, not elements of the array. It's basically a design tradeoff: a type can only have one kind of iterator, and it was probably deemed more useful or logical for an array iterator to yield rows, rather than individual elements. An additional sum method is free to be defined however is useful.
    • S.S.Prabhu
      S.S.Prabhu over 4 years
      Thanks. Why not provide these via answers so you guys get credit for it ?