Any unix commands to view network status & activity using the terminal?

I don't use the terminal much and was wondering if there are any unix network commands that let you view packet contents, connection status and other network information. I'm not interested in making any changes, I just want to use the terminal to get network and related information.

Thanks in advance to anybody who answers.

- Mark

G4/450MHz Sawtooth Mac OS X (10.4.7)

Posted on Oct 6, 2006 1:32 PM

Reply
6 replies

Oct 6, 2006 2:03 PM in response to Mark T1

I am certainly not an expert but these are the commands I use:

this one will give information about the general setup of the connection to internet:
ifconfig -a

to view the incoming packets: (use en0 for wired ethernet, en1 is airport)
(use -nivvv for more verbose content)
tcpdump -ni en1
This command will return the output to stdout --- to interpret this you need to know something about how packets are constructed. Use ctrl–C to stop.

more obscure, apple specific i think, and only directly available if you have mac os x server (although I learnt on these pages how to find it on standard mac os x) is
networksetup
can be used to change the network settings or to view the current settings.

Oct 6, 2006 6:11 PM in response to Mark T1

Hi Mark,
There are tons of commands; it would help to know what you want to know. You can monitor the status of all ports with:

sudo lsof +Mi

That will display all network connections and all listening daemons. A command that is similar to that is:

netstat -a -f inet

Of course netstat specializes in network information and there are lots of different stats it will display.

If you run a firewall, it keeps stats on rule matches. You can see them with:

sudo ipfw -atdN list

As has already been mentioned, Mac OS X comes with tcpdump but there's only one great packet sniffer: Ethereal. It doesn't come with OS X but if you have X11, it can be installed with a packet manager like Fink.

Finally, many running services keep their own stats or logs. You would have to read up on the ones you're running to see what information they provide.
--
Gary
~~~~
A diplomat is man who always remembers a woman's
birthday but never her age.
-- Robert Frost

Oct 7, 2006 4:24 PM in response to Gary Kerbaugh

Gary, I just want to play around with the terminal to see what it can do as far as getting network information and for monitering traffic. You and MacPeter have given me some good comands to start with and that is what I'm looking for.

One command that I was hoping to get was something that may tell me the reason why my internet connection is not working when it goes out. It occasionally stops working for no reason, other times it may work for a week with out any issues.

- Mark

Oct 8, 2006 7:25 AM in response to Mark T1

Hi Mark,
It would be hard enough to diagnose your ISP's problem if your machine is connected. I can't imagine how you could determine anything if you're not connected. However, I suppose you could be physically connected but packets are getting lost in their network. If that happened you might be able to tell by running traceroute. My guess is that the most useful targets would be your gateway, your ISP's nameservers and their DHCP server. If you can connect with those, try something outside of their network. You can discover the IP addresses of the nameservers with the command, "cat /etc/resolv.conf". If you can ping the nameservers, you should lookup a few domain names with nslookup. A failure of their nameservers would appear somewhat like being disconnected.
--
Gary
~~~~
Law of the Jungle:
He who hesitates is lunch.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Any unix commands to view network status & activity using the terminal?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.