Access your server from the outside world with a dynamic IP-addres

Difference between a static and a dynamic IP

An IP address is used to communicate between computers. When a server has a static IP this will never change unless someone decides to. This IP is manually entered in the computer or server.An example of who uses a static IP is a web server. Every domain name has a web server, every public web server has an static IP.  For example www.google.com has the static IP  74.125.230.112 this IP will never change unless Google decides to move the web server to an other location. Because it isn’t possible to learn every IP-address on the internet we invented DNS (Domain Name System). How DNS works I’ll explain in one of my following tutorials for now just remember that DNS will resolve a domain name to the IP of the server.

What are the advantages and disadvantages of a static IP distribution

Advantages:

  • You can learn the IP
  • You can host a web server

Disadvantages

  • You need to configure an IP on each computer
  • You need to remember which IP-addresses are already used in your network

What are the advantages and disadvantages of Dynamic IP distribution

90% of the computers use a dynamic IP. This IP is distributed by a DHCP server.

Advantages

  • You don’t have to configure an IP manually
  • You can use Dynamic Domain Named Services to find your computer

Disadvantages

  • You need an DHCP server
  • You need to configure reserved addresses for printers etc
  • You don’t now which IP belongs to which computer unless you use DNS

So how do I solve my problem when my ISP gives me a dynamic IP and I want to contact my personal server from the world wide web?

Well, I’m going to explain this for my own ISP (also the router settings, this can be different on your router).

The problem

Belgacom gives me a new IP every 48 hours.There is no possibility to learn this.But I need to access my server true the www. There are 2 ways to solve this either I’m going to pay 30euro each month for a static IP or I can install a DDNS service on my server. So how am I going to solve it? The answer is quiet simple Dynamic Dns. I’m going to install a tool on my server which reports every 15 min to a free service.

I’m using the service of www.no-ip.org I suggest that you make an account and add a new domain. The no-ip.org client is multi platform. So no worries. I’m installing the service on a Debian 6.0 server. First I need to download the client to my server. The commands will be in bolt and italic.

Before we start you must register a new

root@debian: wget https://www.no-ip.com/client/linux/noip-duc-linux.tar.gz

After this command the wget will download the file. You will see a very nice progress bar.

root@debian: tar -xvf noip-duc-linux.tar.gz

root@debian: cd noip-2.1.9-1/


root@debian:~/noip-2.1.9-1 make install

After this the service will be ready to be used. The default interval is 30min. This means you can have 30 min downtime (MAX) when your IP is changed. The service will compare its public IP with the last known public IP. If they match the program won’t update. If they don’t match the service will update the DNS and change the IP to the new IP.

So we have access to our IP but we can’t reach our server. This is normal. Before we can access our server we need to adjust our router. We have 2 possibilities. Either we are going to work with a DMZ host or we are going to use port forwarding

DMZ

DMZ is used to forward all traffic to a specific host inside your network. Be aware that when you use DMZ you should configure a firewall on your server. If you don’t configure a firewall all users from the WWW will be able to talk to your server for example the port 80 or 3306 the MySQL port. I’m not a big fan of DMZ because of the security issues. Also when you have multiple servers like me it could be that you would like to redirect a connection on port 80 to one server and a connection on port 81 to an other server.

PORT Forwarding

The second option is port forwarding. As I said before you can edit the settings of your router to forward specific ports to an internal device or server. In my case I would suggest you forward port 22 to your server (CHANGE THIS PORT). If you forward port 22 to your server you will be able to access your server from the WWW. You can forward each port you want and have less security issues because your router will only forward the ports he knows. The others will be blocked by the device.

After this the setup is completed and your server will be accessible from the outside.

Feel free to ask any questions.

Comments are closed.