Querying a service from the client side
curl, dig, nc, openssl s_client, ssh and sftp: composing the request, reading the answer, speaking a text protocol by hand and interpreting error messages.
- 28 cards
- 4 topics
- Free
The outline, topic by topic
Each topic is weighted the way the exam weighs it.
- Concepts
- Questions
- Sort and link
- Scenarios
A few cards from the deck
Client-server model: what is it?
Show the answer
An organisation where one program waits for requests on a port and answers them, while another takes the initiative of opening the connection and asking.
Each tool in this deck plays the client: it talks to a service that is already listening. If nothing listens, the failure is immediate (
Connection refused).Which command asks 1.1.1.1 for the mail servers of example.org?
dig @1.1.1.1 example.org MXdig @example.org 1.1.1.1 MXdig 1.1.1.1 example.org SMTPdig -x example.org MX
Show the answer
dig @1.1.1.1 example.org MXThe server queried follows
@, then come the name and the record type: MX gives the mail servers. SMTP is not a record type, and-xis for the reverse lookup of an address.In
curl -voutput, lines starting with … are sent by the client and those starting with … are received from the server.Show the answer
In
curl -voutput, lines starting with > are sent by the client and those starting with < are received from the server.Lines starting with
*are curl's own comments (connection, TLS); they do not travel on the network.curl: what is it?
Show the answer
A command-line tool that sends an HTTP (or HTTPS) request to a URL and prints the server's response.
-Iasks only for the headers,-vshows the request sent and the response,-Lfollows redirects,-o filewrites the body to a file.curl https://api.example.org/answerscurl: (6) Could not resolve host: api.example.org. What is the probable cause?- The server refused the connection on port 443 of its address
- The certificate presented by the server expired yesterday
- The name was not turned into an address: a DNS problem
- The server answered with a 500 error instead of the page
Show the answer
The name was not turned into an address: a DNS problem
The request never left: curl got no address. Check with
dig api.example.org(typo, missing record, resolver down). A refused connection would give(7).