MAC network question - display network routes

I am new to MAC environment.  How do I display/manipulate network routes from a MAC?  Also, how to I display connections and listening ports from a MAC?

Thanks a lot.
Who is Participating?
packetguyConnect With a Mentor Commented:
The following Terminal program shell commands will give you better answers to your specific questions:

To display routes, type:

  netstat -rn

That's "r" and "n" for the options (r means display routes, n means numeric only, which is usually what you want). You'll get two sections, the first for IPv4 routes, which is probably what you want to look at; the second is for IPv6 routes (if IPv6 is enabled, which it is by default).

To add or delete routes, use the "route add" and "route delete" commands. You can read the details on the route command's syntax by typing "man route"; you'll get the "route" command's manual page.

To list listening ports, type:

 netstat -a | grep LISTEN

If you want numeric port numbers displayed instead of names (such as "smtp"), use the -n option:  netstat -an

To display established connections, use:

  netstat -a | grep ESTAB

Again, to display numeric IP addresses for connected hosts, add the -n option.


Drag down the Apple Menu to System Preference and go into the Network Preferences Panel.
Eoin OSullivanConsultantCommented:
To quickly see your network interfaces ... Open a Terminal window and enter     ifconfig

To view ports you can see what applications are using what ports by typing       sudo lsof -i       (and enter your root password)

The netstat command will show you the open connections, just type                netstat

To trim the netstat report to just the ports type     netstat -an | awk '/(LISTEN|ESTABLISHED)$/ {sub(/.*\./, "", $4); print $4}'
Whenever an author awards less than an "A" grade, I like to follow up to see what I might do better next time. I believe I answered all of the questions you posed correctly. And within 12 hours of your posting the question. In what way was my information inadequate so that you only judged it of "B" quality?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.