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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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}'
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.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Mac OS X

From novice to tech pro — start learning today.