DEV Community

Cover image for Port scanning with Netcat
Adam K Dean
Adam K Dean

Posted on

1

Port scanning with Netcat

Netcat, or nc, is an excellent tool for linux. One thing it's great for is port scanning.

Let us say we want to scan for open ports from 1 to 1000, we can do that like so:

nc -n -z -w 1 192.168.1.2 1-1000
Enter fullscreen mode Exit fullscreen mode

-n prevents DNS lookup. -z will prevent Netcat from receiving any data. -w 1 sets the timeout to 1 second.

You can also use -v to make it verbose, but this will obscure the visibility of successful attempts, which running it without shows.

An example output for the above command is:

Connection to 192.168.1.2 80 port [tcp/] succeeded!

Connection to 192.168.1.2 427 port [tcp/
] succeeded!

Connection to 192.168.1.2 515 port [tcp/*] succeeded!

So useful!

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay