Subdomain to my home computer

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Locked
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Subdomain to my home computer

Post 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?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Subdomain to my home computer

Post 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.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Subdomain to my home computer

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Re: Subdomain to my home computer

Post 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?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Re: Subdomain to my home computer

Post 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?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Subdomain to my home computer

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Subdomain to my home computer

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Subdomain to my home computer

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Subdomain to my home computer

Post 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.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Re: Subdomain to my home computer

Post 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.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Subdomain to my home computer

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Re: Subdomain to my home computer

Post by shiznatix »

Thanks, I will try to get this to work properly
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Subdomain to my home computer

Post by Christopher »

Topic locked.
(#10850)
Locked