>_ IzzyLab

Hands-on task

This task is step 6 of the course “Networking and HTTP from the terminal”

Which ports in the range are open

medium~7 min

Check the port range 8710–8715 on 127.0.0.1 and write the numbers of the ports where something accepts connections, one per line in ascending order, to /root/open.txt. There are no external scanners on the system — make do with the shell.

What you'll practise:
  • /dev/tcp
  • bash
  • port checking
  • seq
  • exit codes

Topic breakdown

/dev/tcp/host/port is not a file in the file system but a special construct of bash itself: redirecting to such a path opens a TCP connection, and the result shows in the exit code. This gives a primitive port availability check without nc, nmap and other utilities that minimal images usually lack. The limitations are worth knowing too: it works only in bash (not in dash/sh), it checks nothing but TCP connection establishment, and without a timeout it can hang for a long time on a filtered port — in scripts such a check is wrapped in timeout.

What's checked

  1. exactly the open ports were found, in ascending order

What it looks like