Static IP address in Linux (Debian)

You can give your Debian installation a static IP address by following these steps:

1. Determine your network interface name: Use the following command to determine the name of your network interface:

ip addr

This will display information about all of your network interfaces. Look for the interface that you want to configure with a fixed IP address. The interface name will be listed on the left-hand side of the output (e.g. eth0, enp0s3, etc.)

2. Edit the network configuration file: Use a text editor to edit the /etc/network/interfaces file. For example, you can use the nano editor by running the following command:

sudo nano /etc/network/interfaces

3. Configure the network interface: Add the following lines to the file, replacing the interface name and IP address with your own values:

auto <interface-name>
iface <interface-name> inet static
address <ip-address>
netmask <subnet-mask>
gateway <default-gateway>
dns-nameservers <dns-server-ip-address>

For example, if your network interface name is “eth0” and you want to set the IP address to “192.168.0.10”, the subnet mask to “255.255.255.0”, the default gateway to “192.168.0.1”, and the DNS server to “8.8.8.8”, the configuration would look like this:

auto eth0
iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8

4. Save and close the file: Press Ctrl+O to save the file, and then press Ctrl+X to close the editor.

5. Restart the networking service: Use the following command to restart the networking service and apply the changes:

sudo systemctl restart networking

After you’ve completed these steps, your Debian installation should have a fixed IP address. You can verify the configuration by using the “ip addr” command again and looking for the interface that you configured.

More info here: https://wiki.debian.org/NetworkConfiguration
Thanks to https://fosstodon.org/@HankB for the tips and better choice of words!

Loading