Blogroll

Search

All your IP V6 Addresses are belong to US

February 2nd, 2012 by Karl

I often have to write code that is automating against a lot of different machines, but when developing that code I often just want to loopback to the local machine. However most of my code wants to ensure the machine name is unique, so I have limitations as in I can use the actual machine name, localhost,  or 127.0.0.1 . Previously I had occasionally put multiple entries in the HOST file that resolved to 127.0.0.1 and it would work, however with certain security techs like CredSSP remoting fails over, plus it’s a horrid way to do unit tests having to change the state of your machine you are running them on to make the test work.

often 3 is not enough when I’m trying to do something like process a throttled queue of work with 40 items in it, running 4 concurrently etc and that caused pain. With IP v6 I discovered I could do ::1 which is nice and pithy but after a while I discovered the variations of acceptible IPv6 adresses for ::1 are HUGE and this gave me all the ammunition I needed to produce sample loopback “machine names” for my unit tests. Here is an example of some acceptable variations:

 

Test-Connection "localhost" -Count 1
Test-Connection "127.0.0.1" -Count 1
Test-Connection "::1" -Count 1
Test-Connection "0:0:0:0:0:0:0:1" -Count 1
Test-Connection "0::0:0:0:0:0:1" -Count 1
Test-Connection "0:0::0:0:0:0:1" -Count 1
Test-Connection "0:0:0::0:0:0:1" -Count 1
Test-Connection "0:0:0:0::0:0:1" -Count 1
Test-Connection "0:0:0:0:0::0:1" -Count 1
Test-Connection "0:0:0:0:0:0::1" -Count 1

Test-Connection "00:00:00:00:00:00:00:01" -Count 1
Test-Connection "00:00:00:00:00:00:00:1" -Count 1
Test-Connection "00::00:0:00:0:00:1" -Count 1
Test-Connection "000:000:000:000:000:000:000:01" -Count 1
Test-Connection "000:000:000:000:000:000:000:0001" -Count 1
Test-Connection "::0001" -Count 1
Test-Connection "::001" -Count 1
Test-Connection "0000:0::001" -Count 1

 

Challenge to you. Make a function that can return X number of acceptible variations. There seem to be some rules, like :: can skip one of the items, but can only be used once, and each item can have up to 3 leading digits and there can be combinations. What is the total number of acceptable variations?

Posted in Powershell | 1 Comment »

One Response

  1. Herb Martin Says:

    Use: 127.x.y.z

    Long ago, I discovered that the entire loopback RANGE worked (at least on Windows for many versions).

    You can create up to 2^24 (minus 2) unique addresses for the local machine.

    More than 16 million possibilities.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.