How do I find out my DNS server IP address assiged my my ISP under Unix or Linux operating system using command prompt? How do I find preferred dns server under Debian / Ubuntu / Fedora Linux desktop system?
Under Unix or Linux operating systems the resolver is used (set of routines in the C library) that provide access to the Internet Domain Name System (DNS). The resolver configuration file is located at /etc/resolv.conf location and it contains information that is read by the resolver routines the first time they are invoked by a process. Use the cat command or grep command to find out your dns server addresses as follows:
cat /etc/resolv.conf
Sample outputs:
# Generated by NetworkManager nameserver 192.168.1.2 nameserver 192.168.1.3
In this example my dns server address are 192.168.1.2 and 192.168.1.3 in dot notation that the resolver should query. Currently name servers may be listed, one per keyword. If there are multiple servers, the resolver library queries them in the order listed. If no nameserver entries are present, the default is to use the name server on the local machine. The grep command can be used as follows:
$ grep --color nameserver /etc/resolv.conf
Sample outputs:
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












![Linux / Unix: Show Shares on NFS Server [ Shared Directories ]](http://s13.cyberciti.org/images/shared/rp/3/12.jpg)


{ 6 comments… read them below or add one }
For the cynical, who might think, “That is what the configuration file is telling the system to do, how can I be sure what it *is* doing, you can find out how your system resolves any given name using dig
$ dig http://www.ibm.com
; <> DiG 9.8.1-P1 <> http://www.ibm.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46538
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.ibm.com. IN A
;; ANSWER SECTION:
http://www.ibm.com. 981 IN CNAME http://www.ibm.com.cs186.net.
http://www.ibm.com.cs186.net. 60 IN A 129.42.60.216
;; Query time: 870 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Thu Oct 4 01:26:31 2012
;; MSG SIZE rcvd: 80
Hi,
Thanks a lot
simple and useful ..
Can someone help to explain to how use the color option but without using the case sensitive requirement like for example:
grep –color hostname /etc/sysconfig/network
no data output
grep –color HOSTNAME /etc/sysconfig/network
HOSTNAME=acct2.acme.com
is there a way in grep to get it to display regardless of case sensitive?
any help/advice would be great
man grep
that will give you -i, –ignore-case
Ignore case distinctions in both the PATTERN and the input files. (-i is specified by POSIX.)
man pages are your friend.
Thanks,
Joe B
$ man grep
… … ..
-i, –ignore-case
Ignore case distinctions in both the PATTERN and the input
files. (-i is specified by POSIX.)
… … …
$
Is that what you wanted?
$ grep -i PEAFOWL hosts
127.0.0.1 peafowl
$ grep -i peafowl hosts
127.0.0.1 peafowl
Thanks Thad I will check that out.
:)