g | x | w | all
Bytes Lang Time Link
408Julia 1.0250902T105824ZMarcMush
010Vyxal j210725T091229Zemanresu
099Tcl250506T151431Zsergiol
049Ruby250506T153213ZJordan
nanGo240122T212151Zbigyihsu
060Zsh P240121T175822Zpxeger
024Regenerate a220703T000519ZDeadcode
016Cinnamon Gum160406T170026Za spaghe
nanPython 3151007T081559ZAnders K
103PowerShell v4151008T010213ZTessella
075Ruby151007T152305ZMegaTom
166CBM BASIC v7.0151016T150811ZPsychona
301Tcl 341 318151016T174126Zwolfhamm
339Commodore BASIC 2.0151010T205843ZMark
231AutoIt3151007T105400ZGiantTre
111Haskell151009T141603ZFranky
095Python 2151007T230838ZStatus
024Pyth151007T084229ZPurkkaKo
021Pyth151008T173926Zizzyg
nanC151007T153927ZRandom83
067Python 2.7151008T130206Zxsot
335Verilog151007T235936Znanofara
137AutoIt3151007T224904Zrav_kr
027CJam151007T084932ZSp3000
nanC with GCC extensions151007T180323ZDigital

Julia 1.0, 42.4 40.8 bytes

using Sockets
foreach(println∘IPv6,0:~UInt128(0))

Try it online!

Vyxal j, 10 bytes

k64↔8↔\:vj

Try it Online!

So, unlike most of the other answers here, this doesn't iterate from 1 to 2^128 and print the corresponding IP address for that number. Most other answers do this due to the challenge disallowing constructing the list of all IP addresses in memory, but in Vyxal we can do so anyway!

This is due to lists in Vyxal being inherently lazy: they will only generate items when they need to. For example, when I tell Vyxal to generate all 8-length combinations of 4-digit hexadecimal strings, what it's actually doing is not constructing the full list in memory, but creating an iterator that will eventually yield every combination.

The j flag formats the outputted list of lines - it's actually necessary to do this so that the output doesn't get concatenated into a massive string in memory.

    8↔     # All combinations, of length 8, of
  4↔       # combinations of length 4 of
k6         # hexadecimal digits - "0123456789abcdef"
      \:vj # each joined by colons

Tcl, 99 bytes

set i 0
while $i<[expr 4**64] {puts [string trim [regsub -all .{4} [format %032x $i] :&] :]
incr i}

Try it online!

Ruby, 49 bytes

p would be shorter than puts but I don't like the extraneous quotation marks.

(2**128).times{puts ("%032x"%_1).scan(/..../)*?:}

Attempt This Online!

Go, \$243 \times 0.8 = \$ 194.4 bytes

import(."fmt";."net/netip")
func F(){for a,M:=0,1<<32-1;a<M;a++{for b:=0;b<M;b++{for c:=0;c<M;c++{for d:=0;d<M;d++{s:=""
for n,k:=0,Sprintf("%08x%08x%08x%08x",a,b,c,d);n<8;n++{s+=k[4*n:4*(n+1)]+":"}
A,_:=ParseAddr(s[:len(s)-1])
Println(A)}}}}}

Attempt This Online!

Prints to STDOUT. Uses the netip.Addr type from the Golang standard library to do the formatting for me.

Explanation

import(."fmt";."net/netip")
func F(){
for a,M:=0,1<<32-1;a<M;a++{ // first 8 digits
for b:=0;b<M;b++{           // next  8 digits
for c:=0;c<M;c++{           // next  8 digits
for d:=0;d<M;d++{           // final 8 digits
k:=Sprintf("%08x%08x%08x%08x",a,b,c,d)  // join the numbers into a single string
s:=""
for n:=0;n<8;n++{s+=k[4*n:4*(n+1)]+":"} // split into 8 groups of 4, split by colons
A,_:=ParseAddr(s[:len(s)-1])            // parse the address
Println(A)}}}}}                         // print using the default String() method, which formats the address

Zsh -P, 60 bytes

x=({0..9} {a..f})
eval for\ {1..8}' ($x$x$x$x)<<<${(j/:/)@}'

Attempt This Online! (Warning: if you don't click the kill button fairly quickly, your browser will run out of memory and crash)

eval for\ {1..8} creates 8 nested loops using the loop variables $1, $2, ..., $8. These numbered variables can then be referred to implicitly using $@ (here, they're joined with colons using ${(j/:/)}).

The <<<${...} section is actually repeated for each level of nested loop as well, but (apart from the last one) they all do nothing, because they feed into the next loop, which ignores its input.

The -P option enables an implicit cartesian product on the adjacent expansions $x$x$x$x. This is the shortest way I could find to count up to 0xffff in hex without needing to convert each loop variable to hex individually.

Regenerate -a, 24 bytes

(($3:!)[0-9a-f]{4}()){8}

Attempt This Online!

(
    # Match ":" iff we're not on the first iteration
    (
        $3        # Match iff we're not on the first iteration
        :         # Match ":"
    !             # Short-circuiting alternation - only try matching the below
                  # if it was impossible for the above to match.
                  # Do nothing
    )
    [0-9a-f]{4}   # Match 4 hexadecimal digits
    ()            # $3 = signal that we're not on the first iteration anymore
)
{8}               # Repeat the above 8 times

Alternative 24 bytes:

(({#1}:!)[0-9a-f]{4}){8}

Attempt This Online!

It might not be intended that this is possible, but Regenerate allows a quantifier to be preceded by nothing. This is what's happening with {#1} - it's impossible for it to match on the first iteration because $1 hasn't been captured yet and doesn't have a length. On subsequent iterations, a match of nothing gets repeated 4 times (the length of $1).

Cinnamon Gum, 16 bytes

0000000: 678b 36d0 b54c d44d 8bc5 455b 8d0c 0500  g.6..L.M..E[....                               .

Try it online. (TIO limits output)

Explanation

The g mode puts Cinnamon Gum in generate mode. The rest of the string decompresses to this regex:

[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]

It then creates a generator of all possible strings that match the regex and iterates through it, printing out each one.

Somewhat amusingly, the golfier regex ([0-9a-f]{4,4}:){7,7}[0-9a-f]{4,4} actually compresses to a longer string than the regex above.

Python 3, 65 bytes · 0.8 = 52.0

from ipaddress import*
n=4**64
while n:n-=1;print(IPv6Address(n))

PowerShell (v4), 193 166 162 145 103 bytes

TimmyD's no-bonus version at 103 bytes:

$i=[bigint]::Pow(4,64);while($i-gt0){('{0:X32}'-f($i-=1)-replace'0(?=.{32})'-re‌​place'.{4}(?!$)','$0:')}

Previous with-bonus version at 145 * 0.8 = 116 bytes

With help from TimmyD and tomkandy, who points out that 0 -eq $false but ([bigint]0) -eq $true. So all my previous versions won't terminate.

$i=[bigint]::Pow(4,64);while($i-gt0){$i-=1;[IPAddress]::Parse((('{0:X32}'-f$i
)-replace'0(?=.{32})'-replace'.{4}(?!$)','$0:')).IPAddressToString}

Previously at 162, before some regex changes:

$i=[bigint]::Pow(4,64)
while($i){$i-=1;if(($x='{0:X32}'-f$i).Length-eq33){$x=$x.Substring(1)}
[IPAddress]::Parse(($x-replace'.{4}(?!$)','$0:')).IPAddressToString}

"A challenge where PowerShell ought to be reasonably competetive!" - me, before I tried it.

Explanation

# PowerShell (PS) has no IP address arithmetic, e.g. IP + 1
#- PS has no 128 bit integers
#- PS has no automatic bignums

# Start from the top, with the BigInteger specialised Power()
$i = [BigInt]::pow(4,64)

# Loop 4**64 through 1, work with $i-1 for ff... -> ::0
while ($i) {
    # PS has no decrement operator for bignums
    # (no using $i-- in the while loop test)
    $i-=1

    # The Net.IPAddress class can't turn a BigInteger
    # into an IPv6 address directly. And because it mashes
    # IPv4 and IPv6 into one class, there's no obvious way 
    # to make a small number always cast to an IPv6 address.
    # Format the bignum as a string of 32 hex digits.
    $x = '{0:X32}' -f $i

    # The BigInteger often formats as /33/ hex digits, 
    # with a leading zero (to avoid unintentional +/- sign bits)
    # ( https://msdn.microsoft.com/library/dd268287 )
    # So remove the leading 0, if there is one
    if (($x).Length-eq33){$x=$x.Substring(1)}

    # I can't always remove the leading zero, because it 
    # can't parse FFFFF... into an address without colons
    # and this regex replace into groups of 4 with colons
    # would go wrong at length 31. No : after the last group
    # This is still better than split/join ... because there
    # isn't a split-into-groups-of-N that I know of.
    $x = ($x -replace '.{4}(?!$)', '$1:'
   
    # Woo! * 0.8 bonus! 45 characters to save 38! :D
    [IPAddress]::Parse($x).IPAddressToString

}

Ruby 75

x=->s,n{n>0?65536.times{|m|x.(s+?:*(8<=>n)+m.to_s(16),n-1)}: p(s)};x.('',8)

This is a recursive solution that takes a each prefix and finds every possible suffix. Recursively.

CBM BASIC v7.0 (166 characters)

a=65535
fOi=0toa:fOj=0toa:fOk=0toa:fOl=0toa:fOm=0toa:fOn=0toa:fOo=0toa:fOp=0toa:?hE(i)":"hE(j)":"hE(k)":"hE(l)":"hE(m)":"hE(n)":"hE(o)":"hE(p):nE:nE:nE:nE:nE:nE:nE:nE

Mark's answer is for the Commodore 64's BASIC 2.0, which lacks a built-in command for printing numbers in hexadecimal. However, thanks to the HEX$() function in BASIC 7.0, the Commodore 128 version is much shorter. It doesn't fit on a single logical line (which on the C128 is limited to 160 characters) but can still be entered as two separate lines in direct mode.

Tcl 341 318 301

proc ip6 {p c} {
    set s %x:%x:%x:%x:%x:%x:%x:%x
    set p [scan $p $s]
    while {[set d 7]} {
        $c [format [string map {x 04x} $s] {*}$p]
        while {[set i [lindex $p $d]]==0xFFFF} {
            lset p $d 0
            if {!$d} return
            incr d -1
        }
        lset p $d [incr i]
    }
}
ip6 fFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:0000 puts

Commodore BASIC 2.0, 339 bytes

In order to get lower-case hex digits, this program is written in "shifted mode" (press <SHIFT>+<C=>)

1k=65535:a=0
2fOb=0tok:fOc=0tok:fOd=0tok:fOe=0tok:fOf=0tok:fOg=0tok:fOh=0tok
3x=a:goS6:?":";:x=b:goS6:?":";:x=c:goS6:?":";:x=d:goS6:?":";:x=e:goS6:?":";:x=f
4goS6:?":";:x=g:goS6:?":";:x=h:goS6:?
5nE:nE:nE:nE:nE:nE:nE:nE:a=a+1:ifa<65536tH2
6y=x/4096:goS7:y=x/256aN15:goS7:y=x/16aN15:goS7:y=xaN15:goS7:reT
7?mI("0123456789abcdef",y+1,1);:reT

Simply making this work on the Commodore 64 was a challenge, because of memory, screen size, data size, and other limitations. I considered implementing the abbreviated representation, but other limitations (such as the undocumented inability to use array elements as loop indices) meant it would increase the length of the program by an estimated 1000 bytes.

Line 7 is an implementation of HEX$(), which Commodore BASIC 2.0 is lacking. I can't use a DEF FN for this because those can only return numbers, not strings. Line 6 is a subroutine that applies it to a group of four digits, which would have been considerably shorter if functions could return strings.

Lines 2 and 5 are eight nested loops, implemented as seven "for" loops and a conditional goto because eight "for" loops, when combined with the two "gosubs" for printing out the address, will overflow the C64's tiny stack.

A C64 can print out about 1.2 addresses per second, for an estimated runtime of 1.3*10^31 years.

AutoIt3, 142 231 Bytes

For $a=0 To 2^32-1
For $b=0 To 2^32-1
For $c=0 To 2^32-1
For $d=0 To 2^32-1
$s=StringFormat("%08x%08x%08x%08x",$a,$b,$c,$d)
For $j=0 To 8
ConsoleWrite(StringMid($s,$j*4+1,4)&($j<7?":":""))
Next
ConsoleWrite(@LF)
Next
Next
Next
Next

Explanation

Expected output size: (One line (39 bytes) + line-feed) (=40 bytes) * 2^128 = 1.361* 10^16 YB (yottabytes)

Haskell 111

s[]=[[]]
s(a:b)=[y:z|z<-s b,y<-a]
r=replicate
main=mapM putStrLn$s$tail$concat$r 8$":":r 4"0123456789abcdef"

With my own sequence function s it no longer leaks memory, but does not feel golfed any more.

Python 2, 95 bytes

def i(p=0):
 while p<4**64:print':'.join(hex(p)[2:].zfill(32)[4*s:4*s+4]for s in range(8));p+=1

Simply goes through every number from 0 to 2^128. First it converts the current number to hexadecimal string, then strips off the '0x' that that function gives. Next it adjusts the string to have 32 zeros in the front and then breaks it up into groups of four. Finally it joins the groups of four with colons, prints that out and adds 1 to the current number. Has the added bonus that you can start it at any value if you give it one, but no input is needed.

Pyth, 27 25 24 bytes

Note: the code had a bug previously, fixing it saved 1 byte

J^4 64WJj\:c%"%032x"=tJ4

Prints the addresses like

ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe
ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffd
ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffc
...
0000:0000:0000:0000:0000:0000:0000:0003
0000:0000:0000:0000:0000:0000:0000:0002
0000:0000:0000:0000:0000:0000:0000:0001
0000:0000:0000:0000:0000:0000:0000:0000

Previous (more complicated) version using the pad operator (also 24 bytes):

J^4 64WJj\:c.[\032.H=tJ4

Explanation

J^4 64                  set J to 2^128
WJ                     while J is not 0:
            =tJ               decrement J
    %"%032x"                 format to length-32 hex string
   c           4            split every 4 chars
j\:                        join by : and print

Pyth, 21 bytes (invalid)

jmj\:c.[\032.Hd4^4 64

This can't be run since 1) it would consume at least 2132 bytes (252 yobibytes) of memory and 2) the interpreter doesn't like it (2128 doesn't fit in ssize_t, so no lists of that size). It would print the addresses in lexicographical order. You can try out the algorithm by changing the number(s) in the end to something usable.

Pyth, 21 bytes

KJ^8CdWJj\:ct.H+K=tJ4

Uses a while loop with J as the iterator variable. Initializes the maximum using 8^chr(' '). Pads by adding that initial value, converting to hex, then removing the first character.

C, 91-126 bytes

My original version, 119 bytes.

long a[9],i;
f(long*x){if(65536&++*x)*x=0,f(x+1);}
main(){for(;!a[8];f(a))for(i=7;i+1;i--)printf(i?"%lx:":"%lx\n",a[i]);}

Best golfed portable-ish version, 103 bytes (thanks @Dennis for some of these concepts)

long*p,a[9];
main(i){while(!a[8]){
for(i=8;i--;printf(i?"%lx:":"%lx\n",a[i]));
for(p=a;++*p>>16;*p++=0);}}

Explanation: The algorithm itself is reasonably straightforward. I used long rather than unsigned int because it's shorter. Declaring them at the file level means everything's preinitialized with zeros. The f function is a simple increment with carry that operates on the low 16 bits of each word. The loop ends when it carries into the 129th bit.

Iterating backwards for the printf means that we print the addresses in the "proper" order and also the check for printing a newline is a few characters shorter.

This does use some non-portable constructs. It's best regarded as a K&R dialect of C, since it uses implicit int return types and does not include stdio.h. And my use of long was informed by this - on most modern systems int is sufficient because it's 32 bits. This could probably run unmodified on PDP-11 Unix.

However, it can be shorter. If we assume that we can use int (either as a type wider than 16 bits, or a type of exactly 16 bits with various properties that happen to be true on many systems such as twos complement and arithmetic rollover), we can get rid of the stuff related to using long.

Version for int wider than 16 bits, 97 bytes.

a[9],*p;main(i){while(!a[8]){
for(i=8;i--;printf(i?"%x:":"%x\n",a[i]));
for(p=a;++*p>>16;*p++=0);}}

Version for 16-bit systems, 91 bytes.

a[9],*p;main(i){while(!a[8]){
for(i=8;i--;printf(i?"%x:":"%x\n",a[i]));
for(p=a;!++*p;p++);}}

Oddly enough, though, the original K&R compiler didn't actually support the declaration without int (it compiles fine, but treats the variables as external and therefore undefined at link time), so an additional three bytes are needed to change the declaration to int*p,a[9]; for a total of 94.

Also, if the assumption that it is interrupted before completing output were a hard constraint, we could remove the end check, saving five bytes.

Bonus: fully ANSI portable version, 126 bytes:

#include<stdio.h>
long*p,i,a[9];
int main(){while(!a[8]){
for(i=8;i--;printf(i?"%lx:":"%lx\n",a[i]));
for(p=a;++*p>>16;*p++=0);}}

Newlines in all versions are inserted for readability and in locations where whitespace is not required, and are excluded from the byte count, except for the newline after the #include line in the ANSI version.

All versions except the ANSI version fall through at the end of main and therefore may return a spurious exit code to the operating system.

Python 2.7, 67 bytes

n=4**64
while n:n-=1;s='%032x'%n;exec"s=s[4:]+':'+s[:4];"*7;print s

As a side effect of the method used to insert the colons, the addresses are printed with the rightmost column appearing at the left:

ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
fffe:ffff:ffff:ffff:ffff:ffff:ffff:ffff
fffc:ffff:ffff:ffff:ffff:ffff:ffff:ffff
...
0003:0000:0000:0000:0000:0000:0000:0000
0002:0000:0000:0000:0000:0000:0000:0000
0001:0000:0000:0000:0000:0000:0000:0000

Verilog, 335

My first Verilog submission, probably could use more golfing but I don't have the energy to do so right now. c is clock, o is ASCII output. Does not qualify for formatting bonus due to zero-padding instead of abbreviating.

module b(output[0:38]o,input c);reg[127:0]a;wire[0:39]d;assign o=d[0:38];always @(posedge c) a<=a+(~(&a));genvar i,j;generate for(i=0;i<8;i=i+1) begin:q for(j=0;j<4;j=j+1) begin:r assign d[5*i+j]=a[16*i+4*j:16*i+4*j+7]>9?{4'h6,a[16*i+4*j:16*i+4*j+7]-9}:{4'h3,a[16*i+4*j:16*i+4*j+7]};end assign d[5*i+4]=8'h3A; end endgenerate endmodule

This is a simple iteration followed by some bit-twiddling to make the output ASCII. I chop the colon after the last group with a small hack. Synthesizes and appears to work for xc3s500e-4ft256-4 on ISE 13.7 lin64.

AutoIt3, 137 Bytes

For $i=0 To 4^64
$s=StringFormat("%032x",$i)
For $j=0 To 7
ConsoleWrite(StringMid($s,$j*4+1,4)&($j<7?':':''))
Next
ConsoleWrite(@LF)
Next

CJam, 36 27 bytes

G32#{(_"%032x"e%4/':*oNo}h;

-9 bytes thanks to @Dennis (I forgot that CJam has string formatting). Prints the addresses lowercase and descending.

For obvious reasons, use the Java interpreter, not the online one. You can replace G32# with something smaller for testing online though, e.g. here's the last 100.

Explanation

G32#             16^32 = 2^128. Call this n
{ ... }h;        While loop. The final ; is to pop n at the end
 (               Decrement n
 _               Copy n
 "%032x"e%       String format to hex, padded to 32 digits
 4/              Split into groups of 4
 ':*             Join with colons
 oNo             Output with newline

C (with GCC extensions), 76 bytes * 0.8 = 60.8

__uint128_t i;main(){char s[50];for(;inet_ntop(10,&i,s,49),puts(s),++i>0;);}

This uses the 128-bit integers GCC extension to simply count up from :: to ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff. inet_ntop() correctly formats each address so the -20% bonus can be claimed.

Output

Using sed to output every millionth line up to 10 million:

$ ./ipv6all | sed -n '1~1000000p;10000000q'
::
4042:f00::
8084:1e00::
c0c6:2d00::
9:3d00::
404b:4c00::
808d:5b00::
c0cf:6a00::
12:7a00::
4054:8900::
$ 

Note I am using a little-endian x86_64 machine, and that network addresses are typically always in network-order (big-endian), so the endianness is effectively swapped by using inet_ntop(). This does not matter - all addresses will still (eventually) be displayed.