Smart Systems for Home

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

Linux Networking Interfaces: Setup & Troubleshooting

· 5 min read · Home Networking

In this article
  1. What You’ll Need
  2. Step‑by‑Step
  3. or
  4. Add or modify:
  5. Example content:
  6. Example content:
  7. or
  8. or
  9. optionally, resolve a domain:
  10. or for NetworkManager:
  11. for systemd‑networkd:
  12. Common Mistakes
  13. Tips
  14. Troubleshooting
  15. Look for "state DOWN". If so, run:
  16. or
  17. Frequently Asked Questions

Yes, you can configure Linux networking interfaces using built‑in tools like ip, ifconfig, nmcli, or netplan, depending on your distribution.

What You’ll Need

  • A terminal or SSH access to the machine.
  • Root or sudo privileges to edit system files.
  • Knowledge of the interface name (e.g., eth0, enp3s0, wlan0).
  • Optional: netplan configuration files for Ubuntu 18.04+.
  • Optional: NetworkManager if you prefer a GUI or nmcli command line.

Step‑by‑Step

  1. Open a terminal and list all network interfaces:
    ip link show
    

    or

    ifconfig -a
    Identify the one you want to configure (e.g., enp3s0).
  2. Decide whether the interface will use DHCP or a static IP address.
    • DHCP is the default on most desktops and servers; it automatically requests an address from a router or DHCP server.
    • Static requires you to specify the IP, netmask, gateway, and DNS servers.
  3. For a static configuration on Debian or Ubuntu using /etc/network/interfaces:
    sudo nano /etc/network/interfaces
    

    Add or modify:

    auto enp3s0 iface enp3s0 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameservers 8.8.8.8 8.8.4.4
    Save and exit.
  4. For a static configuration on Ubuntu 18.04+ using netplan:
    sudo nano /etc/netplan/01-netcfg.yaml
    

    Example content:

    network: version: 2 renderer: networkd ethernets: enp3s0: dhcp4: no addresses: [192.168.1.100/24] gateway4: 192.168.1.1 nameservers: addresses: [8.8.8.8, 8.8.4.4]
    Apply with sudo netplan apply.
  5. For a DHCP configuration on Debian or Ubuntu using /etc/network/interfaces:
    auto enp3s0
    iface enp3s0 inet dhcp
    Then restart networking:
    sudo systemctl restart networking
  6. For a DHCP configuration on Ubuntu 18.04+ using netplan:
    sudo nano /etc/netplan/01-netcfg.yaml
    

    Example content:

    network: version: 2 renderer: networkd ethernets: enp3s0: dhcp4: true
    Apply with sudo netplan apply.
  7. If you use NetworkManager and prefer nmcli:
    sudo nmcli con add type ethernet con-name static-eth0 ifname enp3s0 ip4 192.168.1.100/24 gw4 192.168.1.1
    sudo nmcli con mod static-eth0 ipv4.dns "8.8.8.8 8.8.4.4"
    sudo nmcli con up static-eth0
    For DHCP:
    sudo nmcli con mod enp3s0 ipv4.method auto
    sudo nmcli con up enp3s0
  8. Bring the interface up or down to apply changes immediately:
    sudo ip link set enp3s0 up
    

    or

    sudo ip link set enp3s0 down
  9. Verify the IP assignment:
    ip addr show enp3s0
    

    or

    ifconfig enp3s0
    You should see the configured address and subnet mask.
  10. Test connectivity to the gateway and an external host:
    ping -c 4 192.168.1.1
    ping -c 4 8.8.8.8
    

    optionally, resolve a domain:

    ping -c 4 google.com
    If all replies come back, the interface is functioning.
  11. Persist the configuration across reboots by ensuring the chosen method (interfaces, netplan, or NetworkManager) is enabled and that the service is active:
    sudo systemctl enable networking
    

    or for NetworkManager:

    sudo systemctl enable NetworkManager

    for systemd‑networkd:

    sudo systemctl enable systemd-networkd

Common Mistakes

  • Using the wrong interface name; always double‑check with ip link before editing.
  • Leaving the interface in the down state after configuration; run ip link set up or nmcli con up.
  • Incorrect netmask or CIDR notation; a mismatch will prevent routing to the network.
  • Editing /etc/network/interfaces on a system that uses netplan; the changes will be ignored.
  • Forgetting to restart or apply the configuration; netplan apply or systemctl restart networking is required.
  • Overwriting NetworkManager connections with manual ifconfig commands; this can cause conflicts.

Tips

  • Use nmcli device status to see which interfaces are managed by NetworkManager.
  • When working on a server, prefer netplan or systemd-networkd for a lightweight, daemon‑based approach.
  • Keep a backup of original config files before editing; use sudo cp /etc/network/interfaces /etc/network/interfaces.bak.
  • Use journalctl -u networking or journalctl -u systemd-networkd to view recent log entries if something fails.
  • For wireless interfaces, add iface wlan0 inet dhcp and then run sudo iwconfig wlan0 essid YOUR_SSID key YOUR_KEY if not using NetworkManager.
  • When troubleshooting, start with a physical cable check; a loose or damaged cable is a common culprit.

Troubleshooting

  1. Check the physical connection: ensure the Ethernet cable is securely plugged into both the host and the switch or router.
  2. Verify the interface is not administratively down:
    ip link show enp3s0
    

    Look for "state DOWN". If so, run:

    sudo ip link set enp3s0 up
  3. Confirm the configuration file syntax:
    • For /etc/network/interfaces, run sudo ifup -a and observe errors.
    • For netplan, run sudo netplan try to preview changes without rebooting.
  4. Inspect system logs for driver or kernel messages:
    dmesg | grep enp3s0
    journalctl -b | grep networkd
  5. Check that the correct network renderer is active (NetworkManager vs systemd‑networkd). Mixing both can cause conflicts. Disable the unwanted service with sudo systemctl disable NetworkManager or sudo systemctl disable systemd-networkd as appropriate.
  6. If DHCP is not working, verify that a DHCP server is reachable and that the interface is not blocked by a firewall. Temporarily disable the firewall with sudo ufw disable to test.
  7. Use nmcli device show enp3s0 to view detailed status, including DHCP lease information.
  8. Restart the networking service or reboot the machine if changes are not taking effect:
    sudo systemctl restart networking
    

    or

    sudo reboot
  9. If the interface still does not acquire an IP, try a manual IP assignment with sudo ip addr add 192.168.1.100/24 dev enp3s0 and then test connectivity.
  10. When all else fails, consult the distribution’s official documentation or community forums for version‑specific quirks.

Frequently Asked Questions

1. How do I find the correct interface name on my system?

Run ip link show or ifconfig -a and look for the name that matches the hardware (e.g., enp3s0 for a wired NIC). Avoid using generic names like eth0 on modern systems.

2. Can I use ifconfig to set a static IP?

Yes, but ifconfig is deprecated. Use ip addr add for a temporary change or edit the persistent config files for a permanent setting.

3. What is the difference between netplan and NetworkManager?

Netplan is a declarative YAML system that writes configuration for either systemd-networkd or NetworkManager. NetworkManager is a full‑featured daemon that manages both wired and wireless connections and offers a GUI. Choose netplan for servers, NetworkManager for desktops.

4. Why does my interface not come up after reboot?

Either the configuration file is not in the correct location, or the networking service is disabled. Verify the file path, syntax, and that systemctl status networking shows active.

5. How do I enable a static IP on a Wi‑Fi interface?

Use NetworkManager or nmcli to create a connection with ipv4.method manual and specify the address, netmask, gateway, and DNS. Avoid editing /etc/network/interfaces for wireless on modern distros.

6. What should I do if I accidentally delete my network configuration?

Restore from a backup copy if you made one. If not, recreate the file using the examples above. For Netplan, create a new YAML file; for interfaces, edit /etc/network/interfaces accordingly.