Hack 78 Setting Up Domain Name Service

figs/expert.giffigs/hack78.gif

The most important step in bringing an Internet server online is making sure it can be found from the outside world.

Mac OS X, in addition to being a fabulous desktop machine, also has a full-fledged Unix server humming away beneath the hood. You can serve up web pages [Hack #88], send mail through your own sendmail [Hack #82] server, retrieve mail using IMAP or POP [Hack #82], and so much more.

Of course, bringing a server (particularly a web server) online isn't all that helpful unless you make sure it can be found and reached from the outside world.

Whether you are on a local intranet or on the Internet, an IP address is how people locate your computer. I'm not going to go into a lot of detail here, but when you register a domain name, you are required to point that domain to a name server, and that name server has an IP address.

The problem is that most DSL/cable companies give you a fat connection, but they don't include a static (nonchanging) IP address. They usually assign you a dynamic IP address that might change hourly, daily, or whatever. The problem is that you can't point to a domain name or locate your computer on the Internet if the IP address is always changing. It's like having your computer in the witness relocation program. Luckily, there is a solution.

78.1 Get a Static Address

Your first option is getting a static IP address from your DSL/cable provider. My DSL provider wants to charge me an additional $10 per month for that service, but I'm trying to cut down my costs, not increase them.

78.2 A Better Idea

Traffic on the Internet is simply routed from one IP address to another. No one can remember to type 102.0.43.23 when they want something like Yahoo!, so someone created a way of locating machines called Domain Name Service (DNS). When you type in www.oreillynet.com, DNS servers are able to resolve the proper IP address associated with it and take you to that location.

78.3 How Does This Help Me?

A number of organizations and companies provide what are called dynamic DNS services; for a fee, they will give you a DNS hostname. They do not redirect traffic to your IP address (which would involve traffic passing through their servers), but instead they point the computer requesting the domain name/DNS hostname of the correct IP location. Using a service like this ensures that whenever there is a request for your domain, it will always know where to point visitors.

If your dynamic address at home is always changing, how do they know what your current address is? Simple: you use a client application on your computer that pings your current local IP address, detects whether there has been a change, and updates the dynamic DNS service's database (see Figure 6-46). So, if my current IP changes from 215.23.0.34 to 64.23.123.3, the program takes that second number and sends the update to the dynamic DNS service. Easy as pie!

Figure 6-46. Dynamic DNS when you have a dynamic IP
figs/xh_0646.gif

I use a service called DynDNS (http://www.dyndns.org). You can find a pretty good FAQ on this service at http://support.dyndns.org/dyndns/faq.php. If you use the service, you should support it by making a small contribution each year. The client I use is a carbonized freeware application called Mac Dynamic DNS, written by James Sentman. It has a number of features that allow for some pretty advanced scheduling and logging. It ain't pretty, but it does the job reliably. You can find the application on the DynDNS site.

Now, I want to point out that you don't have to register your own domain name to use this service. DynDNS has a number of existing domains that you can use. For example, you could create a domain name similar to yourusername.homeunix.com. This saves you the nominal cost of setting up a domain name and still gives you the ability to point people to your computer.

Go ahead and set up an account and make the donation. It may take up to 48 hours for confirmation from the donations department that your donation was received, so be patient.

78.4 Setting Up the Client

Go to the Network Preferences pane and make sure your network connection is set to DHCP so that your ISP will assign you an IP address properly.

A note about firewalls/routers: if your Internet connection travels though firewall software or a router, you may experience some trouble accessing your computer. Make sure it is set to accept inbound connections to port 80 (the default for HTTP requests). If you are using a DSL/cable router, make sure you've set up port forwarding properly (check your router's manual for instructions). Still having trouble? Check whether your ISP blocks inbound connections to port 80 (some have done this because of Internet worms). If this affects you, set up your HTTP server on a different port (for example, 8080).

Now, if you've made your donation and followed the DynDNS instructions to create your account, you need to add this account information to the Mac Dynamic DNS application. It has an easy-to-follow wizard that will walk you through creating the client account (see Figure 6-47). Set this as your master account, turn the account on, and click Check Now to update your IP address with the DynDNS service. When it has communicated with the service, it will show your current IP address in the window. Don't forget to set the application's preferences to update the address automatically!

Figure 6-47. Macintosh Dynamic DNS regularly updates DynDNS.org
figs/xh_0647.gif

The agraham999 account is on, displays my IP, and shows the last time it was checked. Hopefully, your IP address will look different. You can click Check Now to have it override the schedule.

Because I don't know how often my DSL provider updates my IP, I've set the Dynamic DNS application to check my connection every 15 minutes and notify DynDNS.org of any changes.

Be sure that you set this application (and its background application) to launch at startup via the Login Preferences pane.

Alan Graham



Mac OS X Hacks
Mac OS X Hacks: 100 Industrial-Strength Tips & Tricks
ISBN: 0596004605
EAN: 2147483647
Year: 2006
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net