Hacker News new | past | comments | ask | show | jobs | submit login

34. They know how to validate an IP address.

I am surprised by this one. What are the pitfalls there?




Maybe it means a non-reserved IP? 127.0.0.1, is often used as localhost for example, but all of 127.0.0.0–127.255.255.255 is reserved. There are several reserved blocks like this. If you include reserved addresses, every 32 bit pattern is a valid ipv4 address at least in theory. I hear network equipment in the real world is entirely another beast. I remember some ISPs did not work cloudflare's 1.1.1.1 DNS presumably because they were using the address for something else.


IPv4 has a lot of reserved and special-purpose ranges. Hell, I don't think most people could even recite the three major private-use blocks. Multicast and link-local addresses have more complications.

IPv6 is similar, though a little better consolidated. While there is one range of addresses reserved specifically for organization subnets at your disposal (fc00::/7), a lot of people assume just about anything not currently assigned for the internet (presently 2000::/3) will be safe forever.


I understand your point, but I think the context is more of "They can't even handle a fizzbuzz level problem" and not come up with something quite naive (i.e. something like naive RegEx matching), rather than "they can't implement a professional IPv4 validator that takes into account all the intricate special cases with subnets and reserved address blocks."


Yes, but that's still orders of magnitude easier than parsing emails or html...


My personal favorite is assuming that /31 IP subnets (255.255.255.254) are invalid (RFC 3021), but also, to quote wikipedia:

> IPv4 addresses may be represented in any notation expressing a 32-bit integer value. They are most often written in dot-decimal notation, which consists of four octets of the address expressed individually in decimal numbers and separated by periods.

> For example, the quad-dotted IP address 192.0.2.235 represents the 32-bit decimal number 3221226219, which in hexadecimal format is 0xC00002EB. This may also be expressed in dotted hex format as 0xC0.0x00.0x02.0xEB, or with octal byte values as 0300.0000.0002.0353.


I think that is because not every IPv4 adress has the format x.x.x.x There are short forms (i.e. 1.1 that gets expanded to 1.0.0.1, though not sure if that's in the original RFC) or decimal forms. And then there's IPv6, which again has its rules.


Huh, I thought omissions/abbreviations of addresses was introduced with IPv6.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: