Linux and Unix-like system uses Internet address (in dot notation) of a name server that the resolver should query to convert host names to IP address and vice versa. The resolver reads a configuration file called /etc/resolv.conf. The name server IP address are stored in /etc/resolv.conf file. Up to three name servers may be listed per line using the following syntax:[donotprint]
Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | No |
Requirements | None |
Time | N/A |
nameserver ISP-DNS-IP1
nameserver DNS-IP2
nameserver DNS-IP3
How do I see my DNS server IP address?
Type the following cat command:
cat /etc/resolv.conf
Or use grep command as follows:
grep nameserver /etc/resolv.conf
Sample outputs:
How do I change or update my DNS nameservers IP address?
Use a text editor such as vi, ee, emacs, joe and co to edit the file /etc/resolv.conf as root user:
$ sudo vi /etc/resolv.conf
DNS lookup on a Linux and Unix systems
Now, you know your DNS name server IP address. It is time to use command such as host command and dig command to find out more information about domains or IP address.
dig command examples
Type the following command to resolve domain name called cyberciti.biz
dig cyberciti.biz
Sample outputs:
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6_6.1 <<>> cyberciti.biz ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9933 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;cyberciti.biz. IN A ;; ANSWER SECTION: cyberciti.biz. 300 IN A 75.126.153.206 ;; Query time: 47 msec ;; SERVER: 10.0.80.11#53(10.0.80.11) ;; WHEN: Mon Jan 12 11:00:20 2015 ;; MSG SIZE rcvd: 47
To see just IP address, type:
dig +short cyberciti.biz
Sample outputs:
75.126.153.206
To see an IPv6 address for www.cyberciti.biz, enter:
dig aaaa www.cyberciti.biz dig +short aaaa www.cyberciti.biz
Sample outputs:
2607:f0d0:1002:51::4
A few more examples using the dig command:
# list authoritative dns server ## dig ns cyberciti.biz ## show mx (mail server) info/ip for cyberciti.biz domain## dig mx cyberciti.biz ## Reverse lookups — mapping addresses to dns names # dig -x ip dig -x 75.126.153.206
host command examples
The syntax is:
## Get an IPv4 address for cyberciti.biz ## host cyberciti.biz ## Get mail server info for cyberciti.biz ## host -t mx cyberciti.biz ## Get nameserver info for cyberciti.biz ## host -t ns cyberciti.biz ## Get an IPv6 address ## host -t aaaa cyberciti.biz ## Use specific (Google) dns server ip # 8.8.8.8 to query www.cyberciti.biz ## host www.cyberciti.biz 8.8.8.8 ## Get all info about cyberciti.biz ## host -a -v cyberciti.biz
Sample outputs:
🐧 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |