7

Possible Duplicate:
How does IPv4 Subnetting Work?

I am currently revising Networking for the Cisco CCNA1. One of the questions that I am struggling to answer is the following:

Which of the following IPv4 addresses are vaild subnet addresses:

  • 172.16.4.127 /26
  • 172.16.4.155 /26
  • 172.16.4.193 /26
  • 172.16.4.95 /27
  • 172.16.4.159 /27
  • 127.16.4.207 /27

I can't get my head around how to know understand when a subnet address is valid or not.

Many thanks

4 Answers4

8

IP addresses are 32-bits long, the mask is also 32 bits. When you perform a logical AND of the address and the mask, you get the subnet address. See this wikipedia section on how to determine the network prefix.

My mental shortcut that works for netmasks >= 25 is I subtract the mask length from 32 and look at the last octet of the IP address... that is the maximum host bits in the address (call that number h). If the last octet is evenly divisible by 2**h, then that is a subnet address.

For example, 172.16.4.127/26... 32 - 26 = 6. 2**6 = 64 and 127 % 64 = 63. Therefore, 172.16.4.127 is not a valid subnet address... in fact it is the broadcast address for the 172.16.4.64/26 subnet. Good luck with your CCNA exam.

Mike Pennington
  • 8,305
  • 9
  • 44
  • 87
2

The answer is either all, or none depending on what they mean.

The normal understanding of a 'valid' subnet address is one in which the address quoted is the lowest possible in the specified range. Hence a /26 (64 addresses) would end with a multiple of 64, and a /27 would end with a multiple of 32.

None of the addresses you've quoted meet that rule.

  • 172.16.4.127 /26 - this is the broadcast address for 172.16.4.64 /26
  • 172.16.4.155 /26 - this sits in the range 172.16.4.128 - 191
  • 172.16.4.193 /26 - this is the first usable address in 172.16.4.192 /26
  • 172.16.4.95 /27 - this is the broadcast address for 172.16.4.64 /27
  • 172.16.4.159 /27 - this is the broadcast address for 172.16.4.128 /27
  • 127.16.4.207 /27 - this sits in the range 172.16.4.192 - 223

Are you sure you copied them correctly?

Alnitak
  • 21,191
  • 3
  • 52
  • 82
  • I'm not quite sure I'm parsing your answer... you say it could be all or none depending on what they mean... 172.16.4.127/26 is not a valid subnet address... That is the broadcast address, by definition. He is studying for a test, and they throw these kind of problems at them to ensure they understand the concepts correctly. – Mike Pennington Apr 19 '11 at 09:57
  • what I'm saying is that none of the supplied values match the _usual_ definition of a "subnet address". – Alnitak Apr 19 '11 at 10:13
  • @ Mike Pennington - "to ensure they understand" I find CCNA very difficult, I can pass 90% of the exams, and I can subnet successfull, but I dont understand theses sorts of questions. So for instance 172.16.4.127/26 is the last address before the next subnet meaning that it is a broadcast address, this means that it is not a useable address by a host therefore not a subnet address.Is this correct? –  Apr 19 '11 at 16:43
2

When I get lost with network addresses (I agree, it is not easy to calculate those /26 or /27s), I just ask the ipcalc tool to do the math for me. But be careful, because ipcalc in CentOS/RHEL is a completely different tool.

You run ipcalc and pass it some kind of network address as an argument and it gives you all kinds of useful self-explanatory information (looking at the binary netmask you can understand what a valid network address is in such a way that you will remember it). Taking your first address as an example (the space before the slash is optional).

$ ipcalc 172.16.4.127 /26
Address:   172.16.4.127         10101100.00010000.00000100.01 111111
Netmask:   255.255.255.192 = 26 11111111.11111111.11111111.11 000000
Wildcard:  0.0.0.63             00000000.00000000.00000000.00 111111
=>
Network:   172.16.4.64/26       10101100.00010000.00000100.01 000000
HostMin:   172.16.4.65          10101100.00010000.00000100.01 000001
HostMax:   172.16.4.126         10101100.00010000.00000100.01 111110
Broadcast: 172.16.4.127         10101100.00010000.00000100.01 111111
Hosts/Net: 62                    Class B, Private Internet

So in your case, 172.16.4.127 is the broadcast for the 172.16.4.64/26 network. And for a complete answer:

  • 172.16.4.127/26
    • Network: 172.16.4.64/26
    • Broadcast: 172.16.4.127
  • 172.16.4.155/26
    • Network: 172.16.4.128/26
  • 172.16.4.193/26
    • Network: 172.16.4.192/26
    • HostMin: 172.16.4.193
  • 172.16.4.95/27
    • Network: 172.16.4.64/27
    • Broadcast: 172.16.4.95
  • 172.16.4.159/27
    • Network: 172.16.4.128/27
    • Broadcast: 172.16.4.159
  • 172.16.4.207/27
    • Network: 172.16.4.192/27
chutz
  • 7,888
  • 1
  • 29
  • 59
1
  • A is the broadcast address for the subnet "10"
  • B is a valid address for the subnet "10" which is a valid subnet.
  • C is a valid address for the subnet "11" which is considered to be an invalid subnet
  • D is the broadcast address for the subnet "101"
  • E is a valid address for the subnet "110" whcih is a valid subnet.

I see this way: B and E are valid IP address and I think it's what they mean as "IPv4 addresses are vaild subnet addresses" although the question in the way it's put is likelly to cause misunderstanding.

henrique
  • 11
  • 1