Saturday, September 6, 2014

IPv6 notes

I've been gone for some time as a result of my CCIE studies.  One might think: Why aren't you using your blog to keep notes--everyone else is?"  I know...I just usually spend too much time dicking around with the formating and end up not using my time wisely.  I typically commit to making a blog post when I've learned something using examples I care about.

I've been reading quite a bit of material on IPv6, as I have training in 2 weeks and don't want to feel like I'm going in blind.

Today, I'll be doing an example on IPv6..and go through the motions.  All of the motions..even down to the decimal to hex conversion.

So..lets kick it off with this particular allocation that we have for work:

2620:158::/36

Based off that allocation, we can immediately realize two things:

1) HOLY SHIT, that is a lot of potential subnets, given the default host length of /64.  That mean, we have potentially 28 bits to play around with (64-36).  Using the 2^(X) formula, that equals 268,435,456 potential subnets.

2) EACH subnet could support 18,446,744,073,709,551,616 hosts.  Thats a lot of potential addresses.

So what is the full range of addresses available to us, based on the prefix 2620:158::/36?

Well, one helpful tidbit might be to figure out how the /36 address was derived.  If we have a /36, that means it was derived from a shorter prefix...possibly a /32?

If we use the 2620:158::/32 prefix..lets do some fancy magic using a couple basic steps:

1) Find the number of subnet bits:


Pretending we're the RIR responsible for handing out the /36s...how many /36s can we get from our existing /32?  Well...36-32 is equal to 4, and with 2 to the power of 4 (2^4) we can have 16 possible subnets from /32.

2) Find the number of subnet (or interesting hexits):


Subnet hexits = s/4 (round up!).  In our example, 16/4 = 4.  Thus, our sub-prefixes will be in the form of 2620:158:HHHH::/36
Note:

  • If s/4 leaves a remainder, the the rightmost hexist will NOT end in something other than an "F."
  • If s/4 DOES leave a remainder, then it means the hex values for each of the hexits for the last subnet will be "F."
We'll come back to that! 

3) Find the increment (or Block B)


This step required me to go do some reading on a math topic I haven't touched in some while: Modulus.  The formula is B=2^(16-L%16).  My first reaction: The hell is a percent sign doing in there :)

Essentially, the result is the remainder when dividing the two.  For our example, B=2^(16-36%16):



B=2^(16-4)
B=2^12
B=4096


Wait..what?  4096?  That's a huge number!  How can that be?  Well...thats in decimal.  We'll need to convert that into hex!





This can quite EASILY be done by using your windows calculator..but for the sake of knowing what exactly is going on...lets walk through it!

1.  Divide 4096/16:





Here, we have two important values:

1) 0!  We take this value and notate it.

2) 256!  We take this value and continue the process!

Current value: 0








2. Divide 256/16:



Same as before, we have two important values:


1) 0!  We take this value and add it to our running list.

2) 16!  We take this value and continue the process!

Current value: 0 0








3. Divide 16/16:


Same as before, we have two important values:


1) 0!  We take this value and add it to our running list.

2) 1!  We can now add this to our running list, as it is no longer divisible by 16!

Current value:   1 0 0 0





We just found that the hex value for 4096 in decimal to be 1000.  That means, that we have a incremental block value of 1000.  What can we do with that?  Well, if our original intention was to find the subnets available by subnetting the 2620:158::/32 into 16 subnets, we will get the following subnets:

1)    2620:158:0000::/36
2)    2620:158:1000::/36
3)    2620:158:2000::/36
4)    2620:158:3000::/36
5)    2620:158:4000::/36
6)    2620:158:5000::/36
7)    2620:158:6000::/36
8)    2620:158:7000::/36
9)    2620:158:8000::/36
10)  2620:158:9000::/36
11) 2620:158:A000::/36
12) 2620:158:B000::/36
13) 2620:158:C000::/36
14) 2620:158:D000::/36
15) 2620:158:E000::/36
16) 2620:158:F000::/36

4. How to find a particular subnet number?

In the previous example, we only had 16 subnets..so figuring out the nth subnet number may be as simple as writing it out.  But what if you have a million subnets?!  The easiest way to write it out is to use the formula: subnetID(n) = S (n-1), with S being the number of subnets.

For example, what if we wanted to find the 12th subnet ID in the previous example?

SubnetID(12) = 16 (12-1)
SubnetID(12) = 16 (11)
SubnetID(12) = 176

*Note: This is NOT correct, based off every resource I've seen...but we are simply not coming to the correct solution.  If I multiply 176 in decimal by 256..we get 45056.  THIS in hex is B000, which is the correct answer.  Why is it being multiplied by 256?  Not sure..I'll fix it once I figure out why!*

Don't forget we have to convert this back into hex!  45056 in hex is B000