≡ Menu

Linux / Unix: Find Out DNS Server IP Address / Names

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

  • Jalal Hajigholamali October 4, 2012, 12:11 pm

    Hi,

    Thanks a lot

    simple and useful ..

  • Mac October 4, 2012, 2:36 pm

    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

    • iWonder September 30, 2015, 9:27 am

      Just use “grep -i”, case insensitive search
      ie., grep -i -color hostname /etc/sysconfig/network

  • JBruyet October 4, 2012, 7:33 pm

    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

  • Thad E Ginathom October 4, 2012, 7:36 pm

    $ 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

  • Mac October 5, 2012, 3:59 pm

    Thanks Thad I will check that out.

    :)

  • Security: Are you a robot or human?

    Leave a Comment

    You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">