TCP/IP for Linux



Table of Contents

  1. Introduction
  2. TCP/IP Basics
  3. Subnet Addressing/CIDR
  4. DNS
  5. DHCP
  6. Ports
  7. Installing TCP/IP for Linux
  8. Configuring TCP/IP for Linux
  9. Troubleshooting Tools


Introduction



TCP/IP Basics


Binary Overview


Disguising the IP address

Some spammers try to disguise their IP address by using a nonstandard IP addressing scheme. For instance, a mythical spammer URL might read:

http://3232236545/getrippedoff.html

To decode the IP address, 3232236545, do the following:

  1. Convert the number 3232236545 to binary. Using a program to do the conversion is easiest. The binary form of the number is 11000000101010000000010000000001
  2. The number you got should be 32 digits long. If it isn't, add enough 0's at the beginning to make it 32 digits long. In our example, it is already 32 digits long.
  3. Break the binary number up into 4 groups (or octets) of 8 digits each: 11000000.10101000.00000100.0000001
  4. Now convert each octet into its decimal equivalent: 11000000 => 192; 10101000 => 168; 00000100 => 4; 00000001 => 1
  5. The "mysterious" IP address is 192.168.4.1

IP address Rules

Not just any set of numbers can be a valid IP address; there are rules.


Reserved IP addresses

The following IP addresses are reserved for private use, and should be used for internal networks:

The range 127.0.0.0-127.255.255.255 is also reserved for the loopback network and should not be used.

Despite the above addresses being reserved, this does not mean you will never see them on the Internet. IP addresses from crackers and script kiddies can be forged, and other instances are the result of misconfiguration. It is a good idea to block these addresses at your firewall or router if possible, both incoming and outgoing. Most ISP's don't filter these addresses very well, if at all.



Subnet Addressing/CIDR - Subnet Mask


Subnet Addressing/CIDR - Example

A simple way to determine the network ID (or address) given a subnet mask is to convert both to binary, multiply digit wise, and the result is, in binary, the network address.

For example, given an IP address of 192.168.4.19/28 (or 192.168.4.19/255.255.255.240 in the old style) the result would be:

192.168.4.18 in binary: 1 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 1
28 1's: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0
bitwise multiplying 1 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 192.168.4.16 network

Notice that the IP address in this case, 192.168.4.16 would have a host ID of all 0's. This is why a host ID can't be all 0's. All 0's means this network.


Classes

The old style of assigning subnet masks was to use classes. Of course, subnetting, or supernetting would change the subnet mask. Still, it did, and still does, give you the best CHANCE of correctly guessing the subnet mask. The following table gives you the rundown:

Class IP Range Prefix (Binary) Default Subnet Mask
A 1.x.x.x - 126.x.x.x 0 255.0.0.0
B 128.x.x.x - 191.x.x.x 10 255.255.0.0
C 192.x.x.x - 223.x.x.x 110 255.255.255.0
D 224.x.x.x - 239.x.x.x 1110 N/A
E 240.x.x.x - 255.x.x.x 1111 N/A

Note that class D is for multicasting (not covered) and class E is reserved/experimental. Do not try to use these as an IP address for your system. In fact, any class E address you see on your Internet interface are likely forged packets (or the result of a misconfigured/messed up program). Also, 127.x.x.x is left out of the table because it is reserved for the loopback network.


Guessing the Subnet Mask Example

Guessing the subnet mask is rather risky. Given the address 192.168.18.18, what is the correct subnet mask? What network is it on? Answer: It's impossible to tell for sure. According to the class table, the subnet mask should be 255.255.255.0 and the network would be 192.168.18.0. However, it doesn't have to be. Here are a few of the possibilities:

IP Address Subnet Mask Network
192.168.18.18 255.255.255.0 192.168.18.0
192.168.18.18 255.255.0.0 192.168.0.0
192.168.18.18 255.255.240.0 192.168.16.0
192.168.18.18 255.255.255.240 192.168.18.16

Because the entire 192.168.x.x range of IP numbers is reserved for private (non-Internet) use, all the possibilities in the above table are perfectly valid and legitimate IP/subnet mask pairings.


Advantages of CIDR over IP classes

One reason classes aren't so great is that they lock you into a fixed size of your network. The only way to get any flexibility is to subnet. Take a look at the following table:

Maximum Number of Networks and Hosts per Network
Class Default Subnet Mask # of Networks # of Hosts per Network
A 255.0.0.0 126 16,777,214
B 255.255.0.0 16,384 65,534
C 255.255.255.0 2,097,152 254

Suppose your company had a network with 500 hosts, and would never add any additional hosts. Under the class system, Class C would be too small, so your company would have to be assigned a Class B network address. However, this wastes a whole lot of usable IP addresses. Since there is a finite number, this is a problem. One, temporary, answer was to do away with the classes and go to CIDR. With CIDR, you can, in theory, get a network sized almost exactly to your needs. In this example, one solution is to assign 192.168.0.1/23 which allows for 510 hosts.

Another solution is to subnet. Some feel, including this author, that subnetting and CIDR are essentially the same thing.


What is subnetting and why would I want to do it?

Subnetting:

Each new network you create by subnetting requires its own, unique, network ID.


Subnet Sizing

The first thing you have to do to subnet is figure out what size you want the new segment(s) to be. To calculate the number of hosts and/or the number of networks on your new subnet, use the following formulas:

# of Networks # of Hosts
2i but see notes below (2j) - 2
i = # of network ID bits borrowed from
the host ID portion of your assigned subnet mask
j = # of host ID bits left in the new subnet mask

Note that i+j must equal the number of host bits in your original, assigned subnet mask.

How is this formula derived? The following refers to the binary numbers, not decimal. Remember that every time you add an additional bit, the number of possibilities doubles. For example:

# of bits Possibilities # of Possibilities Formula
1 bit 0, 1 2 21 = 2
2 bits 00, 01
10, 11
4 22 = 4
3 bits 000, 001
010, 011
100, 101
110, 111
8 23 = 8

This should, hopefully, explain where the 2x part comes from.

The "- 2" for hosts comes into play because a host ID of all 0's means, in TCP/IP, this network. It is not a valid host ID. A host ID of all 1's means a broadcast to everyone on this network. It too is not a valid host ID. Hence, 2 must be subtracted from the number of hosts in the formula. Note that with every new (sub)network, you lose 2 possible hosts. Therefore, it becomes tricky to size properly. To many new networks, and you run out of IP's. To few, and you don't have enough networks.


Subnet Sizing continued

The formula for networks assumes you are subnetting (or perhaps supernetting), not looking at the whole 32 bit range (which isn't available anyway). FYI, for networks, a network ID of all 0's means a specific host on the local network. It is not a valid network, and is used for DHCP (in the form of 0.0.0.0/32, which is a broadcast source), but I have yet to encounter any other use. On the other end of the spectrum, a network of all 1's is a broadcast, meaning everybody. It is also not a valid network, except for DHCP where an address of 255.255.255.255/32 is a broadcast destination. If you aren't using DHCP, these addresses should be blocked at your firewall.

Given that you are subnetting, a certain number of bits are already mandated by whoever assigned you your network range. You can borrow additional bits from the host ID to make more networks. However, there are limits as to how many bits you can borrow. In some texts, the formula for networks 2i will instead be written as 2i -2 . This is because RFC 950 originally forbade the use of the subnetted network IDs where the bits being used for subnetting are set to all 0's (the all-zeros subnet) and all 1's (the all-ones subnet). The all-zeros subnet caused problems for early routing protocols and the all-ones subnet conflicts with a special broadcast address called the all-subnets directed broadcast address.

However, RFC 1812 did away with the limitation and allows the use of the all-zeros and all-ones subnets in a Classless Interdomain Routing (CIDR)-compliant environment. CIDR-compliant environments use modern routing protocols which do not have a problem with the all-zeros subnet and the use of the all-subnets directed broadcast has been deprecated. Before you use the all-zeros and all-ones subnets, verify that they are supported by your hosts and routers. Linux supports the use of the all-zeros and all-ones subnets.

An example of this would be the subnet mask 255.255.255.128 (original was 255.255.255.0) . Under the old system this isn't a valid subnet mask. The .128 part uses only 1 bit for the subnet ID. Since 1 bit can only be 0 or 1, it is an all 0's and all 1's subnet ID. Under CIDR, it is valid, and you don't waste as many numbers.

Another limitation of this formula is you have an upper limit as to how many host ID bits you can borrow for your subnet ID. You must leave at least 2 bits for the host ID.

# of host ID bits # of hosts allowed
0 20 - 2 = -2 not valid
1 21 - 2 = 0 valid, but pointless
2 22 -2 = 2 VALID!

Subnetting Example

  1. Your boss sends you a memo. Starting with the network 192.168.4.0/24 (255.255.255.0 in the old form), break the old network into 7 new subnetworks with at least 35 hosts per network.
  2. Being a very knowledgeable IT person, unlike your boss, you know that all your systems are RFC1812 compliant, so you can have all 0 and all 1 subnets.
  3. Looking at the formulas above, the smallest number of bits you can borrow from the host ID to come up with at least 7 subnetworks is 3. (22 = 4, not big enough, 23 = 8 big enough).
  4. Since there are only 8 host bits in the original network, and you are using 3 for the new subnets, that leaves 5 bits for the new hosts. 25 -2 = 32 -2 = 30. It is not possible to make this subnet.
  5. You go back to your boss and tell him it's impossible. He calls you an idiot who can't understand that he said 3 networks, not 7. You show him his memo, to which he responds that his dumb secretary mistyped it. His "dumb" secretary overhears this, and books his next business flight with 15 layovers through airports with really bad security, to "save money".
  6. With only 3 networks, you must borrow only 2 bits from the host ID. (This give 4 networks.) This leaves 6 bits for the host ID's. 26 -2 = 64 -2 = 62, more than meets the requirements given to you. Therefore the new subnet mask will be /26 (or 255.255.255.192 in the old form).
  7. The new networks are:
  8. Subnet IP Range (Not host!)
    1 192.168.4.0 - 192.168.4.63
    2 192.168.4.64 - 192.168.4.127
    3 192.168.4.128 - 192.168.4.191
    4 192.168.4.192 - 192.168.4.255


DNS - What is it?

DNS stands for Domain Name System. Computers don't think in words or letters; computers think in numbers only. A name like www.hlug.net means nothing to a computer. Humans on the other hand, like words. What does the site at 204.251.209.49 contain? In this case it is currently the site aka www.hlug.net . DNS is a way to convert names and numbers back and forth (among a few other things we won't get into).

Imagine for moment there was no DNS. Whenever you wanted to go somewhere on the web, you have to type in the IP address, rather than a name. Also, email address had to be followed by numbers, not names. For instance suppose instead of writing root@localhost, you had to write root@127.0.0.1 . That wouldn't be very convenient for you. It's not hard to imagine people would start compiling lists of IP address and what they are such as:

IP Address What is it?
127.0.0.1 localhost
204.251.209.49 HLUG's site (www.hlug.net)
204.174.18.129 User Friendly (www.userfriendly.org)

Well, DNS is just a very fancy form of that list. Before DNS when the Internet was far, far, smaller, people did in fact use a list. Using a list to find an IP address still exists today. In both Linux and Windows, the list is called hosts (Windows also has another list called lmhosts, but that is for a slightly different purpose). In Linux, hosts is generally found in the /etc directory.

Here is what my hosts file looks like:

127.0.0.1               localhost localhost.localdomain
192.168.4.179           newlinux

Your hosts file will probably have the first line, but may or may not have any other lines. The format of the file is pretty simple. First is the IP address, separated by some whitespace, then one or more host names, each separated by whitespace.


DNS - Why use it?

Note that since DNS just returns an IP address (oversimplifying), you may use an IP address instead of a name. For example, typing in your web browser http://204.251.209.49 takes to the same place as typing in http://www.hlug.net . However, you should avoid using IP addresses when you can. An IP address can change without notice. DNS will note the change and give you the correct IP number.


The Birth of DNS


Which Nameserver Holds the Correct Piece?

An example using www.hlug.net


Configuring DNS

The format of resolv.conf is as follows:

  1. domain followed by the local domain name. Multiple entries are not allowed. Optional
  2. search followed by a list of alternate domain names to search for a hostname. Optional
  3. nameserver followed an IP address of a domain name server to query when resolving names. Multiple nameserver lines (up to 3) are allowed, but each line can have only one IP address. Technically optional, but really, really, recommended.

Using the above resolv.conf example, if you asked your computer to resolve a host named robert, it would when using DNS, in order:

  1. Contact the first nameserver listed, in this case 192.168.10.1 .
  2. Ask that nameserver to resolve robert.fake.my.domain.cxm
  3. If that nameserver did not answer, ask the next nameserver to do the resolving (192.168.12.1)
  4. If the nameserver (whichever one) could not resolve robert.fake.my.domain.cxm, then your computer would try to resolve robert.my.domain.cxm .
  5. If robert.my.domain.cxm could not be resolved, then your computer would try to resolve robert .
  6. If robert did not resolve, you would get an error message.

Hosts and DNS



Ports

Suppose you (at 192.168.1.1) want to visit a web site at 192.168.1.2. The setting up the a connection might go something like this.



Installing TCP/IP for Linux

All distributions I know of come with tcp/ip already installed. You don't need to do anything to install it!



Configuring the interface

There are number of good tools for this: linuxconf, netconf, netcfg, etc. However, for those that wish to do this by hand (and there is one good reason why)...The network interface configuration are stored in text files. In RedHat and Mandrake based systems, the files are in /etc/sysconfig/network-scripts. The files are ifcfg-. Examples include ifcfg-lo, ifcfg-eth0. All configuration directives take the form

Directive="somevalue"

The configuration directives are:



Troubleshooting tools


ping

Background info

Using Ping

Decoding the output

Here is a sample ping output with leading line numbers added:

1  [robert@newlinux ~] $ ping -R -c 4 keng     
2  PING keng.mydomain.cxm (192.168.4.13) from 192.168.4.179 : 56 data bytes
3  64 bytes from 192.168.4.13: icmp_seq=0 ttl=128 time=0.4 ms
4  NOP
5  RR:     newlinux.mydomain.cxm (192.168.4.179)
6          Keng.mydomain.cxm (192.168.4.13)
7          newlinux.domain.cxm (192.168.4.179)

8  64 bytes from 192.168.4.13: icmp_seq=1 ttl=128 time=0.3 ms NOP (same route)
9  64 bytes from 192.168.4.13: icmp_seq=2 ttl=128 time=0.3 ms NOP (same route)
10 64 bytes from 192.168.4.13: icmp_seq=3 ttl=128 time=0.3 ms NOP (same route)

11 --- keng.mydomain.cxm ping statistics ---
12 4 packets transmitted, 4 packets received, 0% packet loss
13 round-trip min/avg/max = 0.3/0.3/0.4 ms

Here's the line by line explaination:

  1. [robert@newlinux ~] $ ping -R -c 4 keng
    The command that started the pinging. Here I want the path "-R", tell ping to only send 4 packets "-c 4" and give a hostname to pring "keng". Note that the hostname is not case sensitive.
  2. PING keng.mydomain.cxm (192.168.4.13) from 192.168.4.179 : 56 data bytes
    This is the first output line from ping. Ping resolved the host name to "(192.168.4.13)". It also gives me the FQDN for the host keng as "keng.mydomain.cxm". Next, ping tells me which IP address it is sending the ping packets from "192.168.4.179". This is more useful when you have multiple interfaces on your machine, but gives you some information about how your routing table is setup. Finally, ping tells me how many bytes of data it is sending in each packet "56 data bytes". Note that there are 8 bytes of ICMP header data for a total packet size of 64 bytes. The number of data bytes can be changed.
  3. 64 bytes from 192.168.4.13: icmp_seq=0 ttl=128 time=0.4 ms
    This is the first packet that came back. "64 bytes" came back, which is the same number sent out. This is normal. If the number differs, it means there is a problem somewhere between your computer and the other computer, possibly including the other computer. Next, ping tells you the IP address of the packet that just came back "192.168.4.13". This matches the address you sent the packet too. If it doesn't match, that means either someone is playing games on the other computer, or someone on the network is running a pretty lousy sniffer. The "icmp_seq=0" tells you that this is the first packet you sent (numbering starts at 0). All the sequence numbers should be sequental. If not it means there is a problem, probably on the line, but possibly to the other computer. Next up is "ttl=128" which is the time to live. It doesn't provide much useful information. Finally is "time=0.3ms" which tells you how long the packet took to get back to you. This is useful for gauging the speed of the connection. It is normal for this number to vary. A time of 0.3 ms means this is most likely on a low traffic local network.
  4. NOP
    I have no idea what this stands for.
  5. RR:     newlinux.mydomain.cxm (192.168.4.179)
    This is the start of the routing information. The source of the packet was my machine (as would be expected).
  6. Keng.mydomain.cxm (192.168.4.13)
    More routing information. This says the next machine the packet visited was 192.168.4.13 . In this case, it happens to be the destination machine too.
  7. newlinux.domain.cxm (192.168.4.179)
    This is the final destination of the packet.
  8. 64 bytes from 192.168.4.13: icmp_seq=1 ttl=128 time=0.3 ms NOP (same route)
    This gives the same info as line 3, except the packet number is one higher (which it should be).
  9. Same as line 3, except for the packet number.
  10. Same as line 3, except for the packet number.
  11. --- keng.mydomain.cxm ping statistics ---
    Formatting line for some summary statistics.
  12. 4 packets transmitted, 4 packets received, 0% packet loss
    Shows how many packets were lost. 0% is the best (and usual) case.
  13. round-trip min/avg/max = 0.3/0.3/0.4 ms
    Gives some round trip time info.

Using ping to troubleshoot

Note that you should always use IP numbers when troubleshooting unless you are 100% certain DNS is working ok.

  1. ping 127.0.0.1 . If you can't ping this, this means either your firewall is misconfigured, or your TCP/IP protocol isn't starting up. The problem lies with your computer, otherwise, proceed to step 2.
  2. Ping your interface by ip number. In the example above, it would be ping 192.168.4.179 . If you can't ping this, it means your interface is not working properly. It could just need to be started. If this works, proceed to step 3.
  3. Ping your default gateway by ip number. Since it is possible, but not likely, your default gateway doesn't respond to pings, you should do this step when everything seems to be working ok. If your default gateway doesn't respond, the problem lies there (at least). If this works, or the gateway doesn't respond to pings, proceed to step 4.
  4. Ping the remote system. It is possible, and if it is on the internet, likely that it doesn't respond to pings anyway. This should be determined ahead of time. You might need to try something else here, such as traceroute, or just seeing if they have a web page.
  5. Finally, try pinging something by host name. If this fails, but the other tests suceed, that means something is wrong with DNS (or your hosts file).

netstat

Background info

Using Netstat

Decoding the output

Here is a sample (faked) netstat output with leading line numbers added:

1 [root@newlinux ~] # netstat -a --inet -p -n

2 Active Internet connections (servers and established)

3 Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program Name
4 tcp 0 53 192.168.1.1:23 192.168.1.2:4567 ESTABLISHED 2345/in.telnetd
5 tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 3546/sendmail
6 tcp 0 0 192.168.1.1:80 0.0.0.0:* LISTEN 588/httpd
7 tcp 0 0 127.0.0.1:80 0.0.0.0:* LISTEN 588/httpd
8 tcp 0 0 0.0.0.0:113 0.0.0.0:* LISTEN 543/inetd
9 tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN 543/inetd
10 tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 543/inetd
11 udp 0 0 192.168.1.1:137 0.0.0.0:* 757/nmbd
12 udp 0 0 192.168.1.1:138 0.0.0.0:* 757/nmbd
13 udp 0 0 0.0.0.0:137 0.0.0.0:* 757/nmbd
14 udp 0 0 0.0.0.0:138 0.0.0.0:* 757/nmbd

Here's the line by line explaination:

  1. This is the line that launched netstat. Here, I want all active inet sockets, by IP number only, with the program name. Note that is is run as root.
  2. First line of output from netstat. Not much of importance here.
  3. This is the header line.
  4. This line shows an active telnet session. Telnet is a tcp protocol, the session has been established. The local address is 192.168.1.1:23, and the other end of the connection is at 192.168.1.2:4567. The program that owns this socket is in.telnetd. This is the telnet server program, and server port 23 is the telnet port. Telnet is a very dangerous program to use.
  5. This line is an email program (specifically sendmail) waiting for someone to connect to it. The local address is 0.0.0.0:25 which means sendmail is listening on port 25 (the SMTP port) on every interface. Unless you are operating a public mail server, this is very bad form. The every interface means your internet connection can be connected to. A better way to do this is to limit which interfaces your mail server listens on. In fact, you should try very hard to elminate any and all local addresses that start with 0.0.0.0 unless you want to offer that to the world. See 6 and 7.
  6. This is a web server (probably Apache) listening for web requests only on the 192.168.1.1 interface (port 80). This means anyone trying to connect to the internet interface on port 80 looking for an Apache exploit is SOL. No one is listening, but you still have a web server for the intranet. To exploit this web server, someone would have to break in some other way and then come back through the 192.168.1.1 interface. This just raised the difficulty level tremedously, independent of having a firewall. (Having a firewall is still HIGHLY recommended.)
  7. This is the same as line 6, except here the web server is listening on the loopback interface (127.0.0.1) rather than some other interface. If you are limiting interfaces that servers listen on, it's usually a good idea, and pretty safe, to add the loopback interface. Note that the same service (PID and program name) has more than one line in netstat. This is normal.
  8. This line, and the next 2 lines are inetd listening for various connections on any interface. This demonstrates that a single service can listen on several different ports at the same time. In this case, ident is listening for auth requests.
  9. See also line 8. In this case, inetd is listening for telnet connections on all interfaces. This is very risky from a security stand-point.
  10. See also line 8. This line shows inetd listening for FTP requests on all interfaces.
  11. This line is Samba listening for netbios name service UDP packets on the 192.168.1.1 interface. Note that since UDP is a stateless protocol, there is no state. The netbios name service is a form of DNS for microsoft networks.
  12. This line is Samba listening for netbios datagram service UDP packets. See line 11 for more info.
  13. This is almost the same as line 11, except this is Samba listening for netbios broadcasts. Samba will not respond (directly) to anything on this interface. This line will almost always be here if you are running Samba, even if you tell it to only work on select interfaces.
  14. See line 13.

Traceroute

Background info

Using Traceroute

Decoding the output

Here is a sample traceroute output with leading line numbers added:

1    [robert@linux robert]$ /usr/sbin/traceroute www.hlug.net
2   traceroute to www.hlug.net (204.251.209.49), 30 hops max, 38 byte packets
3   1  adsl-208-191-175-254.dsl.hstntx.swbell.net (208.191.175.254)  23.491 ms  23.351 ms  28.194 ms
4   2  core2-vlan50.hstntx.swbell.net (151.164.11.126)  14.174 ms  15.819 ms  16.166 ms
5   3  bb1-g8-0.hstntx.swbell.net (151.164.11.246)  13.218 ms  15.009 ms  14.480 ms
6   4  sl-gw20-fw-6-3.sprintlink.net (144.232.194.73)  21.121 ms  20.283 ms  20.006 ms
7   5  sl-bb20-fw-5-0.sprintlink.net (144.232.11.125)  19.379 ms  20.658 ms  19.608 ms
8   6  sl-gw15-fw-0-0.sprintlink.net (144.232.0.137)  19.891 ms  20.663 ms  20.128 ms
9   7  sprintloopback.mylinuxisp.com (216.39.192.9)  28.781 ms  29.890 ms  29.462 ms
10 8  www.hlug.net (204.251.209.49)  29.969 ms  27.830 ms  32.932 ms

Here's the line by line explaination:


nslookup

Background info

Using nslookup

Types of DNS records (this is NOT an exhaustive list!)

nslookup interactive mode example

  1. [robert@linux robert]$ nslookup
    The command that starts the interactive mode.
  2. Default Server:  dns1-rcs.rcsntx.swbell.net
    Show which nameserver is the current default.
  3. Address:  151.164.1.8
    Shows the address of the default nameserver
  4. >
    Notice the prompt? nslookup is waiting for a command. After you enter a command (except for exit), nslookup returns another prompt. From here on, I will omit the next prompt.
  5. > www.yahoo.com
    Server:  dns1-rcs.rcsntx.swbell.net
    Address:  151.164.1.8
    
    Non-authoritative answer:
    Name:    www.yahoo.akadns.net
    Addresses:  216.32.74.53, 64.58.76.176, 64.58.76.179, 216.32.74.55
    	  216.32.74.52, 64.58.76.177, 216.32.74.50, 64.58.76.178, 216.32.74.51
    Aliases:  www.yahoo.com
    This shows a lookup of www.yahoo.com. The DNS server that you asked (and returns the answer) is given as is it's address. It is a "non-authoritative answer", meaning it is a cached answer and could be wrong. Next is the DNS that is authoritative for www.yahoo.com. There are multiple addresses for www.yahoo.com, meaning there is a cluster of servers you connect to, not just one. This is done mostly to spread out the load. Aliases shows the various servers are known as www.yahoo.com, but that is not their real name.
  6. > set q=ptr
    The "set q=" command tells nslookup what type of record I want returned. "A" records are the default. Now I want to know the hostname associated with a particular IP address.
  7. > 216.32.74.53
    Server:  dns1-rcs.rcsntx.swbell.net
    Address:  151.164.1.8
    
    53.74.32.216.in-addr.arpa	name = www4.dcx.yahoo.com
    74.32.216.in-addr.arpa	nameserver = ns1.yahoo.com
    74.32.216.in-addr.arpa	nameserver = ns5.dcx.yahoo.com
    74.32.216.in-addr.arpa	nameserver = ns.exodus.net
    74.32.216.in-addr.arpa	nameserver = ns2.exodus.net
    ns1.yahoo.com	internet address = 204.71.200.33
    ns5.dcx.yahoo.com	internet address = 216.32.74.10
    This shows what is returned now that I am looking for a hostname from an ip address. This is known as a reverse lookup. The DNS server name and ip are given as before. Next is the line with the name returned, www4.dcx.yahoo.com. Notice that this is not www.yahoo.com. This is what the alias line above was referring to. Also listed are the name servers for that host. Notice also that the reverse lookup ip address is indeed reversed.






















  8. Time-to-live