How to to set up a static IP address on a Debian Linux

How to to set up a static IP address on a Debian Linux

To set up a static IP address on a Debian Linux 10/11 system, follow these steps:

  1. Open a terminal window and type the following command to open the network configuration file in a text editor:
refer‮ ‬to:lautturi.com
sudo nano /etc/network/interfaces
  1. Locate the interface that you want to configure, which is typically eth0 for a wired Ethernet connection or wlan0 for a wireless connection. The interface should be defined as follows:
auto <interface>
iface <interface> inet dhcp
  1. Change the dhcp part of the configuration to static so that the interface is configured with a static IP address.

  2. Below the iface line, add the following lines to specify the static IP address, subnet mask, and default gateway:

address <static IP address>
    netmask <subnet mask>
    gateway <default gateway>

For example, if you want to set the IP address to 192.168.1.100, the subnet mask to 255.255.255.0, and the default gateway to 192.168.1.1, the configuration would look like this:

auto <interface>
iface <interface> inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1
  1. Save the file and exit the text editor.

  2. Restart the network interface by typing the following command:

sudo ifdown <interface> && sudo ifup <interface>
  1. Verify that the static IP address has been successfully set by typing the following command:
ip addr show <interface>

The output should display the static IP address that you specified in the configuration file.

Created Time:2017-10-16 14:38:51  Author:lautturi