Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Linux Network Setup: A Practical Step-by-Step Guide

· 6 min read · Home Networking

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Setting up networking on Linux boils down to three things: identifying your network interface, assigning an IP address (usually automatically via DHCP), and confirming you can reach the internet. On most desktop distributions networking works out of the box through NetworkManager; on servers and headless systems you configure it with a text file or command-line tool. This guide covers the commands and files you actually need, using standard tools that exist on virtually every distribution. Exact tool names vary by distribution: Debian and Ubuntu servers typically use Netplan or systemd-networkd, Fedora and RHEL use NetworkManager, and Arch gives you a choice, so pick the section that matches your system.

What You'll Need

  • A Linux machine with a wired or wireless network interface
  • Access to a terminal and sudo (administrator) privileges
  • Your network details if you want a static IP: IP address, subnet mask or prefix, gateway, and DNS servers (for DHCP you need nothing)
  • For Wi-Fi: the network name (SSID) and password

Step-by-Step

  1. Identify your network interfaces. Open a terminal and run ip link show or ip a. You'll see at least the loopback interface (lo) and one entry per physical or virtual adapter, with names like eth0, enp3s0 (wired) or wlan0, wlp2s0 (wireless). Note the exact name of the interface you want to configure.
  2. Check whether you already have a connection. Run ip a again and look for an inet line under your interface. If one exists, try ping -c 3 8.8.8.8 (internet by IP) and ping -c 3 google.com (internet by name). If both succeed, your network is already working and you only need to read on if you want a static IP or Wi-Fi setup.
  3. Bring the interface up if it is down. If the interface shows state DOWN, run sudo ip link set up (replace <interface> with your real name, e.g. enp3s0). If there is no carrier (no cable plugged in), it will stay down; check the cable and switch.
  4. Get an IP address automatically (DHCP). On systems with NetworkManager (most desktops), run nmcli device connect for wired, or nmcli device wifi connect "SSID_NAME" password "yourpassword" for Wi-Fi. On systems without NetworkManager, install or use dhcpcd or run sudo dhclient . Then repeat the ping test from step 2.
  5. Set up a static IP on NetworkManager systems. Run nmcli connection show to find your connection name, then configure it, for example:
    sudo nmcli connection modify "Wired connection 1" ipv4.method manual ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1 ipv4.dns "192.168.1.1 8.8.8.8"
    Then apply it: sudo nmcli connection down "Wired connection 1" && sudo nmcli connection up "Wired connection 1". Substitute your own address, gateway and DNS values; the address must be outside your router's DHCP range or reserved for this machine.
  6. Set up a static IP on Ubuntu Server (Netplan). Create or edit a YAML file in /etc/netplan/ (it must be owned by root with permissions 600: sudo chmod 600 /etc/netplan/*.yaml). A minimal static example:
    network:
      version: 2
      ethernets:
        enp3s0:
          addresses: [192.168.1.50/24]
          routes:
            - to: default
              via: 192.168.1.1
          nameservers:
            addresses: [192.168.1.1, 8.8.8.8]
    YAML indentation is strict: two spaces per level, no tabs. Apply with sudo netplan try, which gives you a rollback window if the config breaks connectivity.
  7. Verify DNS. Run resolvectl status (or cat /etc/resolv.conf) to confirm DNS servers are listed, then ping -c 3 google.com. If pinging 8.8.8.8 works but a name fails, only DNS is broken; fix the nameservers in your NetworkManager or Netplan config rather than the IP settings.
  8. Make the connection persistent. NetworkManager saves profiles automatically; enable auto-connect with sudo nmcli connection modify "" connection.autoconnect yes. Netplan configs apply on boot once saved. A manual ip command does not survive a reboot, so never rely on it as your permanent setup.
  9. Test from another device. If this machine should serve something (SSH, a web page), test from another computer on the same network using the machine's IP, and check the firewall: sudo ufw status on Ubuntu or sudo firewall-cmd --list-all on Fedora/RHEL. Open only the ports you need, e.g. sudo ufw allow ssh.

Common Mistakes

  • Using the wrong interface name. Copy the exact name from ip a; guessing eth0 when your card is enp3s0 fails silently.
  • Bad YAML indentation in Netplan files. Tabs instead of spaces, or misaligned colons, cause the whole config to be rejected.
  • Choosing a static IP inside the router's DHCP pool, which leads to address conflicts when the router hands the same IP to another device. Reserve the address in the router or pick one outside the pool.
  • Forgetting the gateway or DNS. Without a default route you can reach your LAN but not the internet; without DNS, everything works by IP but no names resolve.
  • Editing /etc/resolv.conf directly on systems where it is generated (by systemd-resolved or NetworkManager). Your changes will be overwritten; set DNS in the connection profile or Netplan file instead.
  • Relying on manually run ip commands as a permanent configuration and losing everything after a reboot.

Tips

  • nmcli has tab completion for interface and connection names, which prevents typos.
  • nmcli device wifi list shows available Wi-Fi networks with signal strength before you connect.
  • Use sudo netplan try instead of sudo netplan apply when configuring a server over SSH; if you cut your own connection, it reverts automatically after a short countdown.
  • ip -br a gives a compact one-line-per-interface view that is much easier to read than the full output.
  • For a home server you want to reach reliably, prefer a static IP or a DHCP reservation in the router over letting the address change.

Troubleshooting

  • No interface listed at all: the driver may be missing. Run lspci or lsusb to identify the hardware, check dmesg | grep -i firmware, and install firmware packages from your distribution's repositories if the log mentions missing firmware. Some Wi-Fi chips need non-free firmware, which not all ISOs include.
  • Interface up but no IP: check the cable and port lights, confirm a DHCP server (your router) is running, then try requesting an address manually with sudo dhclient -v and read the output.
  • Have IP, no internet: check the default route with ip route; there should be a line starting with default via. If missing, your gateway setting didn't apply.
  • Internet works by IP but not by name: it's DNS. Verify nameservers with resolvectl status and correct them in your connection config.
  • Wi-Fi won't connect: run nmcli device status; if the radio is shown as unavailable, toggle it with nmcli radio wifi on. Check rfkill list for hard or soft blocks, and confirm the SSID and password are exactly right.
  • Worked until reboot: you configured it with temporary commands. Move the settings into NetworkManager or Netplan as described above.
  • Others can't reach your server: check the firewall first (sudo ufw status or sudo firewall-cmd --list-all) and confirm the service is listening with ss -tulpn.

Frequently Asked Questions

What is the difference between NetworkManager and Netplan?

NetworkManager is a service that manages connections and works per-connection via nmcli or a desktop applet. Netplan is a renderer, mainly on Ubuntu Server, that reads a YAML file and generates configuration for a backend like systemd-networkd or NetworkManager. Use whichever your distribution ships with.

How do I set a static IP from the command line only?

Either edit the Netplan YAML file (Ubuntu Server) or run nmcli with ipv4.method manual and your addresses, gateway and DNS as shown in the steps. Both persist across reboots; raw ip addr add commands do not.

How do I connect to Wi-Fi from a terminal without a desktop?

With NetworkManager: nmcli device wifi connect "SSID" password "password". Without it, wpa_supplicant plus a DHCP client works but requires more manual setup; installing NetworkManager is usually simpler.

Why does my interface name look like enp3s0 instead of eth0?

Modern Linux uses predictable interface names based on hardware location. They're stable across reboots, which is why they replaced the old eth0/wlan0 scheme. You can rename them via a udev rule or a kernel parameter, but it's rarely worth it.

How do I see which DNS server my system is using?

Run resolvectl status on systems with systemd-resolved, or cat /etc/resolv.conf. Change DNS in your connection profile, not by editing resolv.conf directly.