Raspberry Pi easy access with static IP
  • For anyone that cares, I thought that I would share a way to make accessing your networked pi a little bit easier.

    First set your raspberry pi to boot with a static ip address with this:

    sudo nano /etc/network/interfaces

    paste this into the file, change the address and netmask to whatever you want (ideally it should be set to a number outside of your router's dhcp address pool)

    auto lo
    iface lo inet loopback

    auto eth0
    iface eth0 inet static
    address 192.168.2.203
    netmask 255.255.255.0

    quit and save.
    Manually restart your network interfaces with:

    sudo /etc/init.d/networking restart

    check that the changes worked by typing 'ifconfig'

    Now your pi will always have the same ip address on your network. If you want to take it a step further, you can add an entry in your hosts file to turn your ip into a human readable address.

    on windows navigate to: C:\Windows\System32\drivers\etc
    open the hosts file with any text editor.
    At the end of the file add a line with your ip address, a space (or tab), then the human readable address you want to use.
    for example, mine reads like this:

    192.168.2.203 thegrid.com

    just make sure that it's a .com that you would never really want to visit anyway.

    Now, when you are using ssh, a web browser, or an ftp client; you can simply type in the human readable address. so in a web browser, thegrid.com takes me to my rom uploader on my raspberry pi. yay!

    I hope that this helps!
  • How did I miss this? Awesome tutorial!

    llamaduckmonkeyparty.com takes me to the uploader! Yeah :D

    Thanks heaps!
  • nice! haha. It's probably also worth mentioning that some setups require you to add your gateway address to the /etc/network/interfaces file. I haven't figured out why some people need it and some don't (it probably depends on the router) but at the end of the file add
    gateway 192.168.2.1
    the address should be the base ip of your routers ip-pool.

    If you find that you are having trouble installing packages via apt-get install, then you probably need to add the gateway address.
  • Worked fine for me though :)
    I assume the second part would work on a Linux desktop too? I think the hosts file is in /etc
    I'll try it out tonight, thanks again!
  • yeah, it works on linux and mac too. I just don't remember where the host files are located.
  • Alright, thanks :)
  • Just for the hell of it, I tested it on Android :)
    The Linux/Android hosts file is /etc/hosts
    I sometimes ftp from my Nexus 7, so it may be useful :)
  • nice! If I'm going to be out of town, I like to forward a port on my router to the ftp on my raspberry pi, so I still have access to it.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!