An address gets you to a machine. On that machine, many programs wait for connections, each on its own port: a number from 1 to 65535. A connection always goes to an address and a port.
| Port | Who usually listens there |
|---|---|
| 22 | ssh, for logging in |
| 80 | a web server (HTTP) |
| 443 | a web server, encrypted (HTTPS) |
| 5432 | PostgreSQL, a database |
New command
nc -zv
Opens a connection to one port and closes it straight away. -z sends nothing, -v says what happened.
Usagenc -zv machine port
text
learner@ops:~$ nc -zv web 80
Connection to web (10.0.0.10) 80 port [tcp/http] succeeded! ← a program answered
learner@ops:~$ nc -zv db 80
nc: connect to db (10.0.0.20) port 80 (tcp) failed: Connection refusedRefused means the machine is there and answered: no program takes connections on that port. Look at the program.
Objectives
- Which of web's ports is refused?
- Is db's database taking connections from ops?