Host website without static IP
I always wanted to try to setup a home based server. So I created a setup with Raspberry Pi, TP-link Router and a free Dynamic DNS service.
Stuff that you need :
- Raspberry Pi / Laptop / PC [I am using Raspberry Pi with Debian based OS]
- Cludflare or DNS service
- Own domain name [If you have]
- Working internet connection
Step 1:
Install Nginx or any web server in Raspberry Pi.
Step 2:
Use a DDNS service like freemyip.com
Go to freemyip.com and check your domain is available or not.
If available claim it and store the credentials.
Save the URL that appears on your screen.
Step 3:
Setup Dynamic DNS in your router. [Not necessary maybe I was not able to test without that due to clear field is not option available]
Step 4:
Get your IP address by running this command
1
curl -4 icanhazip.com
Step 5:
Update the DNS record with your IP
1
2
# replace <> with your values
curl https://freemyip.com/update?token=<your token here>&domain=<your-ddns.freemyip.com>&myip=<your IP here>
Cool now you can access the server with the Domain you created with DDNS service. [In here freemyip.com]
Step 6:
If you have a domain and want to point that to new server then add a CNAME record.
1
CNAME your-domain.com your-ddns.freemyip.com
Step 7:
Now we don’t have static IP so it will keep changing after a while.
To update that you can create a cron to keep the things updated every minute.
Get connected with me on Instagram : @d.vlpr and Twitter : dhsathiya