Please don't. Use regex to find something that looks like an IP then build a real parser. This is madness, its's extremely hard to read and a mistake is almost impossible to spot. Not to mention that it's slow.
Just parse [0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3} using regex (for v4) and then have some code check that all the octets are valid (and store the IP as a u32).
And dupe check. 0.0.0.0 and 000.000.000.000 may both be valid, but they resolve the same
Fuck that, if for whatever reason I'm writing an IP validator by hand I'm disallowing leading zeros. Parsers are very inconsistent, some will parse 010 as 10, others as 0o10 == 8 (you can try that right now with a POSIX ping). Talk about a footgun.
some will parse 010 as 10, others as 0o10 == 8
...and that's me in the fetal position, thanks.
Definitely, tho if you store it as a u32 that is fixed magically. Because 1.2.3.4 and 1.02.003.04 both map to the same number.
What I mean by storing it as a u32 is to convert it to a number, similar to how the IP gets sent over the wire, so for v4:
Because 1.2.3.4 and 1.02.003.04 both map to the same number.
But 10.20.30.40 and 010.020.030.040 map to different numbers. It's often best to reject IPv4 addresses with leading zeroes to avoid the decimal vs. octal ambiguity.
I don't know why anyone would write their IPs in octal, but fair point
It's not about how people write them, it's how parsers parse them. IPv4 has been around since 1982, and most parsers interpret leading zeros as octal.
True enough for database or dictionary storage, but a lot of times things get implemented in arrays where you still wind up with two copies of the same uint32.
IPv6 was a mistake. We should have just added an addition octet
That would allow for like, 2 trillion devices? Feels like a bandaid, my dude. Next you’re gonna suggest a giant ice cube in the ocean once a year to stop global warming.
So add two more octets:
Moat companies will still just use something like 10.0.13.37.0.1
IPv6 is not made with internal networks in mind lol
You can use a ULA if you want to. That's essentially the IPv6 equivalent of a private IP.
Why though? Having the same IP for both internal and external solves a bunch of issues. For example, you don't need to use split horizon DNS any more (which is where a host name has a different IP on your internal network vs on the internet). You just need to ensure your firewalls are set up properly, which you should do anyways.
Never claimed it was, please quote me where I said as much
My dude, you used the 10.xx private IP as an example. Why wouldn’t they assume you were referring to internal networks?
I thought it was pretty clear with me adding 13.37 that I was making a joke, the earlier post spoke about how just adding one octet would still be too few addresses, so I joked about adding one more octet.
I’m only pointing out why the other poster would make the assumption you were referring to an internal network. Do with it what you will.
And nuke the hurricanes
Hurricanes cannot cross the equator. The equator is an imaginary line, and hence has zero mass. We can end every hurricane using zero point zero energy (0.0).
o.O
ONCE AND FOR ALL
AND MY AXE!
You could follow this logic and add 2 alphanumeric digits before 4 numeric octets. E.g. xf.192.168.1.1
This would at least keep it looking like an IP and not a Mac address. Another advantage would be graceful ipv4 handling with a reserved range starting with "ip" like ip.10.10.10.1
Oh yeah, great, let's change the fundamental protocol on which all the networks in the world are based. Now two third of the devices in the world crashed because you tried to ping 192.168.0.0.1
that WOULD be quite funny for the first second or 2....
You didn't specify it couldn't be in CIDR block notation...
::/0
Remember, when we abbreviate an ipv6 address all leading zeros are reduced to a single 0.
E.g
0003 would just become 03
When there are geoups of 4 zeros these can be represented as a single 0 or as a double colon ::
But we can only use the :: once so when summarizing an address containing multiple groups of 4 0s one after the other they can all be abbreviated to a single ::
Eg
fe80:0000:0000:0000:0210:5aff:feaa:20a2 would become fe80::210:5aff:feaa:20a2
Therefore it is perfectly valid to abbreviate an address of 0000:0000:0000:0000:0000:0000:0000:0000 /0 to just ::/0
Eh, I've seen some software internally prefer 0::0 instead of just ::0 or :: . Notation wise though you are correct, it is unnecessary.
This excludes all the ipv4 ips that have a 0 in the 2nd, 3rd, and 4th octets. Sorry but we're going to have to revoke your Network Engineering credentials.
thanks, fixed
Not to nitpick, but an IPv6 address is represented as eight groups of four hexadecimal digits separated by :. Like 2001:0db8:3333:4444:5555:6666:7777:8888.
Omg, that's twice now I've messed it up. Fixed.
This reminds me of something I saw online maybe 20 years ago now. Someone created a torrent with a name like "every IP address ever (hacking tool)" and uploaded it to Suprnova, which ended up having thousands of people seeding it. It was just a text file with every IPv4 from 0.0.0.0 to 255.255.255.255 😂
Heard about that too!
Is there an updated version for ipv6?
That file would be ungodly large. There are 2^128 possible addresses, each weighing in at 128 bits, 16 bytes. 16 bytes times 340 trillion trillion trillion. That puts us around 5.44 trillion Zettabytes. The estimates I've seen for worldwide data storage sit aroun 60-70 zettabytes.
IPv6 version is just a Python script that generates random 128-bit integers. Eventually you'll hit a valid IPv6 address!
127.0.0.1, I'm an introvert
one of them has a 7 I’m pretty sure
wow don't doxx me plz
0.0.0.0/0
/32
That's only 1 ip (single host)
1 and 0. Some assembly required.
32 or 128 of them, depending on protocol.
My PC's is now Bob, My router's Billy...
0/0
I mean if I name them do I have to own the domain or…
0.0.0.0/0
::
I'll start.
0.0.0.1: Sophie
Your turn.
0.0.0.2 is Bob
0.0.0.3 is Clarence
0.0.0.4 is Darryl
127.0.0.1 is you
ipv6
Name every protocol
TCP
UDP
UDP
I'd love to tell you a joke about UDP but I'll never know if you get it.
Ok. This covers every ipv6 and ipv4 address.
"^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:)))(%.+)?\s*$"
Please don't. Use regex to find something that looks like an IP then build a real parser. This is madness, its's extremely hard to read and a mistake is almost impossible to spot. Not to mention that it's slow.
Just parse [0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3} using regex (for v4) and then have some code check that all the octets are valid (and store the IP as a u32).
And dupe check. 0.0.0.0 and 000.000.000.000 may both be valid, but they resolve the same
Fuck that, if for whatever reason I'm writing an IP validator by hand I'm disallowing leading zeros. Parsers are very inconsistent, some will parse 010 as 10, others as 0o10 == 8 (you can try that right now with a POSIX
ping
). Talk about a footgun....and that's me in the fetal position, thanks.
Definitely, tho if you store it as a u32 that is fixed magically. Because 1.2.3.4 and 1.02.003.04 both map to the same number.
What I mean by storing it as a u32 is to convert it to a number, similar to how the IP gets sent over the wire, so for v4:
octet[3] | octet[2] << 8 | octet[1] << 16 | octet[0] << 24
or in more human terms:
But 10.20.30.40 and 010.020.030.040 map to different numbers. It's often best to reject IPv4 addresses with leading zeroes to avoid the decimal vs. octal ambiguity.
I don't know why anyone would write their IPs in octal, but fair point
It's not about how people write them, it's how parsers parse them. IPv4 has been around since 1982, and most parsers interpret leading zeros as octal.
True enough for database or dictionary storage, but a lot of times things get implemented in arrays where you still wind up with two copies of the same uint32.
IPv6 was a mistake. We should have just added an addition octet
That would allow for like, 2 trillion devices? Feels like a bandaid, my dude. Next you’re gonna suggest a giant ice cube in the ocean once a year to stop global warming.
So add two more octets:
Moat companies will still just use something like 10.0.13.37.0.1
IPv6 is not made with internal networks in mind lol
You can use a ULA if you want to. That's essentially the IPv6 equivalent of a private IP.
Why though? Having the same IP for both internal and external solves a bunch of issues. For example, you don't need to use split horizon DNS any more (which is where a host name has a different IP on your internal network vs on the internet). You just need to ensure your firewalls are set up properly, which you should do anyways.
Never claimed it was, please quote me where I said as much
My dude, you used the 10.xx private IP as an example. Why wouldn’t they assume you were referring to internal networks?
I thought it was pretty clear with me adding 13.37 that I was making a joke, the earlier post spoke about how just adding one octet would still be too few addresses, so I joked about adding one more octet.
I’m only pointing out why the other poster would make the assumption you were referring to an internal network. Do with it what you will.
And nuke the hurricanes
Hurricanes cannot cross the equator. The equator is an imaginary line, and hence has zero mass. We can end every hurricane using zero point zero energy (0.0).
o.O
ONCE AND FOR ALL
AND MY AXE!
You could follow this logic and add 2 alphanumeric digits before 4 numeric octets. E.g. xf.192.168.1.1
This would at least keep it looking like an IP and not a Mac address. Another advantage would be graceful ipv4 handling with a reserved range starting with "ip" like ip.10.10.10.1
Oh yeah, great, let's change the fundamental protocol on which all the networks in the world are based. Now two third of the devices in the world crashed because you tried to ping 192.168.0.0.1
that WOULD be quite funny for the first second or 2....
Could have sped up adoption significantly.
They played us for absolute fools!
heared of ipv5?
Plus the MAC address
https://imgs.xkcd.com/comics/perl_problems.png
It's always a treat to debug a regex of that size.
I knew there would be someone with the regex.
You're more of a perl programmer than network engineer :P
.*
Technically, this one also matches everything:
*exits the room*
0.0.0.0/0 0::0/0
You didn't specify it couldn't be in CIDR block notation...
::/0
Remember, when we abbreviate an ipv6 address all leading zeros are reduced to a single 0.
E.g
0003 would just become 03
When there are geoups of 4 zeros these can be represented as a single 0 or as a double colon ::
But we can only use the :: once so when summarizing an address containing multiple groups of 4 0s one after the other they can all be abbreviated to a single ::
Eg
fe80:0000:0000:0000:0210:5aff:feaa:20a2 would become fe80::210:5aff:feaa:20a2
Therefore it is perfectly valid to abbreviate an address of 0000:0000:0000:0000:0000:0000:0000:0000 /0 to just ::/0
Eh, I've seen some software internally prefer 0::0 instead of just ::0 or :: . Notation wise though you are correct, it is unnecessary.
0.0.0.0 /0 ::/0
SUCK MY DICK, GRU!
Haha spot on
This is the way.
:00
-:ff
Edit: Just learnt this can be also noted as:
::
-::f
What about IPv4
0.0.0.0/0
Better hope the goon hasn't heard of IPv6 either, or you're toast
::/0
Undefined
This is gonna take a while...
0.0.0.0
0.0.0.1
0.0.0.2
0.0.0.3
...
0.0.0.0/0
::/0
Winrar
Chicken dinrar?
0.0.0.0/0
ipv4 [0,255].[0,255].[0,255].[0,255]
ipv6 [0000,ffff]:[0000,ffff]:[0000,ffff]:[0000,ffff]:[0000,ffff]:[0000,ffff]:[0000,ffff]:[0000,ffff]
This excludes all the ipv4 ips that have a 0 in the 2nd, 3rd, and 4th octets. Sorry but we're going to have to revoke your Network Engineering credentials.
thanks, fixed
Not to nitpick, but an IPv6 address is represented as eight groups of four hexadecimal digits separated by :. Like 2001:0db8:3333:4444:5555:6666:7777:8888.
Omg, that's twice now I've messed it up. Fixed.
This reminds me of something I saw online maybe 20 years ago now. Someone created a torrent with a name like "every IP address ever (hacking tool)" and uploaded it to Suprnova, which ended up having thousands of people seeding it. It was just a text file with every IPv4 from 0.0.0.0 to 255.255.255.255 😂
Heard about that too! Is there an updated version for ipv6?
That file would be ungodly large. There are 2^128 possible addresses, each weighing in at 128 bits, 16 bytes. 16 bytes times 340 trillion trillion trillion. That puts us around 5.44 trillion Zettabytes. The estimates I've seen for worldwide data storage sit aroun 60-70 zettabytes.
IPv6 version is just a Python script that generates random 128-bit integers. Eventually you'll hit a valid IPv6 address!
127.0.0.1, I'm an introvert
one of them has a 7 I’m pretty sure
wow don't doxx me plz
0.0.0.0/0
/32
That's only 1 ip (single host)
1 and 0. Some assembly required.
32 or 128 of them, depending on protocol.
My PC's is now Bob, My router's Billy...
0/0
I mean if I name them do I have to own the domain or…
0.0.0.0/0
::
I'll start.
0.0.0.1: Sophie
Your turn.
0.0.0.2 is Bob
0.0.0.3 is Clarence
0.0.0.4 is Darryl
127.0.0.1 is you
ipv6
Name every protocol
I'd love to tell you a joke about UDP but I'll never know if you get it.
(Yes, this is a TCP joke)
127.0.0.1
Heh, you just doxxed yourself
127.0.0.1
https://worldpopulationreview.com/country-rankings/ip-address-by-country
USA sure does have a lot of IPs!
People name IPs outside of DNS, I mean is there like a Susan or a Karen, perhaps a Clark IP?
Doug
s.w.x.y/z
plug it into a 5-dimensional graph and there you go.