个人工具

UbuntuHelp:DnsAndDhcp

来自Ubuntu中文

跳转至: 导航, 搜索

IconsPage?action=AttachFile&do=get&target=IconNIC.png DNS and DHCP are network related categories. If you are looking for advanced and in depth explanations of these topics, you are in the wrong place - visit the Wikipedia links at the bottom of this page instead. Here we will just explain briefly, in layman's terms, what DNS and DHCP are. DNS = Domain Name System DHCP = Dynamic Host Configuration Protocol ISP = Internet Service Provider - e.g. the company that provides your dialup, DSL, cable, or satellite internet service.

DNS

IconsPage?action=AttachFile&do=get&target=IconUsers.png Essentially, DNS is like an internet phone book. Computers on the internet are identified by IPs which are essentially a string of numbers, similar to how people can be identified by phone numbers or street addresses. Just as you store names in your cell phone because it is not feasible to memorize everybody's phone number, people don't memorize IPs, we memorize domain names. The perfect example of a domain name is google.com - this is what you type into your browser, but google.com has a corresponding IP address which happens to be 72.14.207.99 in the United States (on the West Coast at least). For large web sites and companies, it is possible to have multiple IPs for each domain name, but you usually only talk to one at a time, just like you don't talk to the same person on two phones at the same time. It is also possible that an IP can change, like if it is dynamically assigned via DHCP (see below), but with Dynamic DNS it can keep the same domain name. That is like when your friend gets a new cell phone number, you don't care as long as you have the updated number stored in your cell phone under their name.

DNS Servers

IconsPage?action=AttachFile&do=get&target=PicDocs.png DNS Servers store information about domains/subdomains that fall beneath them and make the information available to other computers. It is possible to setup your own DNS server, you just have to configure your server computer with the right software. If you are interested in setting up your own DNS server, see this link for Hardy Heron or this link for Intrepid Ibex.

DNS Resolvers

IconsPage?action=AttachFile&do=get&target=Icongnomeicu3.png DNS Resolvers talk to other DNS nodes for information about domain names. This allows you to type google.com into your computer and then find out what the IP actually is for that domain, since your computer doesn't know that without inquiring somewhere. In Unix and linux, your DNS resolvers are stored in /etc/resolv.conf - the data in this file is usually collected automatically from your ISP. This config file stores the search domain for DNS servers and two DNS servers called nameservers - the second acts as a backup in case the first server is unavailable at any time. This is like knowing where to look for your phone book so you can find numbers you don't have memorized - you know, just in case you don't tie it to the telephone like in a phone booth.

DHCP

IconsPage?action=AttachFile&do=get&target=IconBookmarksClosed.png DHCP allows your computer to receive an IP address without having one statically assigned to you. This makes network administration on a large scale significantly easier. Most ISPs provide your public IP through DHCP, and if you have a router, your internal IPs are usually assigned with DHCP unless you specify a static IP address. Since IPs are dynamically assigned with DHCP, it is possible for them to change, sometimes at random times. This usually happens when your lease on an IP expires and you don't renew it, so it is assigned to somebody else. This can happen if your computer is turned off when the lease expires, is disconnected from the web, or you switch between ISPs. An example of the latter would be if you take your laptop between work and home - you will have different IPs at each location. To view your public IP, you can visit a website like http://whatismyip.com/. You can look at your computer's specific IP address, whether it is public or private, by using the ifconfig command in terminal. Locate your active network interface and look at the value for "inet addr" - it may look something like "192.168.1.100".

DHCP Servers

Your ISP provides DHCP servers to assign you a public IP address, without which it would be impossible for your computer to interact with the rest of the world wide web. If you have a router, that router usually acts as a DHCP server for your internal network to assign internal IPs to the computers connected to that router (wired or wireless).

Configuration Files

IconsPage?action=AttachFile&do=get&target=IconControlCenter2.png In Debian and Ubuntu, the file /etc/dhcp3/dhclient.conf stores information that is sent to your DHCP server to identify your computer (through the program dhcp3-client). To view this file, run in terminal:

cat /etc/dhcp3/dhclient.conf

For more detail, see the man page:

 man dhclient.conf

Again, your DNS search domain and nameservers are automatically stored in /etc/resolv.conf - to view this file, run in terminal:

cat /etc/resolv.conf

For more detail, see the man page:

 man resolv.conf

Other Resources

IconsPage?action=AttachFile&do=get&target=IconBook-small.png More reading is available at these pages: