MAC network question - display network routes

Posted on 2008-11-12
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
    LVL 53

    Expert Comment

    Drag down the Apple Menu to System Preference and go into the Network Preferences Panel.
    LVL 39

    Expert Comment

    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

    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

    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

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    If you are using Mac OS X and have a large number of login items set up in accounts, under system preferences, you may find that your computer is sluggish and unresponsive during startup until everything is done launching. Another problem that a…
    Connectivity using SMB Symptoms When connecting to Windows Server shares from a Mac you receive an error similar to "Connection failed because the original item could not be found"Authentication persistently fails to a Windows Server from a Mac wi…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now