Connect to two networks simultaneously

8,543

For the first part, to connect to two networks at the same time I would set up static routes. Assuming that the networks are on different subnets, you're basically telling the system, "If you need to connect to a machine with an address of 192.168.2.X, use eth0. If you need to connect to a machine with an address of 192.168.3.X, use eth1. And here is the gateway you should use."

So in /etc/network/interfaces add these lines (with your own network information of course):

auto eth0
iface eth0 inet static
      address 192.168.2.2
      netmask 255.255.255.0
      up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1

auto eth1
iface eth1 inet static
      address 192.168.3.2
      netmask 255.255.255.0
      up route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.1

As far as what logic is required for the system to identify and handle a message in a certain way, I believe that would rely on the certain software you are using to process the messages.

Share:
8,543

Related videos on Youtube

Sivakumar Natarajan
Author by

Sivakumar Natarajan

Updated on September 18, 2022

Comments

  • Sivakumar Natarajan
    Sivakumar Natarajan about 1 year

    I want to connect to two networks simultaneously using the Ethernet and in-built WiFi or to two WiFi networks by installing an additional WiFi adapter.

    My requirement: I have two sets of devices (Group A and group B) that need to communicate with each other but not directly. There is no internet at the location. Group A devices are connected to WiFi router A and group B devices to WiFi router B (It is necessary that they should not be connected to the same router). I want the Ubuntu device to connect to both router A and router B and act as an intermediary between the two groups. The Ubuntu device should receive messages from Group A (through router A), process the information and send notification of the result to Group B (through router B) and vice versa.

    Questions:

    1. How do I setup Ubuntu to connect to two networks simultaneously?
    2. How do I identify which network a message is from and handle that message accordingly?
    3. How do I specify the target network for my notification and send it to that network?
    • psusi
      psusi almost 9 years
      It would be much, much better to simply connect the two wifi access points with an ethernet cable.