I’m pretty sure you have your own server at home. Maybe it’s a small
and efficient Raspberry PI. It could even be a full blown server.
You want to access your data from outside easily. Or maybe you’d like to
host some webserver or other software and make it accessible to the
world.
There is only one slight problem. Most consumer home networks have
dynamic IP’s. This means that your IP changes every 24 hours or at a
different predefined time.
Without a static IP you’ll always have to gi.ve your new IP address to
others, or what’s worse You would need to change your DNS IP record
everyday yourself!
Continue reading for the solution!
Using Dynamic DNS
There is a very easy way in which you can have your dynamic IP pointed to your own DNS name.
Before setting up a dyamic dns in your router talk to your Internet
Service Provider if they do automatic Dynamic DNS.
My IPS provides me with a service in which i get a subdomain which is
always automatically assigned to my dynamic IP.
If your IPS does the same great! If not, don’t despair, read on how you can set this up yourself.
Finding out your router’s IP
Now, you might be asking yourself.. how do you figure out your router’s
ip address?
Open up the commandline on Windows and type
ipconfig
The command for Linux is similar:
ifconfigenp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.3.106 netmask 255.255.255.0 broadcast 192.168.3.255 inet6 2a02:2f0e:d218:f600:9405:ef42:b2b7:b7fc prefixlen 64 scopeid 0x0<global> inet6 2a02:2f0e:d218:f600:def:e277:1a40:7861 prefixlen 64 scopeid 0x0<global> inet6 fe80::1f34:846e:2b13:dde6 prefixlen 64 scopeid 0x20<link> ether 6c:3b:e5:1a:b1:48 txqueuelen 1000 (Ethernet) RX packets 553933 bytes 780006958 (780.0 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 140153 bytes 14703234 (14.7 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 17 memory 0xef300000-ef320000
Use the default gateway IP address. On Linux systems you might need to run the route -n command to find the gateway IP.
route -nDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 192.168.3.7 0.0.0.0 UG 100 0 0 enp1s0
+ You then can browse to the Ipv4 Ip address in your browser. Depending on your router you might have a different user/password combination for login
Setting up Dynamic DNS in your router
Setting up Dynamic DNS in your router is extremely easy if it’s supported. The settings are really unique depending on your router. Most routers support automatically logging in to services like dyndns. These give you a subdomain where you can chose a name. You can use a service like https://setuprouter.com/ to help you find out about your settings. If your router doesn’t support this feature you might need to buy one which does.
For example, even old routers (10 years old) like the Sweex LW050V2 support DDNS. My new Huawei Gigabit Router doesn’t support Dynamic DNS, but my Internet Service Provider does via its system!
After you’ve setup dynamic dns write it down, you’ll need it later
Pointing your DDNS your own DNS
I know I sad you will be using your own DNS. Well, services like dyndns allow you for an extra fee to set up your own dns.
What I prefer to do is buy a domain form let’s say name.com and then point a CNAME record from the subdomain I want to use to the dynamic dns one.
Setting a TTL for about 16 hours. You can also choose 12 or 8 hours to be safe if your IP changes more frequently.
I own the domain "lba.im". In this example whenever someone tries to
access "yourownsubdomain.lba.im" they will be redirected to
"yourownsubdomain.dyndns.com"
You can easily add www in the hostname to redirect to your primary DNS.
Running multiple apps in your subdomain
You can easily add multiple hostnames which alias to your dynamic dns.
This will allow you to host multiple applications. You do however need a
loadbalancer to do this.
Consider using Traefik, nginx or haproxy on your local system.
Port Forwarding
Don’t forget to setup port forwarding in your router! Port forwarding needs to be setup for everythign else to work. The logic is that you will have only 1 external IP but multiple internal IP’s
And if you’re at port forwarding, be sure your firewall allows incoming connections:)
Conclusion
You can have your own domain name point to your home server even behind a dynamic changing ip. All you need is to setup a dynamic dns which will be pointed to by your dns. Don’t forget to setup port forwarding.