Network Static IP

Last Edit: 2024.07.30

Debian / Ubuntu

Overview

Configure network interface static IP addresses.

Assumptions

  • Logged in as administrative user.

Network Interface

Configure network interfaces by creating a configuration file for each interface in the /etc/network/interfaces.d/ directory.

Configure

Use the command ip a for a list of all network interfaces on a system. Note the name of the network interface to configure. For example, eth0 will be used.

sudo nano /etc/network/interfaces.d/eth0

Configure the interface as required by the network.

  • auto / iface: The name of the interface, eth0.
  • address: IP address for the system.
  • netmask: Subnet mask for the network.
  • gateway: IP address of the router on the network.
  • dns-nameservers: Use the router address for the DHCP configured DNS servers, or specify others.
auto eth0
iface eth0 inet static
  address 192.168.1.10
  netmask 255.255.255.0
  gateway 192.168.1.1
  dns-nameservers 9.9.9.9 149.112.112.112

Apply

Apply the network changes by either rebooting the system or restarting the network interface. Reboot if connected via SSH on the modified interface.

sudo reboot
sudo ifdown eth0 && sudo ifup eth0

When using SSH, be sure to modify the SSH configuration on the client before reconnecting to the system.

sudo nano ~/.ssh/config

References

1 2


  1. Debian. “Debian Documentation.” 2024. ↩︎

  2. Debian. “Debian Network Configuration.” 2023. ↩︎