Page 1 of 1
Subdomain to my home computer
Posted: Tue Oct 12, 2010 9:45 am
by shiznatix
Ok this is probably something I should know but alas, I do not know how to go about this.
I have a domain, example.com, where I host some stuff such as my email and my own website for myself. Great.
What I want to do is create a subdomain, local.example.com and point that domain to my home computer so when I go to ssh into it or whatnot I don't have to remember the IP address. The domain is registered on name.com and is pointing to the nameservers on dreamhost where I host the other stuff. How do I single out local.example.com to point to MY_IP?
Re: Subdomain to my home computer
Posted: Tue Oct 12, 2010 10:12 am
by Benjamin
Add a subdomain to the zone file. Something like this:
[text]home.domain.com. 86400 IN A 10.10.10.10[/text]
Where 10.10.10.10 is your home IP. You also need to increment the serial number by 1 and then restart bind9.
See
http://en.wikipedia.org/wiki/Zone_file
You probably won't want to use localhost.domain.com, because that normally points to 127.0.0.1.
Re: Subdomain to my home computer
Posted: Tue Oct 12, 2010 10:14 am
by AbraCadaver
Here's the way I do it. I have the same scenario as you and have had this in place for many years. I also have a dynamic IP at my home computer, so how to keep that updated?
1. sign-up for a free account at dyndns.org or similar service and create a record like bobshouse.dyndns.org
2. load a dynamic DNS client on your home computer and configure it to update bobshouse.dyndns.org with your IP address
3. on your dreamhost server add a CNAME record local.example.com that points to bobshouse.dyndns.org
That's it.
Re: Subdomain to my home computer
Posted: Wed Oct 13, 2010 3:23 am
by shiznatix
AbraCadaver wrote:Here's the way I do it. I have the same scenario as you and have had this in place for many years. I also have a dynamic IP at my home computer, so how to keep that updated?
1. sign-up for a free account at dyndns.org or similar service and create a record like bobshouse.dyndns.org
2. load a dynamic DNS client on your home computer and configure it to update bobshouse.dyndns.org with your IP address
3. on your dreamhost server add a CNAME record local.example.com that points to bobshouse.dyndns.org
That's it.
This is the option for me as I also have a dynamic IP (at least they say it is, not sure it has ever actually changed but it probably will some day). Anyway, how do I go about doing step #2? I have the domain working just find right now, the local.example.com points to the dyndns.org and then in turn points to my computer at home, all of that is working just fine. Now I want to make sure that dyndns updates when my IP updates but I don't know how to go about doing that. Can you push me in the right direction?
Re: Subdomain to my home computer
Posted: Wed Oct 13, 2010 7:49 am
by shiznatix
Or actually, I think I want to completely host my own stuff, so that I can run ssl and whatnot without paying extra for it all. So, lets say I have the domain example.com how would I go about getting that to point to my computer even if my computer has a dynamic IP address? What steps could I take for that situation?
Re: Subdomain to my home computer
Posted: Wed Oct 13, 2010 9:38 am
by AbraCadaver
shiznatix wrote:Or actually, I think I want to completely host my own stuff, so that I can run ssl and whatnot without paying extra for it all. So, lets say I have the domain example.com how would I go about getting that to point to my computer even if my computer has a dynamic IP address? What steps could I take for that situation?
I have no idea what you're talking about here.
But for your previous question, this is the client and it will tell you how to configure it:
http://www.dyndns.com/support/clients/ It's different based on whether you have a router/firewall in front of your computer. After you install and configure this client you need to open a port on your firewall/router to allow ssh and whatever else you want. If your home computer is Linux then you can search for ddclient using your package manager. On Ubuntu
apt-get install ddclient.
Re: Subdomain to my home computer
Posted: Wed Oct 13, 2010 10:08 am
by VladSun
shiznatix wrote:Or actually, I think I want to completely host my own stuff, so that I can run ssl and whatnot without paying extra for it all. So, lets say I have the domain example.com how would I go about getting that to point to my computer even if my computer has a dynamic IP address? What steps could I take for that situation?
You could create a script that tells (by simple HTTP request/PHP script) your example.com server what's the new IP (e.g. by creating this script as /etc/ppp/ip-up.d/script.sh). The example.com server should reload bind domain zone file. The problem with such setup is that your example.com zone file must have a very small TTL - e.g. on minute, so that all cached DNS requests expire very quickly. This will in turn put some additional load onto your DNS server, because you cant specify (AFAIK) a TTL per record, but per domain zone file. That is users of example.com will be affected by the new TTL.
Re: Subdomain to my home computer
Posted: Wed Oct 13, 2010 10:28 am
by AbraCadaver
If I understand more by VladSun's post, you can not host your DNS on your home computer if you have a dynamic IP. Just do what I outlined. I'm using it right now and to post this from my home computer while I'm at work using NX.
Re: Subdomain to my home computer
Posted: Wed Oct 13, 2010 10:44 am
by Weirdan
AbraCadaver wrote:If I understand more by VladSun's post, you can not host your DNS on your home computer if you have a dynamic IP.
You are right in that DNS server should have static IP, but Vlad's post was more about how to implement your own dynamic dns.
Re: Subdomain to my home computer
Posted: Thu Oct 14, 2010 5:35 am
by shiznatix
Edit:
Ok, I figured out how to do the point to my home computer thing, I changed the name servers to my registars and then added in the appropriate A records. Great stuff. The problem now is that if my IP changes, then it all goes down (sad).
So now I am looking for a simple tool that will auto update these A records when my IP changes. I was looking into everydns and zone edit but both seam like they cost money and I don't want to have to pay anything.
Any suggestions? I don't really want to be running my own DNS server or anything, just want to keep it simple for now.
Re: Subdomain to my home computer
Posted: Thu Oct 14, 2010 6:49 am
by VladSun
It wasn't so hard to try ...
At your host
Code: Select all
#!/bin/bash
IFACE="wlan0"
DEST="example.com"
IDENTFILE="/etc/ssh/id_rsa"
COMMAND="/usr/local/bin/dyndns.sh"
#____________________________________________________
IP=`ifconfig | grep $IFACE -A1 | grep "inet addr" | cut -d":" -f2 | cut -d" " -f 1`
ssh root@$DEST -i $IDENTFILE "$COMMAND $IP"
At your server (/usr/local/bin/dyndns.sh)
Code: Select all
#!/bin/bash
BINDRELOAD="/etc/init.d/bind9 reload"
ZONEFILE="/etc/bind/zones/exmaple.com.db"
MYHOST="mypc"
TEMPDIR="/tmp"
#____________________________________________________
TEMPFILE=$TEMPDIR/$$.$MYHOST.db
OLDSERIAL=`grep -i Serial $ZONEFILE | head -1 | grep -o '[0-9]\{10\}'`
TODAYDATE=`date +%Y%m%d`
SERIALDATE=`echo $OLDSERIAL | grep -o '[0-9]\{8\}'`
if [ "$SERIALDATE" != "$TODAYDATE" ]
then
let NEWSERIAL="${TODAYDATE}01"
else
let NEWSERIAL=$OLDSERIAL+1
fi
cat $ZONEFILE | sed "s/$OLDSERIAL/$NEWSERIAL/" | grep -v "^$MYHOST " > $TEMPFILE
echo "$MYHOST 1m IN A $1" >> $TEMPFILE
mv $TEMPFILE $ZONEFILE
$BINDRELOAD
Your zone file should have a "Serial" comment on the serial number line (separate new line).
PS: I have been wrong about TTL per records - you can assign individual TTL per every record.
Re: Subdomain to my home computer
Posted: Tue Oct 19, 2010 4:25 am
by shiznatix
Thanks, I will try to get this to work properly
Re: Subdomain to my home computer
Posted: Wed May 27, 2015 11:44 am
by Christopher
Topic locked.