Menu
Coddy logo textTech

Looking Up a Name

Lesson 7 of 47 in Coddy's Networking with the Terminal course.

When the answer is not in your hosts file, DNS is asked. You can make that lookup by hand:

nslookup example.com

The output has two halves. First the server that answered, which is whichever resolver your machine is configured to use, so it differs from network to network. Then the answer: the address or addresses that name maps to.

You will usually see the answer labelled non-authoritative. That is not a warning. It means the answer came from a cache along the way rather than from the domain's own nameserver, which is normal and is what makes DNS fast.

The useful habit is what this tells you when it fails. If the lookup returns nothing, stop looking at firewalls and ports: nothing has been dialled yet. The name itself is the problem.

challenge icon

Challenge

Medium

Watch a lookup fail, on purpose.

The .invalid ending is reserved: it is guaranteed never to exist, which makes it perfect for testing what a failed lookup looks like.

Try to look up nope.invalid and print resolved if it works or failed if it does not. Expected output:

failed

Send the normal output out of the way with >/dev/null 2>&1 so only your own word is printed.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Networking with the Terminal

Practice on your own: Terminal playground