task 8.1 · chapter 8 of 8: the network from the command line · 20 min
Where does it go?
objective
Log in to ws1 and work out how it reaches srv1: its addresses and management interface, its gateway, the DNS server it asks and what it answers, the route for one address with ip route get, and the hops with traceroute.
answers/8.1.ymlopen a file in VS Code: Ctrl+P (Cmd+P on a Mac), type its name, Enter
| Lesson | The network from the command line |
|---|---|
| Log in | ssh ws1 (from task 6.2). After a make reset, ssh-copy-id ws1 again |
| Your answers | answers/8.1.yml, in the codespace (exit to get back) |
new to this? step by stepbeginner
ssh ws1, thenip -br addrandip route: the management interface and the gateway.cat /etc/resolv.confanddig srv1.lab(anddig +short srv1.lab).- Challenge:
ip route get 192.168.20.10andtraceroute -n srv1. exit, fill in answers/8.1.yml, thenmake check T=8.1.
more in meet the lab
From the Networking 101 lab, one level down
What you already know
The Networking 101 lab had you read ip addr, ip route, ping, traceroute and
dig on its hosts. Here the same commands come with the options engineers type day to day, on a machine with two
networks, which is the usual case for servers.
| Command | Answers |
|---|---|
ip -br addr | every interface and its address, one line each (-br is brief) |
ip route | the routing table: where each network goes, and the default |
ip route get ADDRESS | which route this one address would use: the gateway, the interface, and the source address |
dig NAME | the full DNS answer: the question, the answer, the TTL, which server replied |
dig +short NAME | just the address |
traceroute -n HOST | each router on the way, as numbers (-n: don’t look up names, it’s faster) |
Two networks, one default
ws1 has two interfaces. eth0 is on the lab’s management network, the one your codespace uses to reach it;
it has a route for that one network only. eth1 goes to r1, and the default route, for everything else,
points at r1. ip route get shows that choice being made for one address, which is the quickest way to answer
why is this traffic going that way?
in one sentence ip route get answers “which way does this one address go?”; dig answers “what does DNS say?”.
ws1’s view
netops@ws1:~$ ip -br addr
lo UNKNOWN 127.0.0.1/8
tunl0@NONE DOWN
...
eth0@if23 UP 172.80.102.11/24
eth1@if28 UP 192.168.10.10/24
netops@ws1:~$ ip route
default via 192.168.10.1 dev eth1
172.80.102.0/24 dev eth0 proto kernel scope link src 172.80.102.11
192.168.10.0/24 dev eth1 proto kernel scope link src 192.168.10.10
The tunl0, gre0 and other DOWN entries are spare tunnel interfaces that come from the computer the lab runs
inside. They have no address and nothing uses them. The numbers after @if will differ in yours.
Addresses, routes, names
Log in, and list the interfaces and the routes:
run in the terminalssh ws1 ip -br addr ip routeThe interface on
172.80.102.0/24goes inmgmt_interface, and the address afterdefault viaingateway.Which DNS server does ws1 ask?
run in the terminalcat /etc/resolv.confThe
nameserverline isdns_server.search labmeans a short name likesrv1is tried assrv1.lab.Ask it, the long way and the short way:
run in the terminaldig srv1.lab dig +short srv1.labIn the full answer, find the ANSWER SECTION, and at the bottom the SERVER line: who replied. The address goes in
srv1_address.exit, and fill in the four follow-along lines in answers/8.1.yml.
in one sentence resolv.conf names the DNS server; dig shows its whole answer, and +short just the address.
The path to srv1
From ws1:
- Which interface does ws1 send srv1’s packets out of,
192.168.20.10? Ask for that one address, not the whole table. Write it inroute_dev. - How many hops does
traceroute -ncount from ws1 to srv1? Write it inhops_to_srv1.
Then exit and make check T=8.1.
hint
ip route get 192.168.20.10. The word after dev is the interface.
hint
Each numbered line of traceroute’s output is one hop, and the last is srv1 itself. If you see * * *, wait a few
seconds and run it again: Linux limits how fast it sends the ICMP replies traceroute depends on.
show the solution
netops@ws1:~$ ip route get 192.168.20.10
192.168.20.10 via 192.168.10.1 dev eth1 src 192.168.10.10 uid 1000
cache
netops@ws1:~$ traceroute -n srv1
traceroute to srv1 (192.168.20.10), 30 hops max, 60 byte packets
1 192.168.10.1 0.055 ms 9.405 ms 0.034 ms
2 192.168.20.10 0.126 ms 3.454 ms 0.149 ms
hops_to_srv1: 2
route_dev: eth1
No route says 192.168.20.0/24, so ws1 uses its default: via r1 (192.168.10.1), out of eth1, from its own
192.168.10.10. Two hops: r1, then srv1.
5 check: run it, then prove it
$ make check T=8.1when it's right, you'll see
╭─ task 8.1 · where does it go?
│ ✓ ws1's default gateway (follow along): 192.168.10.1
│ ✓ the interface on the management network (follow along): eth0
│ ✓ srv1's address, from dig (follow along): 192.168.20.10
│ ✓ ws1's DNS server (follow along): 192.168.20.10
│ ✓ how many hops traceroute counts to srv1 (challenge): ...
│ ✓ the interface ws1 sends srv1's packets out of (challenge): ...
╰─ 6/6 checks passed verified