Skip to main content

Debian: Static IP Address Set Up

Debian uses different network management systems. In this article, we willI'll show you how to set a static IP address using all these methods.


🔎 Find your Network Manager

To check which network management system your Debian is using, you have to check if some files exist that are used by either of your manager:

    networking: /etc/network/interfaces dhcpd: /etc/dhcpd.conf systemd-networkd: /etc/systemd/network/*

    If neither of these files exist, your Debian uses NetworkManager to configure your network.

    🧰 Configure your Static IP

    Firstly, you need to find the name of your local ethernet interface. To get this information, run the ip a command. The output should look something like this:

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host noprefixroute 
           valid_lft forever preferred_lft forever
    
    ### ETHERNET INTERFACE 
    
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether dc:a6:32:cc:b4:ec brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.200/24 brd 192.168.1.255 scope global eth0
           valid_lft forever preferred_lft forever
        inet6 2a02:a03f:a190:d700:dea6:32ff:fecc:b4ec/64 scope global dynamic mngtmpaddr 
           valid_lft 86364sec preferred_lft 71964sec
        inet6 fe80::dea6:32ff:fecc:b4ec/64 scope link 
           valid_lft forever preferred_lft forever
    
    ###
    
    3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
        link/ether dc:a6:32:cc:b4:ee brd ff:ff:ff:ff:ff:ff
    

    Find the group with your IP address. In my case, it is the group 2:. From here, the interface name is eth0

    networking

    To assign a static IP address using the networking service, edit the /etc/network/interfaces file:

    auto eth0
    iface eth0 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        gateway 192.168.1.1
        dns-nameservers 8.8.8.8 1.1.1.1
    

    Description line by line:

      auto eth0: add the eth0 interface to the list of interfaces that you want brought up at boot time. iface eth0 inet static: tells Debian to set the IPv4 (inet) eth0 interface in static mode. address: the static address you want. netmask: the netmask of your network. gateway: the gateway of your network. dns-nameservers: your DNS IP addresses separate by a space.

      Next, brought up and down your network interface:

      sudo ifdown eth0
      sudo ifup eth0