Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Hmm... Why wouldn't I just type the IP in?


Because then you can only serve one site from that address.

With this you could serve as many different sites as you want based on the first part of the domain name.


To expand on this, this problem can usually be solved by editing /etc/hosts. But you can't do that on some platforms such as iOS.

By the way, a neat trick is to assign an alias to your network interface in order to avoid the trouble of DHCP giving you a different IP address each time you connect. For example, on Mac OS X:

  $ sudo ifconfig en1 alias 10.99.99.99 netmask 255.0.0.0
This address will only be reachable from hosts that have a route to it, which can be achieved for example by also giving them an alias on the same subnet. Still, comes in handy at times.

(Obviously you want to be sure you're using a vacant address.)

(And of course, when you have control over the DHCP server there are more elegant ways of achieving this, such as binding your MAC to a static IP address.)

Edited for clarity.


What is the difference between an alias and a static IP address? Also don't most routers attempt to give IPs back to the MAC that last had them?


An alias is an additional static ip.

And most routers try to minimize IP variations, but it's not perfect. Mine doesn't persist IP<->MAC associations when I reboot it.


What is the difference between an alias and a static IP address?

Not sure what you mean. If you're referring to the bit about binding MAC to an address, I should probably have said "fixed IP" rather than "static IP", sorry about that.

Also don't most routers attempt to give IPs back to the MAC that last had them?

I'm hopping between different networks (with different DHCP servers) quite a lot, maybe it's less useful when you're always on the same network.


Ah, no Wilya picked up on why I was confused. Sounds like a great tip, thanks!


Ah, for virtual hosts, got it. Thanks.




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

Search: