Explanation

You have two types of IP.

  • IPv4: It looks like that: 192.168.1.78
  • IPv6: It lokks like that: 2001:0db8:0000:85a3:0000:0000:ac1f:8001

I recommand to use v4 all the time, even if we going to the end.

It is just more confortable. When the time will come, your internet provider will force you to IPv6.

You have also two kind of IPs:

  • Local IP
  • Public IP

 

 

Local IP

This is the IP defined between your internet box and your computer/raspberry/smartphone/Iot device.

It is generally start with 192 and looks like that 192.168.1.20

Generally, you internet box is set on 192.168.1.1

You can check them on the interface of your box.

If you want to check the one your computer on Windows: > ipconfig If you want to check the one of your PI: > ifconfig

Public IP

This is the one which identify you on the internet network. This is like your phone number.

You can read your IP here.

In most of the cases, for technical reasons, this address is changing periodically (once per day maybe).

If you want to acces to your server from outside, you need to call this address, but due to the periodcal change, you will never know which is the current public IP of your box.

For that your need a domain name service.

 

 

DNS services

There are planty of DNS services available.

OVH Domain name

  • Unlimited sub-domain (nas.mycloud.ovh, printer.mycloud.ovh, etc...)
  • Very stable - around 3€ per year

In order to re-send the IP every time: Create a python script like this one:

import requests

from json import loads

from urllib2

import urlopen

data = loads(urlopen("http://httpbin.org/ip").read())

print("actual ip:" +data["origin"])

host="MYDOMAIN.ovh"

username="USERNAME"

password="PASSWORD"

url="https://www.ovh.com/nic/update?system=dyndns&hostname="+host+"&myip="+ data["origin"].split(",")[0]

print(url) > >res = requests.get(url, auth=(username, password))

print(res)

Then, set this kind of CRON task (triggered every hours here) :

crontab -e > 0 */1 * * * python /etc/my-dns-update.py

Free service

  • never tested
  • http://www.duckdns.org

Port forwarding

After the IP system, let's get closer to the port system. On each computer, you have an IP (like a phone number). But this IP provide access to differents services (like different desks).

Theses services are using port number between 0 and 65536.

For example: - http is on 80 - https is on 443 - ftp is on 21 - ssh is on 22

You need to configure the port in the box in order to reached the computer port.

For example: If you call mycloud.ovh on port 22 (SSH), the box should not that the request should be rooted to the server on port 80.

I cannot describe this procedure here because it is depending on each provider and each model. Just search "port fowarding" follow by your provider brand should gave you the correct information.