Configure Static IP Linux Debian

Oct 25, 2024 · 2 mins read
Configure Static IP Linux Debian

Configuring a Static IP Address in Debian

This guide provides detailed instructions for setting up a static IP address on Debian. It includes a summary of commands, a step-by-step breakdown, and troubleshooting tips for common network configuration issues.

Note: Ubuntu uses Netplan, which is a command line utility for the configuration of networking on certain Linux distributions. Netplan uses YAML description files to configure network interfaces


Summary of CLI Steps:

# Open the network configuration file
sudo nano /etc/network/interfaces

# Add configuration for the static IP
iface eth0 inet static
    address <your_static_ip>
    netmask <your_netmask>
    gateway <your_gateway>

# Restart networking service
sudo systemctl restart networking

Configuring a Static IP Using the Command Line (CLI)

  1. Open the Network Configuration File
    In Debian, network configurations are stored in /etc/network/interfaces. Open this file with nano:

    sudo nano /etc/network/interfaces
    
  2. Edit Interface Configuration
    Add or modify the configuration for the interface (e.g., eth0) with the specific IP settings:

    iface eth0 inet static
        address <your_static_ip>
        netmask <your_netmask>
        gateway <your_gateway>
    
    • address: Set the static IP address, e.g., 192.168.1.100.
    • netmask: Specify the subnet mask, e.g., 255.255.255.0.
    • gateway: Define the default gateway IP, e.g., 192.168.1.1.
  3. Save and Close the File
    Save your changes (CTRL + O) and close the editor (CTRL + X).

  4. Restart the Networking Service
    Apply the new configuration by restarting the networking service:

    sudo systemctl restart networking
    
  5. Verify IP Configuration
    Confirm the new IP by running:

    ip a show eth0
    

Troubleshooting

  • Issue: IP address doesn’t persist after reboot.
    Solution: Verify that changes in /etc/network/interfaces are correct and saved.

  • Issue: Unable to connect after setting static IP.
    Solution: Ensure IP, subnet, and gateway do not conflict with other devices on the network.

  • Issue: No internet access after configuration.
    Solution: Verify the gateway and DNS settings in /etc/resolv.conf, adding DNS servers if necessary.

Share this article!