Section 11.3. Naming and DNS


11.3. Naming and DNS

IP addresses, especially IPv6 addresses (see the sidebar "IPv6 Addresses," earlier in this chapter), aren't something that you ever really want to deal with directly; hostnames are much more convenient to use. However, every operation that involves a hostname has to involve looking up an IP address for that hostname. For example, when you point Safari or Firefox to www.oreilly.com, the system translates that hostname into an IP address using the Domain Name System (DNS), a distributed naming system that resolves hostnames to an IP addresses.

For the most part, DNS is transparent. All you need to have is a DNS server defined in your network configuration, and you can use hostnames in your applications. Without DNS, all you'll be able to do is surf the Net by IP address, which is possible but not a very fun experience.

If your computer obtained its IP address through DHCP, it should also be configured with the correct DNS server. However, if you have to configure your IP address manually, you'll need to provide valid values for a DNS server. If you have to configure your own DNS servers, make sure you use a DNS server that is close to you on the network. After all, every connection to a host on the Internet requires the resolution of hostname to IP address. The closer you are to the server, the better.

Figure 11-4. Manually configuring network settings in the Network preference panel


The DNS servers that your machine is currently using are shown in the Network preference panel. You can also find them in the /etc/resolv.conf file, as shown in Example 11-3.

Example 11-3. Examining the contents of the resolv.conf file
 $ cat /etc/resolv.conf domain example.com nameserver 192.168.79.5 nameserver 192.168.79.7

On other Unix systems, you can directly edit the resolv.conf file to change your nameserver configuration. However, this file is automatically updated by the networking system in Mac OS X, so any changes you make to it will be lost the next time you change networks.

11.3.1. Looking up DNS Information

To look up an IP address for a hostname yourself, or to find the hostname associated with an IP address, you can use the Lookup tab of Network Utility, as shown in Figure 11-5. Simply enter the host or IP address that you want to look up and click the Lookup button. Other options are available to you through the information pop-up menu. However, for most purposes, the default information setting should give you all the information you need.

Figure 11-5. Using Network Utility to look up host information


On the command line, you can use the host command to determine the IP address for a host or vice versa, as shown in Example 11-4.

Example 11-4. Using host to look up DNS information
 $ host www.oreilly.com www.oreilly.com has address 208.201.239.37 www.oreilly.com has address 208.201.239.36 $ host 208.201.239.36 36.239.201.208.in-addr.arpa domain name pointer www.oreillynet.com.

11.3.2. Multicast DNS

Even without a configured DNS server, there is another component of Bonjour known as multicast DNS (mDNS). mDNS lets computers on a local network know each others' names so that you can access a computer using a human-readable name instead of an IP address. For example, for a machine named Hobbes, you should be able to browse a web server running on it from another machine on the local network by entering into Safari Hobbes.local.

By default, when you install Mac OS X, the name of your machine will be based on the full name given when setting up the first account. For example, the default name of my machine after installing Tiger was "Jason Deraleau's Computer." You should change this to be something a bit shorter and more personalized (throughout this book you'll see Ronin and Hobbes, the names of two of my machines) in the Sharing preference panel.


The combination of mDNS and self-assigned IP addresses provides the foundation for Bonjour to work its magic. With mDNS, Bonjour-enabled computers not only let each other know their names, but they can also advertise the services they offer. When you enable iTunes music sharing or iChat, a description of that service is broadcast via mDNS, allowing any other Bonjour machine to see it.

Wide-Area Bonjour

A feature of Tiger that hasn't gotten much attention is wide-area support in Bonjour. Normally, Bonjour is limited to the local subnet for advertising and discovering network services. Wide-area Bonjour extends the convenience of Bonjour beyond the LAN and brings it to the WAN. This part of Bonjour isn't enabled by default, but some savvy developers have put together a Bonjour preference pane that lets you configure wide-area Bonjour. The preference pane is a free download available at http://www.dns-sd.org/ClientSetup.html.


11.3.3. Ports and Services

The various services provided by a host, such as HTTP for serving web pages or SMTP for handling email, are each exposed to other computers on a separate port: a network connection endpoint in the IP stack identified by a number. For example, HTTP is defined to run on port 80. This means whenever you browse to a page on the server, your web client is opening a connection to port 80 of the server to make its request.

Most services use ports numbered less than 1024; these are known as the well-known ports . Table 11-1 lists the various services and ports built into Mac OS X's firewall. Table 11-2 lists some more common services and their ports. You can also find an extensive listing of well-known services in the /etc/services file.

Table 11-1. Well-known ports found in Mac OS X's firewall

Service

Ports

Personal File Sharing

548/tcp, 427/tcp

Windows Sharing

139/tcp, 137/udp, 138/udp

Personal Web Sharing

80/tcp, 427/tcp, 443/tcp

Remote Login

22/tcp

FTP Access

21/tcp

Apple Remote Desktop

3283/tcp, 5900/tcp, 3283/udp, 5900/udp

Remote Apple Events

3031/tcp

Printer Sharing

631/tcp, 515/tcp

iChat Bonjour

5297/tcp, 5298/tcp

iTunes Music Sharing

3689/tcp

iPhoto Bonjour Sharing

8770/tcp

Network Time

123/udp


Table 11-2. More well-known services and their ports

Service

Ports

Telnet

23/tcp

SMTP

25/tcp

DNS

53/tcp, 53/udp

POP3, POP3S

110/tcp, 995/tcp

NNTP

119/tcp

IMAP, IMAPS

143/tcp, 993/tcp

LDAP, LDAPS

389/tcp, 636/tcp





Running Mac OS X Tiger
Running Mac OS X Tiger: A No-Compromise Power Users Guide to the Mac (Animal Guide)
ISBN: 0596009135
EAN: 2147483647
Year: 2004
Pages: 166

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