1

I have a Raspberry Pi B+ hooked up to my home network. Sometimes when I'm away from home I need to ssh into it.

I'd like to know if exists a script that can tell me (via sms, telegram or e-mail) its dynamic IP address.

  • 1
    I wonder why you don't use static IP if you usually SSH into your Pi. Using also a DDNS server if your ISP doesn't provide you an static IP and you wouldn't have this problem. – migrc Apr 28 '16 at 14:57
  • I suggest you ask about this on our larger sibling site Unix & Linux. I would migrate it directly, but I suspect it has already been asked and answered there and so would be bounced back as a duplicate. – goldilocks Apr 28 '16 at 15:43
  • 1
    In my case the router that my ISP installed allows me to use a DDNS service then I just have to do some port forwarding. – migrc Apr 28 '16 at 15:45
  • 1
    @migrc You're kind of right (which is why I deleted that last comment). The pi does not have an address of its own, the router does, so you would need a router that allows for port forwarding to make the email solution work. Not all ISP's provide those, but many still should (my major telecom one does not anymore). – goldilocks Apr 28 '16 at 15:47
3

Have you tried using http://www.noip.com/ 's dynamic vpn service? Just install noip2 on your pi, follow the instructions on the website, forward port 22 on your router, and voila you have a domain that allows points to your dynamic ip at home.

1

You Pi probably has a private ip address it got from your home router. Your router is usually the only device that has a public ip address.
You can ssh into your Pi if you forward port 22 on your router to your Pi's port 22.

You'll still need to know your router's public address though.

One quick way to check your router's current public ip address is to ask duckduckgo.
That address is likely to change in the future, so you'll need something to deal with that.

The Easy Way

A Dynamic DNS service lets you access you public ip address by name, even if the address changes.

I started using the free version of no-ip just last week.

  1. You pick a domain name (like, say, gmontini.ddns.net).
  2. You download a ready-made program onto a Windows, OS X, or Linux PC that will run in the background. The program periodically checks for changes to your public ip address and updates the ddns record on no-ip's servers appropriately.
  3. Every 30 days, you have to log into their website in order to keep your domain name.
    The price of free stuff!
    (I haven't done this part yet.)

(The program (called noip2) is also available for the Pi, but you have to compile it yourself and write the init script too. That's really easy though (no fighting with dependencies or the linker) and it comes with a really good README with an example init script.)

The Hard Way

If you don't want to use a dynamic vpn server, you could install postfix which lets your raspberry pi send email messages.

But you'd probably have to fight...

But once you've got that working, you can get emails on your phone (if you get email on your phone) or get text messages (by having your Pi email the right sms gateway)

You just need to create a cron job that runs a shell script that checks your public ip address and sends you an email if it's changed since the last check.

Another Hard Way

  1. You could buy a USB to SIM card adapter and a prepaid T-Mobile SIM card.
  2. Plug them into your Pi.
  3. Magically configure them (I don't know how to do this.)
  4. Have a cron job that runs a shell script that checks your public ip address and sends you a text message if it's changed since the last check.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.