简体   繁体   中英

how to communicate hosts in different subnet

We have two subnets Router 1

192.168.2.1
255.255.254.0

Router 2

192.168.1.1
255.255.255.0

 Modem >> switch 
        >> router1 wan port  >> from lan port to switch >> Different computers
        >> router2 wan port  >> from lan port to switch >> Different computers

Please note two different static public ips(of same subnet) for both routers.

I would like to know how I can access a host from Router 1 to a host in Router 2 or vice-versa.

use a single router:

Modem >> router >> switch >> lan1 >> computers in lan1
                          >> lan2 >> computers in lan2

You don't even need two LANs formally, since the PCs don't need a special routing rule to reach all local systems in this case.

You use two address sets: 192.168.1.xxx and 192.168.2.xxx and a network mask of /23 or even /16, no difference there. This way all PCs know they can simply send out packages to everything inside 192.168... Whereas for packages outside they need a rule routing those packages through the router. The routing of packages between the two areas on the LAN side is done automatically by the switch. That is what a switch is build for.

This is an explanation of how you would do it assuming that you must keep these as two separate subnets!

That is, you'll have to set up access for each IP address in the other router's firewall, and then specify to which internal system it will connect.

Note: It's only safe to do this because you have two static IP addresses! There really isn't an easy, safe way to do this with dynamic IPs.

In that case, Router 1 will have to grant access to Router 2's public IP address and vice versa. How you do this completely dependent on the make and model of the router.

The routers will know how to route to each other, because they'll be using the public IPs.

So, the data path will be: System1 (subnet1)->Router1->Internet->Router2->System2

Since different routers have you specify addresses in different ways, make sure you know how yours expects you to input the address or range of addresses.

However, that's not enough. Because you have multiple systems on each subnet, all sharing the same public IP address, you also have to specify which inbound traffic goes to what subnet host.

That is, you start on System1 in the above data path. The data goes out Router1 and back into Router2. How does Router2 know where to send it? It only has ONE external IP address.

Again, there are different ways of doing this for different routers. On some, you can specify that data on certain ports gets sent to certain systems. (Port Forwarding)

Using Telnet as an example (you shouldn't ! Telnet isn't secure. It's just easy to use as an example)...

You want to get from System1 (on subnet1) to System3 (subnet2).

On Router1 you specify that incoming data on Port 23 (Telnet port) should go to System1. On Router2 you send all Port 23 data to System3.

Port Forwarding, however, is somewhat limited insofar as, in the setup above, only System1 and System3 can receive Telnet data.

The other common way to do this is to have all data from a particular IP sent to one particular system on your subnet. That won't work for you, because you have multiple systems on each subnet!

I hope this isn't too non-specific! (Or too rambling! :-) ) I'm trying to be as non-specific as possible, but it makes it difficult to explain things! Unfortunately, since each company's routers use different interfaces, it's impossible for me to exactly what you need to do!

Let us know what your routers are. Then I can possibly be more specific.

In the meantime, however, look for the sections in your router to 1) the other router's data in, and 2) specify what data goes to which system on the subnet!

I hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM