-4

Suppose we have two networks connected with each other by a router. One of them is using Class A prefix and the other one is using Class B prefix in IP address.
The Question is how these two network will communicate with each other as they are using different classes of IP addressing.

MikeyB
  • 40,079

4 Answers4

5

That is why you need a router in between, the router will have interfaces on both networks and will be able to pass packets between the two networks.

topdog
  • 3,558
3

Classful IP addressing is no longer being used. At all. Don't worry about it. I wish everybody would purge the terms "Class A" "Class B" and "Class C" from their memory. They are not needed at all. What's used now is Classless Inter-domain Routing. Notice it is classless in that there are no longer different classes of IP addresses (with exceptions like multicast and private IP addresses)

If you have valid subnets with a properly configured router, traffic will flow. All the router needs to know is its IP addresses on networks A and B along with the subnet masks. If it knows those, it will route data (provided you're not doing any sort of traffic filtering or NAT)

Jason Berg
  • 19,334
1

OK. I'll take another shot at this. Here is how a Class A (network with the first octet being 0 and 127 and also having a 255.0.0.0 subnet mask) network can communicate with a Class B (network with the first octet being between 128 and 191 and also having a 255.255.0.0 subnet mask) network.

A packet originates on a device in network A. This packet is sourced from IP address 10.0.1.2 and destined to IP address 172.16.1.2. The source device first checks the destination IP address. It compares this information to the information in its own routing table. The only entries of note in its routing table are the local subnet (10.0.0.0 with a 255.0.0.0 subnet mask) and it's default gateway (0.0.0.0 with a 0.0.0.0 subnet mask with a next hop of 10.0.1.1). Since the packet doesn't match any entry in its routing table besides the default route, it sends it to the default gateway, which is the router.

The router takes this packet and does the same thing. It examines the destination IP address and compares it to its routing table. The router has multiple local interfaces to compare to. It has a local network of 10.0.0.0 with a subnet mask of 255.0.0.0 and a local network of 172.16.0.0 with a subnet mask of 255.255.0.0. The router matches the destination address with the second routing table entry and directs it out the interface connected to that network. That interface looks up the MAC address for 172.16.1.2, creates a frame, and sends it out the proper interface.

The class of the networks don't really matter. The only thing that matters is that the router has an entry in its routing table that will match the destination IP address of the packet.

Jason Berg
  • 19,334
0

If two different hosts are on the SAME NETWORK, they can talk directly.

If two different hosts are on DIFFERENT NETWORKS, they need a router to pass packets.

Example:

  • Host A: 10.0.0.42 is on network 10.0.0.0/8 (a.k.a. a Class A network)
  • Host B: 172.16.0.42 is on network 172.16.0.0/12 (a.k.a. a Class B network)
  • Host C: 11.0.0.42 is on network 11.0.0.0/8 (a.k.a. a class A network)

Since A and B are on different networks, they need a router to talk.

Since B and C are on different networks, they need a router to talk.

Since A and C are on different networks, they need a router to talk.

The prefix length of a network (we used to call it Class) makes NO DIFFERENCE to whether two hosts can talk. The difference is in the network.

MikeyB
  • 40,079