Filtering Netcat results in a Bash script

I am trying to write a script that connects to a list of IPs on port 53 - and I want the result to return only open ports. Here is the script I am running below - I have tried grepping and cutting the output but im not sure I am doing this correctly - I cant seem to pipe the script results to a text file either.


for ip in $(seq 200 254); do
    nc -v 192.168.11.$ip 53 &

I apologise for its simplicity I am new - and if the solution is elsewhere


Check for the command's exit code, it should be zero for a successful connection. Also use the -z option to drop the connection once it has been established.


for ip in $(seq 200 254); do
    nc -z 192.168.11.$ip 53
    if [ $? -eq 0 ]; then
        echo "Hit: 192.168.11.$ip"

If you were using nmap instead of netcat, you could have used this:

nmap -p 53

PS. If you're trying to determine which hosts run DNS server, you should scan for open 53/udp, not 53/tcp (option -u in netcat)

Need Your Help

Capturing real time images from a network camera

c++ camera video-streaming video-capture mjpeg

What is the best way to capture streamed MJPEG from a network IP camera?

Use just Controller name as route

I would like to access my NewsList route by that URL: