Learn how to a build a cloud-first strategyRegister Now


MAC network question - display network routes

Posted on 2008-11-12
Medium Priority
Last Modified: 2013-11-11
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.
Question by:nav2567
  • 2
LVL 53

Expert Comment

ID: 22946690
Drag down the Apple Menu to System Preference and go into the Network Preferences Panel.
LVL 41

Expert Comment

by:Eoin OSullivan
ID: 22947823
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}'
LVL 11

Accepted Solution

packetguy earned 750 total points
ID: 22948214
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.


LVL 11

Expert Comment

ID: 23257396
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?

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question