How to make two different networks communicate

I have two PCs, as depicted in the figure.

Because of practical constraints, I cannot change anything on PC2, i.e., I cannot change its IP address and gateway (blank).

On both PCs, the subnet mask is '''255.255.255.0'''.

On PC1, I can only configure the gateway IP address.

Ideally, I would like both PCs to "think" they were communicating in the same network range (no gateways needed as far as the PCs were concerned).

Would this be feasible?

If yes, what kind of functionalities those routers must implement?

How to make two different networks communicate

Ideally I want to be able from PC1 to

ping 192.168.1.11

and get responses from 192.168.2.11, i.e., the router(s) would handle all the address translation.

Thank you.

How to make two different networks communicate

Published: 2012-03-27

How to make two different networks communicate
The article explains the protocols and technology which is involved when two computers on different TCP/IP networks communicate with each other. In the diagram, a router is used to segregate two networks. The networks are 192.168.1.0/24 and 192.168.2.0/24. The corresponding interface IP address on the routers are 192.168.1.1/24 and 192.168.2.1/24 as shown in the diagram. The interfaces on the router are connected to ports on the switch , to which the computers are connected. The IP address of the computers are 192.168.1.2 (PC1) and 192.168.2.2 (PC2). Take a scenario where PC1 wants to communicate with PC2.  For the communication to be succesfull, the TCP/IP adapter settings of PC1 and PC2 should be configured with the corresponding gateway addresses. The gateway addresses are required , since , communication is to be achieved between devices on two different networks. The gateway for PC1 should be a device , which is accessible to it , and which is capable of forwarding the information to the intended network. In the diagram, the router would be the ideal gateway. But the router has two interfaces, which are configured for two different IP addresses.  So which IP address should the PCs use. For example, the IP address 192.168.1.1 should be used as the gateway IP address for PC1 and IP address 192.168.2.2 should be used as the gateway IP address for PC2. What would happen if 192.168.2.1 is used as the gateway for PC1 ? PC1 would not be able to access it since , the IP address (192.168.2.1) itself is on a different network.Gateways are devices which should belong to the same network, and has knowledge about how to reach other networks. The following sequence of events follow, once the TCP/IP adapter settings is configured with the gateway address. 1. PC1 pings PC2 2. The routing table on PC1 identifies that PC2 (192.168.2.2) is on a different network 3. The packet would be sent to the gateway IP address configured on the PC as the destination is on a different network and the PC does not have any other option as a specific route to the network 192.168.2.0 is unavailable on the routing table of the PC.   4. Since the specific route is unavailable, the default route on the PC, which is populated by the operating system after the gateway IP address is configure would be used. 5. The packet has to be encapsulated in a frame and sent to the gateway 6. To generate the frame, the destination mac-address of the gateway is required. 7. PC1 sends ARP request to find out the mac-address of the interface of the router configured with the IP address 192.168.1.1. ( Note: If the ARP Cache on the PC contains the IP/Mac mapping for 192.168.1.1, this step would skipped and the frame encapsulating the IP packet would be sent directly to 192.168.1.1) 8. The router responds with an ARP reply. 9. PC1 uses the mac-address in the ARP reply, constructs the frame and sends the packet to the router. 10. The router is configured with two IP addresses, 192.168.1.1/24 and 192.168.2.1/24. When configured, routing tables are populated and 192.168.1.0/24 and 192.168.2.0/24 ( the corresponding network addresses) are listed as directly connected networks. 11. When the packet reaches the router, the destination IP address is looked into (192.168.2.1). The router checks if it is aware of the destination network for the destination IP packet. 12. Since the network is a directly connected network, the router knows which interface to use. 13. The router sends out an ARP request to find out the mac-address of PC2 (( Note: If the ARP Cache on the router contains the IP/Mac mapping for PC2, this step would be skipped and Step 15 would be executed) 14. PC2 would send an ARP Reply with it's mac-address. 15. The router would encapsulate the packet with the new frame, where the source mac-address is the mac-address of the interface corresponding to 192.168.2.1 and the destination mac-address would be PC2'S

Check out my Ebook TCP/IP Interview Questions and answers - http://tcpipguru.com/tcpip-interview-questions-answers/

IP addresses can be said to consist of multiple parts, similar to how full street addresses consist of multiple parts. A street address can consist of the increasingly specific parts Country, City, Postal Code, Street and House Number. An IP address consists of two main parts: IP network and addresses within the IP network. The addresses within the IP network are also called the host addresses because different hosts (computers) have different unique addresses within the IP network.

  • The IP network corresponds to more general parts of a full street address, such as City, Postal Code and Street name.
  • The Host Addresses within the IP network correspond to specific house numbers on a street.

On a computer network, all devices that are connected to the same local network can talk directly with each other. But to do so they need to have IP addresses that belong to the same IP network. Computers that belong to different IP networks have to communicate with each other via a router.

How to make two different networks communicate

Two computers belonging to the same IP network are able to communicate

How to make two different networks communicate

Two computers belonging to different IP networks cannot communicate directly with each other

The pictures above will give you a few examples of what IP addresses look like. An IP address is divided into four parts, separated by dots. Each part of the IP address can have values between 0-255.

The main purpose of a router is to be able to forward traffic towards different destinations. A router keeps track of where different IP networks exist on the computer network. The main task of the router is to forward traffic between those IP networks.

But how can you tell if two IP addresses belong to same IP network? Unfortunately, it isn’t as easy to tell IP networks apart from one another as it is with street addresses.

The answer is within something called a Subnet Mask. The Subnet Mask determines how much of the IP address that denominates which IP network the address belongs to. The rest of the IP address can then be used for computers and other hosts on the IP network.

Subnet Masks and IP networks

To really understand exactly how the Subnet Mask works you would have to study and learn about binary numbers and a few other more advanced topics. Luckily you don’t need any of that deeper understanding unless you work with IT or computer networks professionally.

Both an IP address and a Subnet Mask consists of four parts separated by periods. Each part of an IP address and a Subnet Mask can have a value between 0-255

How to make two different networks communicate

In its simplest form, each part of the Subnet Mask is either the number 255 or the number 0 (zero).

  • 255 means that the corresponding part of the IP address belongs to the IP network.
  • 0 (Zero) means that the corresponding part of the IP address belongs to the Host Addresses.

Here are a few examples of IP addresses and Subnet Masks in combination:

  • If the Subnet Mask is 255 in the first part then the first part of the IP address shows what IP network the address belongs to.

How to make two different networks communicate

  • If the second part of the Subnet Mask is also 255, then the second part of the IP address is also part of the IP network.

How to make two different networks communicate

  • If the third part of the Subnet Mask is 255, then the third part of the IP address also belongs to the IP network.

How to make two different networks communicate

Network Address, the name of the network

Each IP network has a so-called Network Address which is the “name” of the IP network. If you wanted to tell somebody which IP network a computer is located within you would always tell them the first (lowest numbered) address on the IP network, which is the Network Address.

Example 1:

In the picture below, the first three parts of the IP address belongs to the IP network. This is determined by the Subnet Mask.

How to make two different networks communicate

0 (Zero) is the lowest address that is available in the fourth part of the IP address. The computer thus belongs to the IP network 101.102.103.0

The fourth part (.5) of the IP address shows which host address that the computer is using on the IP network.

Example 2:

The next computer below belongs to the IP network 211.139.157.0. It is using the host address 9 on the IP network, and its IP address is 211.139.157.9

How to make two different networks communicate

Example 3:

This computer belongs to IP network 192.168.1.0, which is one of the most common IP networks that you will find in home networks.  It has received host address 7 on the IP network, and its full IP address is 192.168.1.7

How to make two different networks communicate

IP networks in your home network

In a normal home network, the Subnet Mask is usually “255.255.255.0”. What that means is that the three first parts of the IP address determine which IP network that the IP addresses belong to. The last part of the IP address determines which unique address within that IP network that each individual computer has got.

As we mentioned earlier, each part of an IP address can have a value between 0-255. So the fourth part of the IP address permits for 256 different addresses (zero up to 255) that can be used for computers, IP phones, routers, laptops, printers and other devices. These type of devices are commonly referred to as hosts or clients. In a normal home network, those addresses are always more than enough to cover the devices that are connected to the network.

When speaking about the computers, wireless phones, printers etc that are connected to a computer network the term client is often used. A client is any device that acts as an end user device, something that a user is interacting with. This could be a PC, your mobile phone, the wireless printer you have, your Smart TV or your game console.The term device is a bit more generic and can normally include clients but sometimes also the network equipment itself such as your router or switch.

Another term that is sometimes used is host which more commonly refers to computers and servers on the network.

But none of these terms are really set in stone, and they are often used interchangeably. The important bit is that since most of these devices behave in more or less the same way on a network it is often simpler to refer to them as clients, hosts or devices instead of having to list all of the devices.

The first address (zero) and the last address (255) in your home network can not be used for clients. They are reserved for special functions. The first address is the Network Address which has already been discussed. The last address is used for broadcasting, which is explained in the Switching part of this material.

So in the end, there are 254 available addresses that can be used in a home network. Normally the home router will use one of those addresses, and the rest are available for your computers and other devices.

It is usually your home router that determines which IP addresses that the computers can use in your home network. The router hands out IP addresses, the Subnet Mask and other details to the clients. This will be discussed later on in the section about how addresses are assigned to devices.