Explore

Loading

Sunday, February 12, 2012

DNS Tools in linux


Domain Name Service (DNS for short) is that magical protocol that allows your computer to turn meaningless domain names like www.slackware.com into meaningful IP address like 64.57.102.34. Computers can't route packets to www.slackware.com, but they can route packets to that domain name's IP address. This gives us a convenient way to remember machines. Without DNS we'd have to keep a mental database of just what IP address belongs to what computer, and that's assuming the IP address doesn't change. Clearly using names for computers is better, but how do we map names to IP addresses?
host can do this for us. host is used to map names to IP addresses. It is a very quick and simple utility without a lot of functions.
www.slackware.com is an alias for slackware.com.
slackware.com has address 64.57.102.34
But let's say for some reason we want to map an IP address to a domain name; what then?
nslookup is a tried and true program that has weathered the ages. nslookup has been deprecated and may be removed from future releases. There is not even a man page for this program.
% nslookup 64.57.102.34
Note:  nslookup is deprecated and may be removed from future releases.
Consider using the `dig' or `host' programs instead.  Run nslookup with
the `-sil[ent]' option to prevent this message from appearing.
Server:         192.168.1.254
Address:        192.168.1.254#53

Non-authoritative answer:
www.slackware.com       canonical name = slackware.com.
Name:   slackware.com
Address: 64.57.102.34
The meanest dog in the pound, the domain information groper, dig(1) for short, is the go-to program for finding DNS information. dig can grab just about anything from a DNS server including reverse lookups, A, CNAME, MX, SP, and TXT records. dig has many command line options and if you're not familiar with it you should read through it's extensive man page.
% dig @192.168.1.254 www.slackware.com mx

; <<>> DiG 9.2.2 <<>> @192.168.1.254 www.slackware.com mx
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26362
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 2

;; QUESTION SECTION:
;www.slackware.com.             IN      MX

;; ANSWER SECTION:
www.slackware.com.      76634   IN      CNAME   slackware.com.
slackware.com.          86400   IN      MX      1 mail.slackware.com.

;; AUTHORITY SECTION:
slackware.com.          86400   IN      NS      ns1.cwo.com.
slackware.com.          86400   IN      NS      ns2.cwo.com.

;; ADDITIONAL SECTION:
ns1.cwo.com.            163033  IN      A       64.57.100.2
ns2.cwo.com.            163033  IN      A       64.57.100.3

;; Query time: 149 msec
;; SERVER: 192.168.1.254#53(192.168.1.254)
;; WHEN: Sat Nov  6 16:59:31 2004
;; MSG SIZE  rcvd: 159
This should give you an idea how dig works. “@192.168.1.254” specifies the dns server to use. “www.slackware.com” is the domain name I am performing a lookup on, and “mx” is the type of lookup I am performing. The above query tells me that e-mail to www.slackware.com will instead be sent to mail.slackware.com for delivery.
finger(1) will retrieve information about the specified user. You give finger a username or an email address and it will try to contact the necessary server and retrieve the username, office, telephone number, and other pieces of information. Here is an example:
% finger johnc@idsoftware.com
finger can return the username, mail status, phone numbers, and files referred to as “dot plan” and “dot project”. Of course, the information returned varies with each finger server. The one included with Slackware returns the following information by default:
·         Username
·         Room number
·         Home phone number
·         Work phone number
·         Login status
·         Email status
·         Contents of the .plan file in the user's home directory
·         Contents of the .project file in the user's home directory
The first four items can be set with the chfn command. It stores those values in the /etc/passwd file. To change the information in your .plan or .project file, just edit them with your favorite text editor. They must reside in your home directory and must be called .plan and .project.
Many users finger their own account from a remote machine to quickly see if they have new email. Or, you can see a user's plan or current project.
Like many commands, finger has options. Check the man page for more information on what special options you can use.
Someone once stated that telnet was the coolest thing he had ever seen on computers. The ability to remotely log in and do stuff on another computer is what separates Unix and Unix-like operating systems from other operating systems.
telnet allows you to log in to a computer, just as if you were sitting at the terminal. Once your username and password are verified, you are given a shell prompt. From here, you can do anything requiring a text console. Compose email, read newsgroups, move files around, and so on. If you are running X and you telnet to another machine, you can run X programs on the remote computer and display them on yours.
To login to a remote machine, use this syntax:
% telnet <hostname>
If the host responds, you will receive a login prompt. Give it your username and password. That's it. You are now at a shell. To quit your telnet session, use either the exit command or the logout command.
* Telnet does not encrypt the information it sends. Everything is sent in plain text, even passwords. It is not advisable to use telnet over the Internet. Instead, consider the Secure Shell(PKE). It encrypts all traffic and is available for free.
Now that we have convinced you not to use the telnet protocol anymore to log into a remote machine, we'll show you a couple of useful ways to use telnet.
You can also use the telnet command to connect to a host on a certain port.
% telnet <hostname> [port]
This can be quite handy when you quickly need to test a certain service, and you need full control over the commands, and you need to see what exactly is going on. You can interactively test or use an SMTP server, a POP3 server, an HTTP server, etc. this way.
In the next figure you'll see how you can telnet to a HTTP server on port 80, and get some basic information from it.
Electronic mail is one of the most popular things one can do on the Internet. In 1998, it was reported that more electronic mail was sent than regular mail. It is indeed common and useful.
Under Slackware, we provide a standard mail server, and several mail clients. All of the clients discussed below are text-based. A lot of Windows users may be against this, but you will find that a text based client is very convenient, especially when checking mail remotely. Fear not, there are many graphical e-mail clients such as KDE's Kmail. If you wish to use one of those check its help menu.
pine is not elm. Or so the saying goes. The University of Washington created their program for Internet news and email out of a need for an easy mail reader for their students. pine is one of the most popular email clients in use today and is available for nearly every flavor of Unix and even Windows.
elm
elm is another popular text-based email client. Though not quite as user friendly as pine, it's definitely been around a lot longer.
By default, you are placed in your inbox. The messages are listed with the message number, date, sender, and subject. Use the arrow keys to highlight the message you want. Press Enter to read the message.
To compose a new message, type m at the main screen. The d key will flag a message for deletion. And the r key will reply to the current message you are reading. All of these keys are displayed at the bottom of the screen with a prompt.
The man page discusses elm in more detail, so you will probably want to consult that before using elm.
“All mail clients suck. This one just sucks less.” mutt's original interface was based on elm with added features found in other popular mail clients, resulting in a hybrid mutt.
Some of mutt's features include:
·         color support
·         message threading
·         MIME and PGP/MIME support
·         pop3 and imap support
·         support for multiple mailbox formats (mbox, MMDF, MH, maildir)
·         highly customizabl
nail is a command line driven mail client. It is very primitive and offers pretty much nothing in the way of user interfaces. However, mailx is handy for times when you need to quickly mail something, scripting a bulk mailer, testing your MTA installation or something similar. Note that Slackware creates symbolic links to nail at /usr/bin/mail and /usr/bin/mailx. Any of these three commands executes the same program. In fact, you will most likely see nail referred to as mail.
The basic command line is:
% mailx <subject> <to-addr>
mailx reads the message body from standard input. So you can cat a file into this command to mail it, or you can just type text and hit Ctrl+D when finished with the message.

No comments:

Post a Comment