Forget IP Addresses! Use /etc/hosts!
Written by Matt on August 16, 2008 – 12:13 pm -After realizing the endless possibilities of having a Linux server in my home, I quickly set one up (using Ubuntu Server Edition). Now I have a server with SSH, HTTP, FTP, and NFS setup in my basement. I love using all these features, but I can’t stress enough that typing the internal IP address of the server (192.168.1.250) got old very fast. So I found a quick and easy solution: /etc/hosts
Simply open /etc/hosts in your favorite text editor (you’ll need root priviliges), go to the bottom line, and follow this format:
192.168.1.250 Server
The first option is the IP address of whatever you’d like to add a name to, and the second option is the name. So after saving this file, I can now type Server instead of 192.168.1.250 anytime I’d like to access my server. So now I can SSH into my server by typing “ssh Server”. Have an HTTP server setup? Open Firefox and simply type “Server” in the address bar! How simple is that?
Posted in Usability Tips |
View blog reactions

August 18th, 2008 at 11:48 am
I think its important to note that you need to modify your /etc/hosts file on any desktop/laptop machine that will be accessing the server and not actually modify the servers /etc/hots. A good follow up would be port forwarding and dynamic dns to make your server available from outside your internal home network.
August 18th, 2008 at 12:44 pm
I remember doing pretty much the same when I started. Back then I had a p133 running OpenBSD. I used to ssh into it from UNI and get my files from it. There are many things you can do with a linux box!
Now I have a 2 tb fileserver hosting shares to my ps3
August 18th, 2008 at 2:51 pm
Use Bind and setup a DNS server on your Ubuntu box. This is much better than editing your hosts files. http://ubuntuforums.org/showthread.php?t=236093
August 18th, 2008 at 8:12 pm
I have openwrt running on my wireless router, and put all of my computers in the router’s host files, so I can access them all by name. I never have to bother with it on any specific computer, and it even works if a friend comes over.
August 18th, 2008 at 10:52 pm
This works until DHCP kicks in. That’s why Dnydns or any DNS server is important. You should include that part, as most people don’t pay extra for a static IP.
August 19th, 2008 at 1:44 am
Take care; /etc/hosts should not be edited unless there is no other option! Use DNS to resolve all names to IP addresses in your network.
After all the adventures you have had with SSH, HTTP, FTP, and NFS, this should not be a very hard nut to crack. Have fun!
Regards, Robert de Bock.