Raspberry Pi: Install and configure No-IP on Raspberry Pi

No-IP enables you to address your Raspberry Pi publicly by hostname rather than IP address. For example, when accessing your machine via SSH from outside your LAN, it’s difficult to remember your public IP. So intead No-IP allows you to create your own easy to remember domain, and assign it to your IP address.

This is heavily documented elsewhere on the web. You can check out the official guide here by No-IP themselves, but this includes a neater startup script at the end.

  1. Create yourself a No-IP account
  2. When logged in, Add a Host.
  3. Enter in a hostname – mine is cookuoprpi – and select a domain under the “No-IP Free Domains” list within the drop down menu. Keep everything else as is, just ensure that your IP address is correct. Your IP address is 54.162.136.26.

Add a Host

  1. Please read Step 5 in combination with this step. Execute the following commands to download and install the client.

sudo su
cd /usr/local/src/
wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
tar xf noip-duc-linux.tar.gz
cd noip-2.1.9-1/
make
make install
/usr/local/bin/noip2 -C

  1. After make install, you will likely be asked to enter your No-IP login details from Step 1, but if you weren’t then the last command will definitely ask you for it. If you have just one hostname on your No-IP account, then answering to “Do you wish to upload ALL hosts?” wouldn’t be a problem. If you do have more than one hostname associated to your account, then pay close attention and type N and select the desired hostname. If answered incorrectly, you will find all your hostnames pointing to that machine.
  2. Press CTRL + D to exit yourself from being the root user, which is what the sudo su command did – you don’t want to be casually using that account if you’re not familiar with the harm it can cause.
  3. Martin O’Hanlon shared a cool script to start No-IP upon boot, so I’m going to be using this instead of the one in the Readme file; purely because the Readme uses killproc. Nothing wrong with it, just no point installing that if you can just use killall instead which ships with Raspbian as standard.

sudo nano /etc/init.d/noip2

Copy and paste the below into the editor.

#! /bin/sh
# /etc/init.d/noip 

### BEGIN INIT INFO
# Provides:          noip
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Simple script to start a program at boot
# Description:       A simple script from www.stuffaboutcode.comwhich will start / stop a program a boot / shutdown.
### END INIT INFO

# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting noip"
    # run application you want to start
    /usr/local/bin/noip2
    ;;
  stop)
    echo "Stopping noip"
    # kill application you want to stop
    killall noip2
    ;;
  *)
    echo "Usage: /etc/init.d/noip {start|stop}"
    exit 1
    ;;
esac

exit 0

sudo chmod 755 /etc/init.d/noip2
sudo update-rc.d noip2 defaults
sudo reboot

  1. Open the required ports on you router to enable access to your Raspberry Pi from outside your LAN. This depends on the service you want to use and/or if you’ve changed the default port of a particular service. For example, SSH by default is port 22 so open that on your router if you wish.
    1. IMPORTANT: Please ensure you’re using public key authentication instead of passwords before you use and open SSH ports. The same goes for any other port forwarding, just make sure you have sufficient security measures in place.
  2. You’re done. You can now address your Raspberry Pi publicly by hostname rather than IP address. Open up Putty and direct it to the hostname.

This post is part of the Public Accessible Raspberry Pi File Server tutorial post.

Leave a Reply

Your email address will not be published. Required fields are marked *