11.3. Naming and DNSIP 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 panelThe 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 InformationTo 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 informationOn 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 DNSEven 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.
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.
11.3.3. Ports and ServicesThe 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.
|