• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 441
  • Last Modified:

TCP/IP and NetMasks and Routing Tables

Perhaps someone can help me to understand TCP/IP and subnet masks better.

I have two computers (connected to a cable modem and to each other via a hub, not a router) that have been dynamically assigned (via DHCP) their IP addresses. The addressess are as follows:

Computer A:  xxxx.yyyy.181.97, subnet mask

Computer B:  xxxx.yyyy.180.177, subnet mask

Now, doing a "bitwise and" between the two addressess and their respective masks, I derive the network to which I belong to be xxxx.yyyy.176.0.

I also note that for computer A the last byte is less than 128 and for computer B the last byte is greater than 128. I know that there can be some significance to this, but have not seen an explanation.

Now, if we limited the IP addresses on the subnet xxxx.yyyy.176.0 to be of the form xxxx.yyyy.176.(1-255) with a subnet mask of, then this subnet would only be able to accommodate 255 IP addresses. It looks like the combination of the 181 and the 248 on the subnet mask allows for more IP addresses to be assigned to that subnet? Is that the point?

Now let's say that I wanted to be able to network these two computers together at home. I would want an entry in my routing table for computer A that says that if I am trying to send a packet to computer B, I should send it from computer A. What should that look like and why?:

Destination: ??
Gateway: ??
Genmask: ??
Flags: ??
MSS: 0?
Window: 0?
irtt: 0?
IFace: eth0

Thanks for the help/tutorial.
  • 4
  • 2
  • 2
1 Solution
I may be missing the point of your question but it appears to me that this is a simple subnetting exercise where they have allowed for 8190 subnets each having 2046 hosts.

The address bit layout is therefore

nnnnnnnn nnnnnnnnn nnnnnhhh hhhhhhhh
(where n = network address bit and h = host address bit)

The valid IP addresses on these subnets are x.x.176.1 to x.x.183.254. The subnet address itself is x.x.176.0 and the broadcast address is x.x.183.255, all other addresses are valid for use by hosts.

As far as I can see there would be no requirement to route packets between the two PCs as they are on the same network, routers only being required when traversing networks.

I can't see any significance for the low-order byte being greater than or less than 128, this byte in and of itself has no special meaning as it is only the last 8 bits of the 11 bit host address area.

Cheers - Gavin
amcandrewAuthor Commented:
Now I think I understand the subnet/host part. I did not realize that one could specify that only 5 of the eight bits in the 3rd byte would be used for the subnet, since almost all of the examples that I have seen have had subnet masks of the form

As to the last question, the two computers that I wish to network together are connected to each other via a hub and they are each connected to the Internet (and to subnet xxxx.yyyy.176.0 via a cable modem). If I want to send a packet from A to B, I see two physical possibilities. First, the packet could go from A out the cable modem to a computer on the subnet (xxx.yyy.176.1? it is the gateway for destination and then come back through the cable modem to computer B. Or, the packet could go directly from A to B, if A knows that it is directly connected to B via the hub.

I think that the second approach would be the best. Can I implement it directly by the following routing table entry on A?:

Destination: xxxx.yyyy.180.177  (i.e. B)
Gateway: xxxx.yyyy.181.97  (i.e. A)
Genmask: xxxx.yyyy.248.0
Flags: U
MSS: 0
Window: 0
irtt: 0
IFace: eth0

Thanks for your assistance thusfar; I will accept your next answer so that you'll get the points you deserve.



You don't need any routing in this case. As newmang stated above, in this case both computers are in the same subnet (same network number and netmask). Therefore each can "see" the other.

In practice what is going to happen when one wants to communicate to the other is that the originating box will broadcast an arp request. All nodes that are on the same subnet will see the broadcast. The arp request is simply the originating box's request to find out what system on the local subnet has the IP it's trying to reach. Basically it's asking "who has, tell me". The other system will see the broadcast and respond with its MAC and off they go.

Give the points to newmang. He's answered your question.
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

amcandrewAuthor Commented:
But, when I try to ping B (xxxx.yyyy.180.177) from A, I get a message that all packets are lost.

The routing table on A has the following entries (generated by DHCP)

Destination       Gateway           Genmask
XXX.YYY.176.0             xxx.yyy.176.1

Note that pinging works fine and I have internet access via my browser. I am a little suspicious of the destination and gateway addresses that are simply; maybe that is the way DHCP sets things up so that I do not have access to, cannot ping, any other machine on the cable company's network?
Your routing table is correct for the local network and the default route. The first line says that XXX.YYY.176/ is a local network and that no gateway is needed. The last line has a destination of (anywhere) and a gateway point to your ISP's router and is the default route for non-local traffic.

If these two boxes are Linux machines you may have installed a default firewall on them. This would prevent pings or anything else from working between the two systems. If that's the case you'll need to modify the firewall rulesets or disable the firewall.
amcandrewAuthor Commented:
It was a firewall on B. Duh!  Thanks for the help.

Glad to see it is all working and you understand the addressing.

Just to fill in the background to this.....

In the beginning when the addressing structure was defined no-one had any idea of the "internet". All IP networks were essentially private networks.

There were 3 classes of addressing defined with the difference being the division of the 32 bit address into network and host component parts. These were as follows:

Class A :
8 bits of network address, 24 bits of host address.
1st bit of the address is ALWAYS 0
Addresses range from to
Allows for a small number of networks each with huge numbers of hosts.

Class B :
16 bits of network address, 16 bits of host address
1st 2 bits of address ALWAYS 10
Addresses range from to
Allows for a medium number of networks each with a medium number of hosts

Class C :
24 bits of network address, 8 bits of host address.
1st 3 bits of address ALWAYS 110
Addresses range from to
Allows for large number of networks each with a small number of hosts.

Class D : is reserved for multicasts, starts with 1110 and ranges from to

Note that 127.x.x.x addresses are reserved for internal loopback addresses, this explains why you could ping - it never went outside the box.

With the emergence of the internet this addressing structure became very wasteful as many addresses in each network were wasted. What then emerged was the ability to sub-net the address whereby a class B address such as you are using can be subdivided by allowing some of the host part of the address to be used as network address bits.

One entity would be allocated a Class B address (, they would then subdivide this address into a number of sub-nets by subnetting (in your case and then allocate those networks out to other entities.

This is a very simplified explanation of what's going on here - there is much much more such as super-netting, classless inter-domain routing (CIDR) etc but it should give you a start. There are many books available on the subject if you really want to get down and dirty with this - I've been doing this for 30 years now and I still find out new stuff every day.

Cheers - Gavin
amcandrewAuthor Commented:
Thanks for the additional background. I think I'll look for a book ("TCP/IP for Dummies"?).


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now