Assigning a .local Domain to Your Raspberry Pi (aka Stop Forgetting Your IP Address)🗓
Here's the first of hopefully many Raspberry Pi posts! I just got a kit for Christmas and I started toying with it last night. Most of my posts are first likely won't be too unique, however, they'll be a nice written documentation of everything I've done so far for myself and possibly someone else can enjoy it as well. :)
Even though I assigned a static IP address based on my Raspberry Pi's MAC Address in my router settings I still felt like setting up an easy way to access my Pi box due to the fact that my Airport Extreme likes to be horribly unreliable when it comes to reserving IP addresses.
Since I use OS X on all of my computers I figured the best way was to setup a .local domain using avahi, which impliments Zeroconf (aka Bonjour) on Linux distros easily. As always thanks to apt-get this can easily be installed by running the following command:
sudo apt-get install avahi-daemon
Once the install is completed you'll be ready to roll. So long as you have Bonjour running on your system like Android, iOS, OS X have by default (PS -- If you don't have Bonjour on PC the fix is pretty easy, just install iTunes.) you can now access your Pi by replacing its IP address with raspberrypi.local. If you are running a web server you can even access your device by visiting http://raspberrypi.local/ in a web browser.
The way Zeroconf works is by taking your devices hostname and adding local to the end of it, the reason raspberrypi.local works by default is because, assuming you are using the default wheezy build that is suggested, the default hostname is raspberrypi. If you'd like to customize your .local domain you'll want to change your hostname.
To do this you'll want to enter the following command:
sudo nano /etc/hostname
You should be greeted by a text file that just reads the name of your hostname, raspberrypi. Just delete this and replace it with whatever you want your hostname to be.
Once you've got the hostname set close out of nano saving your changes (control + x, then y.).
Last by not least give everything a quick reboot for good measure by running:
Once the box comes back you can no longer access your Pi by visiting raspberrypi.local, but by visiting whateveryouput.local. (devbox.local in my case!)
You might notice causing other fun stuff like converting other devices on your network to hostname.local views as well.
Boo numbers, yay for words.———