Skip to content

Set Static IP Address on Deb 12

Set Static IP Address

To change the IP address on Deb 12, you can configure a static IP address either by:

  • Editing /etc/network/interfaces (used on older systems or when avoiding NetworkManager)
  • Using tools like nmcli or a graphical interface if NetworkManager is installed

Below is the method using the traditional /etc/network/interfaces approach.

Know your Interface Name First

Use the following command to identify your network interface name (e.g., eth0, enp0s3):

ip -c link show

Method 1: Using /etc/network/interfaces (Traditional Server Configuration)

This is a manual configuration approach suitable for servers or systems without NetworkManager.

🛡️ Step-by-step Instructions

  1. Find your interface name:

    ip -c link show
    
  2. Backup your current config:

    sudo cp /etc/network/interfaces /etc/network/interfaces.bak
    
  3. Edit the network configuration file:

    sudo vim /etc/network/interfaces
    
  4. Add or modify the configuration:

    Replace enp0s3, IP, netmask, gateway, and DNS as per your actual network details.

    auto enp0s3
    iface enp0s3 inet static
        address 192.168.42.100
        netmask 255.255.255.0
        gateway 192.168.42.1
        dns-nameservers 8.8.8.8 1.1.1.1
    
  5. Apply the changes:

    You can restart the networking service or the specific interface:

    sudo systemctl restart networking
    # or
    sudo ifdown enp0s3 && sudo ifup enp0s3
    

Make sure you have console access

Misconfiguration can lead to loss of network access. Always ensure you have a way to revert if needed, especially when working remotely.


Additional Methods

For systems using NetworkManager, consider using:

  • nmcli (command-line)
  • NetworkManager GUI (nmtui or desktop interface)