last day (16 days later) » 

9:30 PM
-1
Q: What is the shortest reasonable public IPv6 address?

qräbnöWhat is the shortest reasonable public IPv6 IP address? I ask because I want to obfuscate public IP addresses in log and other files and check for a minimum length.

 
::1 is the local loopback in IPv6, so 3? (oh, you said public)
 
"Public", yeah. :)
 
Well... IPv6 addresses can be abbreviated down to 3 chars at minimum, you may want to read this document about how they can be shortened
 
"Reasonable", so it may exist on the interwebs.
 
::2 could exist...
Why redact them this way?
 
9:30 PM
We are coming closer. :D Because I can. I just train my Python skills. Please explain the downvote.
 
I didn't downvote the post. Are you ok if I move this to chat?
 
Please, go ahead.
 
How about a regular expression?
 
Maybe.. but it seems to only work in perl now that I see it
You're using python, so why not try this?
import socket

def check_ipv6(n):
try:
socket.inet_pton(socket.AF_INET6, n)
return True
except socket.error:
return False

print check_ipv6('::1') # True
print check_ipv6('foo') # False
print check_ipv6(5) # TypeError exception
print check_ipv6(None) # TypeError exception
the indent is messed up
here's a link to it
24
A: Regular expression that matches valid IPv6 addresses

Joe HildebrandIt sounds like you may be using Python. If so, you can use something like this: import socket def check_ipv6(n): try: socket.inet_pton(socket.AF_INET6, n) return True except socket.error: return False print check_ipv6('::1') # True print check_ipv6('foo') # Fal...

 
9:35 PM
Can it also check for private or public address?
 
let me look
 
I know there are libs out there - but hey, I wanted to try my private IP regex stackoverflow.com/a/62925185/1707015 the other way round.
 
Nope
 
I want to obscure ONLY public IP addresses - the last 16 bits (for IPv4) or the last 88 bits (for IPv6), as recommended by the BSI in Germany for log files older than (then?) seven days.
 
So you're hiding IPs from your own log files? Do your files not have a format?
e.g. all my log files contain IPs within the first column, so I could just setup a cronjob to remove the first column from all the logs.
 
9:43 PM
I need to make it in post-processing because I already have a shit load of log files. ;)
 
It may be easier if you can find a pattern
 
As you can see in etherpad I guessed the string len of 3 correctly with < 4 ;)
I am not completly stupid ;)
 
I'm not sure at this point, sorry.
 
Yeah, np, maybe someone will answer more than 3 and I can adjust it.
 
 
2 hours later…
11:42 PM
@qräbnö Private addresses are for IPv4. IPv6 does not have that. The closest thing would be ULA, but there are significant differences between IPv4 Private addresses and IPv6 ULA.
@qräbnö All IPv6 publicly routable addresses are in the 2000::/3 range, but there are ranges within that that are not publicly routable. See the IANA IPv6 Special-Purpose Address Registry that explains what ranges are forwardable and globally reachable (both required for public addresses).
@qräbnö The range of public addresses will be 2000:: to 3ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff, altough not all ranges in that range are public addresses.
 

  last day (16 days later) »