*BSDThis forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: RedHat, Slackware, Experimenting with FreeBSD
Posts: 222
Rep:
Netstat -ntulp for FreeBSD
Just a quick question. Is there an equivalent command in FreeBSD for the linux command netstat -ntulp
I want to view which TCP and UDP ports are open on my system.
One might assume that with over 2000 posts I either already knew to check man pages OR had at least been admonished to do some in one of those earlier threads.
In point of fact I had checked the man page. The OP didn't give his version of FreeBSD and on the 4.9 system I looked at it didn't have the options he was using.
The fact that I specifically mentioned "-p" would have been a clue that it didn't work the way it does on Linux though I'll admit I missed the fact that it is there and means "protocol" rather than "program" as it does on Linux. My comments about lsof were to address the lack of a "program" option.
On that FBSD 4.9 system running your command gave:
netstat -a -f inet -p tcp,udp
netstat: tcp,udp: unknown or uninstrumented protocol
Running your line with only tcp or only udp after -p gives only one of the two protocols the OP was looking for whereas the the egrep finds both.
You know what? This is not about you. I tried chipping in, god forbid I offend a Senior Member (WAW) in the process. And I wasn't telling *YOU* to check the manual page.
My assumption, perhaps, flawed is that before "chipping in" you would have read all the posts in the thread.
Anyway - sorry for the tone of my post - yours just hit me wrong. As indicated in my reply I did have to re-examine one thing I wrote based on what you wrote.
No problems. I just remember when I was using FBSD I was doing something similar to your solution because I was too lazy to read the `netstat` manual page (I'm not implying *you* are lazy, as your method is "portable" across various releases). I do not currently have access to a BSD system so I had to search for an online FBSD man page repository to refresh my memory about the flags. I wasn't sure how to print *both* tcp and udp, the "-p tcp,udp" mode was an assumption. Surely "-p tcp" works and "-p udp" works but how you'd get both was what I had trouble with. So there were two reasons I was suggesting the OP to check the netstat man page: one, it's always good to read these documents, 2nd: he/she'd be able to "correct" my reply in case it was erroneous.
Just a quick question. Is there an equivalent command in FreeBSD for the linux command netstat -ntulp
I want to view which TCP and UDP ports are open on my system.
Yes. Another easy way to get this information is with sockstat.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.