Solved

TCP/IP and NetMasks and Routing Tables

Posted on 2002-04-22
8
427 Views
Last Modified: 2010-03-18
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 255.255.248.0

Computer B:  xxxx.yyyy.180.177, subnet mask 255.255.248.0


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 255.255.255.0, 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.
0
Comment
Question by:amcandrew
  • 4
  • 2
  • 2
8 Comments
 
LVL 4

Accepted Solution

by:
newmang earned 100 total points
ID: 6961985
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
0
 

Author Comment

by:amcandrew
ID: 6962630
Gavin:
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 255.255.0.0.

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 0.0.0.0) 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.

Regards,

Alec

0
 
LVL 40

Expert Comment

by:jlevie
ID: 6962856
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 1.2.3.4, 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.
0
 

Author Comment

by:amcandrew
ID: 6962974
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     0.0.0.0           255.255.248.0
127.0.0.0         0.0.0.0           255.0.0.0
0.0.0.0           xxx.yyy.176.1     0.0.0.0

Note that pinging 127.0.0.0 works fine and I have internet access via my browser. I am a little suspicious of the destination and gateway addresses that are simply 0.0.0.0; 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?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 40

Expert Comment

by:jlevie
ID: 6963076
Your routing table is correct for the local network and the default route. The first line says that XXX.YYY.176/255.255.248.0 is a local network and that no gateway is needed. The last line has a destination of 0.0.0.0 (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.
0
 

Author Comment

by:amcandrew
ID: 6963498
It was a firewall on B. Duh!  Thanks for the help.
0
 
LVL 4

Expert Comment

by:newmang
ID: 6964204
Alec

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 1.0.0.0 to 126.255.255.255
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 128.0.0.0 to 191.255.255.255
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 192.0.0.0 to 223.255.255.255
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 224.0.0.0 to 239.255.255.255

Note that 127.x.x.x addresses are reserved for internal loopback addresses, this explains why you could ping 127.0.0.0 - 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 (255.255.0.0), they would then subdivide this address into a number of sub-nets by subnetting (in your case 255.255.248.0) 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
0
 

Author Comment

by:amcandrew
ID: 6970813
Thanks for the additional background. I think I'll look for a book ("TCP/IP for Dummies"?).


Regards,

Alec
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now