Working with DNS in Unix/Linux

In this thread, I will add useful material when working with DNS-AMI under some Unix/Linux OS. Perhaps at the beginning of this article is not complete. But over time, as will the need, the desire and the time — the article will expand.

To check DNS in Unix/Linux

Sometimes the system utilities are not the same in all Unix/Linux OS. And all the things that you know may not work on another OS. I have so happened.

To check DNS in Linux

Linux has nmcli utility that can show your DNS:

$ nmcli dev show | grep 'IP4.DNS'

In CentOS this utility you need to install, like so:

$ yum install NetworkManager -y

Start the service:

$ service NetworkManager start

Or (CentOS 7)

$ systemctl start NetworkManager.service

Check DNS on Mac OS X

In Mac OS X has a built-in utility called scutil which can show DNS-s in the system.


$ scutil --dns | grep 'nameserver[[0-9]*]'

The output will be priverno this:

nameserver[0] :
nameserver[1] :
nameserver[0] :
nameserver[1] :

To change DNS in Unix/Linux

Sometimes you need to change DNS to some other, this will show you how to do it.

To change DNS in Mac OS X

To start looking at what interfaces are:

$ networksetup -listallnetworkservices

For example, for Wi-Fi you can run the following command:

$ networksetup -setdnsservers Wi-Fi

To remove all DNS servers running, you can run:

$ networksetup -setdnsservers Wi-Fi

Something like that. And this from the article “to Check DNS in Unix/Linux” is completed.


(Visited 32 times, 1 visits today)