How to communicate between different networks? - networking

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?
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.

If you can't change PCs, it needs to be done on gateway.
Try changing the network mask from 255.255.255.0 to 255.255.0.0 (or from 24 to 16) on the routers (LAN interface).
If possible you could also change the network mask on PC.

Related

Ping can't go across router connecting 2 LANs [Packet Tracer]

Topology of the network
The subnetworks work fine within themselves and pings reach their destinations but pings can't go through the router and reach the other LAN. I can ping the interface of the router that is on the same side of the origin of the ping but not the other one. It's as if the router is acting like a wall of brick. As far as I can tell the configuration of the interfaces are fine and the IPs of the hosts are as well considering I can ping them within their own subnetworks. The switches seem to work as intended within their own network. I'm fairly new at networks and I've searched online without finding any fix that worked for me. At one point I was considering a default gateway problem but even if it is I don't know what I would have to do to fix it. IP addresses with their default gateways of all the elements
I've also looked at the Router0 "show ip route" but can't notice anything that could help me.
Hello Nathan Cournoyer,
It looks like the problem resides with your default gateway settings.
Let me go through the ip routing process for you (sort of).
Let's say PC1 wants to send an ICMP ping to PC3 in the other network (LAN2). So you type in PC1 terminal ping 192.168.2.145. PC1 is first going to determine whether routing is necessary by checking whether PC3 is on the link. According to PC1's IP address and subnet mask, PC1 determines that only hosts 192.168.1.1-254 (192.168.1.0/24) are on the link, therefore 192.168.2.145 is not on the link and routing is necessary. As a result, PC1 sends the ping packet to its default gateway for routing. You currently have 192.168.1.0 as your PC1 default gateway, which is incorrect in two ways. 1) PC1 cannot reach the router through this address because the Router0's interface on LAN1 is 192.168.1.127. 2) 192.168.1.0 is typically used as a subnet ID. I don't think it can be used to routing.
To solve your problem, you need to set the default gateway of both LANs' hosts to the router interface's IP on the same respective LAN.
I think the previous sentence is confusing. Let me detail your setup
Device
Interface
CIDR
Default Gateway
Router0
G0/0
192.168.1.127/24
G0/1
192.168.2.159/24
PC1
NIC
192.168.1.97/24
192.168.1.127
PC2
NIC
192.168.1.98/24
192.168.1.127
PC3
NIC
192.168.2.145/24
192.168.2.159
TFTP Server
NIC
192.168.2.146/24
192.168.2.159
For IPv6, it should be largely the same logic as IPv4.
I don't think you need to setup IP addresses for the switches, unless they need that for internal web servers and others. You can technically replace the router with a layer 3 switch. You may not need a full-blown router for inter-LAN routing.
I learn computer networking on my own, so my knowledge may be incomplete and/or incorrect. Please point out any problems.

How to assign IPv4 address to routers?

I can't seem to understand how to assign the IP address to routers.
Could someone explain how to get the IP address for the router? (image 1)
this is a diagram included in our course lecture
diagram
I found similar questions but using programming languages it's not the way I am looking for so please help.
The Router on the image have three interfaces with IPs:
223.1.1.4
223.1.3.27
223.1.2.9
To change it, you need to change the IP of the interface using some programming language like CISCO iOS CLI.
If you want to add some device to a virtual network, be careful with the subnet mask.
In the example, the subnet mask of all interfaces is probably 255.255.255.0 with 223.1.1.0/24,223.1.2.0/24 and 223.1.3.0/24 prefixes. So, if you want to add a device to a VLAN, you need to use an IP with the same network prefix.
If you want to add a device in the 223.1.1.0/24 VLAN, you need to specify 223.1.1.X IP, with 255.255.255.0 subnet mask and 223.1.1.4 as default gateway.

Basic networking questions

I am trying to understand how exactly routing works:
if 2 computers are on the same network
if they are on different networks.
More specifically I am trying to understand this: Routing
I am also trying to understand the difference between
IP Address,
Net Address,
Mac Address.
From what I understand:
1) IP Address: is used when computers communicate on the internet only.
2) Net Address: is a local version of the IP address and each device on the network has a unique net address. It's used when devices on the same network want to communicate with each other.
3) Mac Address: is a globally unique address and no other computer in the world has the same Mac address. In reality this is not true because it can be changed. It's used when ???
When a computer wants to communicate with another on the same network, they use net address, right? If the computers are on different networks what exactly happens?
Question: Can someone please fix my mistakes if any and explain what I am missing?
Thank you very much.
There are many network types, but since the most used ones are Ethernet and IP networks (and you seem to be asking about them), I will answer shortly based on them.
IP addresses are always used. They may not be used for deciding who gets the packets directly, but they are the basis even in local networks, since it is an IP network. There can also be other network types that have their own mechanisms, but they are not that common.
In local Ethernet the machines ask via ARP protocol "who has this IP address?" and get a reply with a MAC address. After that they send and receive packets based on that MAC address. The packets still have the IP address information, otherwise the receiving machine wouldn't know what is the destination. Do note that the receiving machine might be a firewall or other middleware device, not the actual computer that has the address. Also a single machine and network card may have several IP addresses set up for it.
In IP networks the IP address is used for routing. All routing devices have a routing table that will tell where the packets should go. If it's a simple device, it usually has a local network and everything else goes via a default gw, which will know better what to do with the packets.
A home router will just push them to the operator, there another router will know what addresses go to their networks, others are pushed forward via another connection, until a bigger place is reached where there are inter-operator connections and they choose again the correct route. And then it goes to smaller and smaller pipes the other way around.

Two hosts with different subnets on layer 2 switch - why does this work?

I am just preparing for a test in college about networking.
I'm currently trying around with sub netting and I found out that two devices attached to a layer 2 switch can talk to each other although they have different subnets!
Device A: 192.168.0.1 subnet mask : 255.255.255.0
Device B: 192.168.1.1 subnet mask : 255.255.255.0
The question is why I can ping from device A to B and vice versa?
There's no router, just the two devices and a switch.
From my understanding they should not see each other.
The OS should not even send the ARP request when the unknown IP is in a different subnet.
Could this be a caching issue?
Many Cisco Layer 2 switches are capable to ping the connected systems.
It is possible that your computer might have a route entry that sends a packet which matches no other specific route entry to your router. This is also called as the default gateway. Conventionally the computers in the same subnet are connected directly and most of the times, do not go through the gateway.
To explain it more clearly, If you're on a Linux machine, run route -n.
Destination Gateway Genmask
14.0.1.0 0.0.0.0 255.255.255.0
0.0.0.0 172.16.80.1 0.0.0.0
The first entry has a destination ranging from 14.0.1.0 to 14.0.1.255. The gateway for this match is 0.0.0.0. The table implies that these systems are connected directly. On the other hand, the entry 0.0.0.0 in the destination field will get matched when the packet matches none of the other entries. The gateway for this is the router address (which in my case in 172.16.80.1). All the packets that do not have IPs in the range that I specified above go to the router for further routing. Once the router gets the packet, it takes the further decision based on its routing information that it posses.
In your case the router happens to know that the other subnet is attached to it and hence passed your packet onto that subnet.
Have a closer look at the ARP. The ARP would be addressed to the router in your case of pinging to the other subnet. On the other hand, if pinging within the network, the ARP would be to the destination directly. This is the conventional case. Of course, it all depends on the routing tables in your system. You can always make all packets go through the gateway or no packets to go through the gateway.

What are the effects of incorrectly setting the netmask?

What are the effects of incorrectly setting the netmask? I have a C++ application that sets the network mask of a device. If the netmask is set incorrectly, tftp doesn't seem to work properly. Why would this happen? What other problems occur when the netmask is not properly set for a device/PC?
While this question is probably more about IP networks than programming it is a challenging subject for many developers.
The netmask delimits the host address (your PC or server) and the network address (the part of the logical network infrastructure in which your system lives). The two parts are used to deliver the data packet to the correct device. The network address is obtained by ANDing the netmask with the IP Address. Consider the following scenario:
IP Address: 10.0.1.1
Netmask: 255.255.0.0
The host address portion of the IP address for our PC is 1.1, so the PC knows that any host addresses starting 10.0. are local to it. Any addresses that then start 10.1, etc, are not 'local' and will need to be forwarded to a router. If you have another device intended to be on the same network that is:
IP Address: 10.0.2.1
Netmask: 255.255.255.0
Here the netmask is wrong for our example setup, this device is now going to see the network address as 10.0.2 and the host address as 1, if it tries to communicate with 10.0.1.1 it will see a network address of 10.0.1! Not local and so will refer it to the default router for forwarding. If the netmask was correctly set (i.e. the same as the first example, assuming that's the correct setting for your network) then the second device would see the first as local, i.e. on the 10.0 network and wouldn't attempt to forward the packet to a router.
Many protocols will happily cope with this but tftp is intended to operate within a single network and so will fail as there's a perception that the target is on a different network.
This may not describe your exact situation but I hope that the example demonstrates the important principle that configuration matters, you can't have an inaccurately configured environment and expect it to work.
The netmask determines which IP adresses are local (non-routed); IP adresses outside that range go through the router. If the netmask is wrong, the program tries to directly access sites where it has to go through the router, or vice versa.
The netmask defines, which part of the IP-address is used as address for the network and which part is used for the workstations.
First Example:
IP1: 192.168.20.4
IP2: 192.168.192.4
NM: 255.255.0.0
Both IPs are in the same net. They can communicate with each other without needing a router. That's because the IP-addresses will result in the same bitmask when you or it with the netmask.
Second Example:
IP1: 192.168.20.4
IP2: 192.168.192.4
NM: 255.255.128.0
Now both IPs are in different networks because when you or the IP-addresses with the Netmask, the resulting bitmask will be different and they wont be able to communicate with each other without a router that routes between the two networks.
You can test this by yourself with ipcalc.
Possible implications of mismatched netmask are explained here. In short:
The host is likely to construct routing table incorrectly.
The host will miss some broadcast packets and not send broadcasts properly.
Mis-function of TFTP is almost for sure caused by the first reason. It affects any other IP protocol in the same way.
Other answers mention only the first problem (which is OK, as the second one is rather marginal). Note that it is not the netmask of the interface itself which determines how the IP packets would be routed - it is the routing subsystem of the host; but the netmask is normally used for constructing the routing table.

Resources