Nslookup is a command-line tool available for querying the Domain Name System (DNS) to obtain domain name or IP address mapping or for any other specific DNS record. Nslookup is available natively in Windows, Linux, Unix, macOS and most operating systems. To list all records of a domain name, run one of the following commands. May 28, 2020 To search for other type of DNS records, use -type= flag (e.g. Nslookup works also for just hostname, where it will automatically use parent or connection-specific DNS suffixes configured in the operating system when searching to obtain FQDN (fully qualified domain name), which is very useful in LAN environment. Nslookup is a command-line tool available for querying the Domain Name System (DNS) to obtain domain name or IP address mapping or for any other specific DNS record. Nslookup is available natively in Windows, Linux, Unix, macOS and most operating systems. To list all records of a domain name, run one of the following commands.
Some additional info...
Even if I run this..
sudo dscacheutil -cachedump -entries host
I don't get the output I;m looking for, I see no entries at all. This is even after going to a website in a browser and doing a host lookup on command line, you would expect something to be cahced.
DirectoryService Cache Overview:
AAAA Queries - Disabled (link-local IPv6 addresses)
Cache Size - 27
Entry count by category:
Group - 22
Service - 1
User - 4
Cache entries (ordered as stored in the cache):
Category Best Before Last Access Hits Refs TTL Neg DS Node
---------- ------------------ ------------------ -------- ------ -------- ----- ---------
Sep 29, 2011 8:22 PM
Click here to return to the 'Configure DNS lookups from the terminal' hint |
I believe if you have flat files configured as an option in directory access, that /etc/resolv.conf should work fine (it does for me). You just need to do a sudo killall -1 lookupd when you make changes, to force lookupd to reread the files.
We tried this, it didn't work.
The FFAgent for lookupd reads a whole bunch of files (listed in the lookupd man page) but not /etc/resolv.conf.
D.
Be aware that scutil/scselect only function for the current boot of the machine - on reboot, the information that configd uses (in /Library/Preferences/SystemConfiguration/preferences.plist) is re-read; any and all changes made with scutil will be lost (if you read the man pages, you'll note that it refers to the 'dynamic store' that configd uses. The dynamic store gets reinitialized whenever configd restarts - whether by reboot, 'kill -HUP `cat /var/run/configd.pid`' or something else.)
If you're looking for something to make *permanent* changes to network settings, you'll want the ncutil framework [Google is your friend.]
I use Tunnelblick/openvpn to connect to HotSpotVPN from my mac; however, I can't get the new DNS settings to take. I see the /etc/resolv.conf file change to reflect the new DNS settings, but Safari and Mail.app still use my original settings. Even upon issuing a ' kill -HUP `cat /var/run/lookupd.pid`' or 'lookupd -flushcache', the original DNS settings are used. DNS lookups using host and ping work fine, however. I'm using 10.4.1. Any ideas to get Safari and Mail.app to use the DNS settings issued once connected to the VPN?
You need to incorporate the methods mentioned in the hint into script files that are run by openvpn. I don't know anything about the particular VPN server you mentioned, but as of a few weeks ago there was no working script available from openvpn.net to correctly take the DNS configuration from openvpn and apply it to configd.
We intend to submit our scripts to the openvpn.net site once our testing period is over.
D.
/etc/resolv.conf is not the primary source for OS X and later; take a look at scutil --dns to see the current resolver configuration. It is possible to get the DNS stuff to override for the duration of an OpenVPN tunnel; I wrote a script that uses it (Python using the SystemConfiguration framework wrapper) and can send it to anyone who's interested...
Update:
Another (better?) way to reset the lookup configuration for an interface is to use ipconfig (but you need sudo).
ipconfig <interface> DOWN
then
ipconfig <interface> DHCP
will force a re-read of DHCP configuration over the network.
D.
ifconfig set (interface) NONE
and
ifconfig set (interface) DHCP
where (interface) is something like en0, en1, etc.
D.
Shouldn't you be using:
State:/Network/Global/DNS
instead of:
State:/Network/Service/PRIMARY_SERVICE_ID/DNS
If you've defined any DNS servers in the Network system preferences, they won't be listed in the dictionary returned by the primary interface. Also, the information in the global DNS record is an exact match for the contents of resolv.conf
-ch
I'm not sure. This didn't work for us, any changes made to .../Global/DNS wouldn't be reflected in resolv.conf.
D.
Here my little Shell Script to Set the DNS.
See the Power of the Shell:
Filename: setdsn
-------------------------------------------------
#!/bin/bash
# Script is used to set the Nameserver Lookup under Max OS X 10.4 with the Console
# Script by Stephan Oeste <stephan@oeste.de>
if [ $# -lt 2 ] ; then
echo 'Use: $0 <domain> <1.Nameserver> [2.Nameserver]'
echo 'Example Use: $0 example.tld 1.2.3.4 1.2.3.5'
exit 1
fi
PSID=$( (scutil | grep PrimaryService | sed -e 's/.*PrimaryService : //')<< EOF
open
get State:/Network/Global/IPv4
d.show
quit
EOF
)
scutil << EOF
open
d.init
d.add ServerAddresses * $2 $3
d.add DomainName $1
set State:/Network/Service/$PSID/DNS
quit
EOF
-------------------------------------------------
Create the file
chmod +x setdns
And then use ist with (Example): setdns domain.com 12.23.34.45
CU Emzy
Cool, Emzy.
You may be interested, I contributed some scripts to openvpn.org for automatically dsitributing the nameserver configuration over the openvpn tunnel. You won't have to set the resolver configuration manually in that case. But your script should be great for fixing a stuffed config...
D.