// IP bit tricks // compute an n bit subnet mask, all 1s except for last n bits. int subnet = ~( ( 1 << n ) - 1 ); // generate a list of possible local IP addresses, e.g. // 192.168.0.0 .. 192.168.255.255 int base = (192 << 24) | (168 << 16); for ( int i=0; i<0xffff; i++ ) { int sample = base | i; out.println( DottedQuad.dottedQuad( sample ) ); }