4 ms·
... but please don't.
by billpg 3y ago
... but please don't.
- capitainenemo 3y agoObviously the octal and hex and overflow are pretty cursed, but I do like using 10.0.0.* for home IPv4 just 'cause typing ssh 10.1 is so darn convenient.
- theandrewbailey 3y agoI switched to the 10/8 block at home because it's less stupid than typing 192.168.whatever for everything local. I'll have to try this.
- kbenson 3y agoOr set up local DNS and search domains, or even just add entries to your hosts file. `ssh fw` is easy, as is `ssh server`, which while more characters are more in the central typing plane.
- capitainenemo 3y agoI have those too, but I'm familiar with all the IPs and I just got tired of adding DNS entries. Esp for some predictable ones in the "dynamic" range. Also there are times I don't have DNS working. Often times at some console where copy/paste also isn't working or where I don't even have a mouse, and I extra appreciate the simpler typing :)
- ianburrell 3y agoI think the IP address libraries should only accept the standard dotted decimal octet form. And let the others die as non-standard, historical forms.
- lucb1e 3y agoI use this to store IP addresses in a database because you can operate on numbers (e.g. WHERE subnet_start < $thisip < subnet_end) but hardly on the unique dotted format that we normally display them as. Also to specify a bind address when I don't care, like running `php -S 0:3000` (the silly thing wants a bind address rather than only a port number. There, have one!) or accessing localhost in a browser (just typing 0:3000 is enough). For 127.0.0.1, unfortunately the best you can do is writing 127.1. The numeric, hex, and octal variants are 2130706433, 0x7f000001, and 017700000001, which I personally don't find preferable to 127.1.
- crazygringo 3y agoYes, storing is different from displaying though. In MySQL for example, that's what INET_ATON() and INET_NTOA() are for, to convert between binary and display. Analogous to storing timestamps but displaying as datetimes in a timezone.
- lucb1e 3y agoI'd still much rather store something that can be indexed in a btree than something where you have to always call a function on and do full table scans. Of course, before displaying to the user you'd use long2ip again (or the database equivalent you mentioned; I usually avoid doing unnecessary computations on the database and, instead, let the application handle display logic).
- crazygringo 3y agoSorry if I wasn't clear, I was agreeing with you! Yes precisely for indexing (plus just a fixed column size that wastes no space).
- wjholden 3y agoThis is why I love this site. I've been doing networking for many years and I'm not a total novice in databases, but I had no idea MySQL had these functions.
- brobinson 3y agoPrepare to be even more amazed: https://www.postgresql.org/docs/current/datatype-net-types.html https://www.postgresql.org/docs/current/datatype-net-types.h... https://www.postgresql.org/docs/current/functions-net.html https://www.postgresql.org/docs/current/functions-net.html
- chrisdhal 3y agoIf you're using a database, use something like Postgres that has this functionality built in[0]. You can store IPs, networks, etc. in a native format that has all sorts of functionality available out of the box. [0] https://www.postgresql.org/docs/current/functions-net.html https://www.postgresql.org/docs/current/functions-net.html
- ghayes 3y agoI'm not convinced we shouldn't have (originally) adopted using pure hex, e.g. 0x7F000001 instead of 127.0.0.1. Personally, I think it makes subnet masks, etc, a lot _more_ obvious.
- sgjohnson 3y agoYes. The nibble boundary is at every 4, not 8 bits too, making subetting A LOT easier.
- marginalia_nu 3y agoNext you'll tell me to stop visiting the alternate timeline where everyone has a mustache and domain names end in a period. https://news.ycombinator.com./item?id=35751030 https://news.ycombinator.com./item?id=35751030 ;-) ( warning: your cookies for news.ycombinator.com won't work in news.ycombinator.com. )