The idea
A laptop nobody set up, the home router (its way out and its DNS server) and a web server on another network. You bring the laptop online by hand, one piece at a time: Linux networking from zero.
Steps
-
A machine nobody set up
A working laptop has an address, a way out and a resolver; this one has none. Before fixing anything, see what is missing: look at its card (its network card), then ask the router "are you there?" with
ping.laptop:~# ip addr show eth0 laptop:~# ping -c1 -W1 10.0.1.2
-
Switch the card on
First piece: turn the card on, because a card that is off sends nothing, whatever else is set. Then look at it again and try the router once more.
laptop:~# ip link set eth0 up laptop:~# ip link show eth0 laptop:~# ping -c1 -W1 10.0.1.2
-
An address, and the network it opens
Second piece: give the card the address
10.0.1.10on a network of size/24. The address says who the laptop is, and the size says which addresses are its neighbours. Then read the routing table, and ping the router again.laptop:~# ip addr add 10.0.1.10/24 dev eth0 laptop:~# ip route laptop:~# ping -c1 -W1 10.0.1.2
-
The way out: a default route
The web server,
10.0.2.10, is on another network, and the laptop reaches only its neighbours directly. Third piece: a default route, which hands everything else to the router,10.0.1.2.laptop:~# ip route add default via 10.0.1.2 laptop:~# ip route laptop:~# ping -c1 -W1 10.0.2.10
-
Names: a DNS server in resolv.conf
People use names, and a program needs to know whom to ask for the address behind one. Fetch the page by name. Then write the fourth piece,
/etc/resolv.conf, which names that server, and fetch it again.laptop:~# curl -sS -m 5 http://webServer.lab/ laptop:~# curl -sS -m 5 http://webServer.lab/
-
A reboot forgets it all
The laptop is online, but every
ipcommand changed only the running system. Restart it, and look at its card and its routes again.laptop:~# ip addr show eth0 laptop:~# ip route
-
Make it stick: /etc/network/interfaces
Settings that survive a restart, the saved network configuration, live in a file read at boot. Write the four pieces into
/etc/network/interfaces, restart the laptop, then prove it came back online by itself.laptop:~# ip route laptop:~# curl -sS -m 5 http://webServer.lab/