View Full Version : DNS Manipulation and other TCP/IP Bits
tothomas
09-18-2004, 05:42 PM
Folks, recently I was doing some network troubleshooting and what I thought was an issue with my PIX Firewall turned out to be the fact that my DNS cache on my MAC needed to be flushed. I learned this by checking the issue in question on a windows machine and I have not heard the end of it by those who have yet to see the light. Thus I am looking for the equivalent commands to learn the following in terminal.
1. What is my ip address per interface
2. What is the DHCP server I am using
3. What are the DNS servers I am using
4. What is my default gateway
Yes I know some is available via the Network Preferences but it takes awhile to get there and if you use dhcp you cannot see many things there.
The above information is found in windows via the dos command "ipconfig /all" so that is the equivalent I am looking for.
Also the part that bit me is not knowing how to clear the DNS Cache on my mac so if anyone knows how to do that it would be appreciated. Thank you.
slacker
09-18-2004, 07:49 PM
ifconfig is the command you are looking for.
stetner
09-18-2004, 08:17 PM
You can get info for 1 from 'ifconfig -a'
I am not sure where you can get info for 2 from.
You can get info for 3 from 'cat /etc/resolv.conf'
You can get info for 4 from 'netstat -r'
atomictuesday
09-19-2004, 03:14 PM
*hint hint*
On a default consumer router, the router is both the gateway and the dhcp server.
Tony
stetner
09-20-2004, 05:53 AM
On a default consumer router, the router is both the gateway and the dhcp server.
TonyUsually, but if you are going to make that assumption, why bother asking the question?
I assume only that the original poster wanted definitive information.
1. What is my ip address per interface
2. What is the DHCP server I am using
Are those two not listed nicely in the prefPane?
For 1 you can do: ifconfig -a | grep "inet " | cut -d" " -f2
which will list the loopback interface first.
3. What are the DNS servers I am using
On the command line use: dig test.com | grep ";; SERVER"
4. What is my default gateway
On the command line use: route -n get default | grep gatewa
tothomas
09-20-2004, 07:20 AM
Stetner usually yes the DG is the DHCP server when using home networking however in a corporate environment that is usually quite never the case.
Mule thanks for the detailed terminal commands, the goal is to now write an AppleScript that will give me this easily.
Anyone out there know how to get the DHCP server?
Thanks
Tom
hayne
09-20-2004, 08:14 AM
The above information is found in windows via the dos command "ipconfig /all" so that is the equivalent I am looking for
Try 'ipconfig packet en0'
(assuming your interface is en0 as is usual for Ethernet)
Individual pieces of info can be obtained via 'ipconfig getoption'
E.g. I believe the following command tells you the DHCP server:
ipconfig getoption en0 server_identifier
Also the part that bit me is not knowing how to clear the DNS Cache on my mac
I think this is done via 'lookupd -flushcache'
See 'man lookupd'
hayne
10-04-2004, 03:50 PM
Try 'ipconfig packet en0'
(assuming your interface is en0 as is usual for Ethernet)
That should have been: 'ipconfig getpacket en0'
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.