Labs / First Contact / IP addressing & subnets

Lab 2 of 4 ยท IP addressing & subnets

A bare machine: networking by hand

Linux networking by hand: bring a bare machine online, then make it survive a reboot.

Start this lab, free Free 7 steps

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

  1. 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
  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
  3. An address, and the network it opens

    Second piece: give the card the address 10.0.1.10 on 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
  4. 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
  5. 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/
  6. A reboot forgets it all

    The laptop is online, but every ip command changed only the running system. Restart it, and look at its card and its routes again.

    laptop:~# ip addr show eth0
    laptop:~# ip route
  7. 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/

Run these steps on real machines

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Start this lab, free