Skip to content

Instantly share code, notes, and snippets.

@dginhoux
Last active November 5, 2022 15:22
Show Gist options
  • Save dginhoux/49c906357c0eed8532d2058a48cb0cc6 to your computer and use it in GitHub Desktop.
Save dginhoux/49c906357c0eed8532d2058a48cb0cc6 to your computer and use it in GitHub Desktop.
## tcp one port
ip=192.168.175.140 ; port=80 ; timeout 1 bash -c "</dev/tcp/$ip/$port && echo $ip port tcp/$port open || echo $ip port tcp/$port closed" 2>/dev/null || echo $ip port tcp/$port connection timeout 2>/dev/null
## udp range port
ip=192.168.175.140 ; for port in $(seq 1 65535); do timeout 1 bash -c "</dev/tcp/$ip/$port && echo $ip port tcp/$port open || echo $ip port tcp/$port closed" 2>/dev/null || echo $ip port tcp/$port connection timeout 2>/dev/null; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment