Linux Blog

Getting Home

Filed under: General Linux — TheLinuxBlog.com at 6:30 am on Friday, January 16, 2009

Getting into your home network from the wild west known as the internet can be a pain, especially if your IP address is always changing on you, or perhaps the one time that you need to get into your home network your IP address changed.

This happened to me not so long ago, my IP address hardly ever changes but my IP address did happen to change when I moved into my new residence. Assuming that my address would stay the same I headed off to work, unfortunately I was unable to phone home.

Many people know about the free sites that let you update your IP address such as DynDNS, no-ip.org etc. But I couldn’t settle for that mediocre domain. By setting up a CNAME in my DNS I was able to forward a subdomain to my dynamic update address which in effect allowed me to remember home.mydomainname.com rather than the wacky no-ip.org address I chose. You can do the same using free utilities, providing that you have a little time and some control over your DNS.

Before you proceed make sure you have a way of setting a CNAME for your domain name. You can try your domain registrant if you use their web servers, maybe your web host gives you the ability to manage zones and if not ask them if they can add it for you, most times they will.

You will need to set up an account with one of the free providers I used No-IP.com but others like DynDNS.org, freedns.afraid.org, ZoneEdit.com and easyDNS.com should work.

Once you have set up an account with them and have your IP address mapped to a domain name, go ahead and add the CNAME record into your DNS.

The next step is to install and configure the program, script, cron or whatever method your free DNS account uses to update. I used my DD-WRT installation and plugged my account information into the DDNS tab, I checked the update and it registered my IP.

Once you have got your IP address into the free DNS provider, you should check to make sure that it works by doing a lookup on that host name. Use nslookup to do this:

nslookup yoursubdomian.your-free-dns-account.com

If it resolves to your home IP address, then your set to move forward with tackling the task of adding the CNAME into the DNS for your domain name. I cannot cover how to do this with every system in this article but basically you create a zone with the domain, 14400 IN CNAME and the full address of your free DNS with a period at the end. This is important or your name will not resolve properly.

Depending on what DNS servers you use it may take a while for the DNS to get updated. In nslookup I set my server to use OpenDNS’s in to test to make sure the name resolved properly. To do this, start nslookup and type:

> server 208.67.222.222

Once you perform a lookup on your new subdomain, you should see something like the following:

> home.yourdomainname.com

Server: 208.67.222.222

Address: 208.67.222.222#53

Non-authoritative answer:

home.yourdomainname.com canonical name = yoursubdomain.your-free-dns-account.com

Name: yoursubdomain.your-free-dns-account.com

Address: <your IP>

Thats all there is to it. If your IP is updating via your free DNS service and you set up your CNAME then you will be able to find your home, or give your home address to anyone wishing connect without the embarrassment or hassle of explaining your subdomain and free domain account.

htaccess allow from

Filed under: General Linux — TheLinuxBlog.com at 10:32 am on Tuesday, September 9, 2008

htaccess allow from gives you the ability to allow (or deny) specific IP’s or domain names from a directory on your server. To do this the syntax is quite simple. Using VIM or nano open up the .htaccess file in the directory that you want to restrict access to. You need to add the following:

Order Deny,Allow
Deny from all
Allow from 127.0.0.1

This allows access from your local host and the IP address you specify. Using .htaccess you can also allow by host name. This is useful if you wish to allow or deny a friend access to a directory. (note: it will also work if you have them in your hosts file)

Order Deny,Allow
Deny from all
Allow from LinuxBlog
Allow from .thelinuxblog.com

Using htaccess to allow from your LAN is also pretty easy. You use your CIDR address (ip/subnet) to do this try something like this (changing to match your LAN):

Order Deny,Allow
Deny from all
Allow from 192.168.1.1/24

I run into htaccess allow problems a lot, and hope that this will clear the air up for me. htaccess can be very handy if you do not want to keep turning your firewall on and off, but do not want your directories wide open. Just remember, if you want to stop everyone except those you choose to access your apache web directories, use htaccess allow from!