Debian 9 Static ip (Debian Stretch)

Setting Debian 9 static IP is not too different from the previous version. You might find the network cards named a bit differently now. Apart from that, it is mostly the same. And we will look at an alternative at the end, and an issue while configuring Debian 9 static IP.

Debian 9 Static IP

Edit network interfaces

Let’s look at how to give your Debian 9 a static IP address. The first thing you need is to edit the network interfaces. Launch your favorite text editor and edit /etc/network/interfaces. It will look something like below. In this example, I’m using a wired network interface. It will now be called ens3 instead of eth0 like in earlier versions. Your interface might have a different name.

debian 9 static ip 1

You need to change DHCP to static. Then you need to add the address, gateway, and netmask. In this example, I used 192.168.2.86 for address and 1921.68.2.1 for the gateway (because that is the address of my gateway). Most likely your settings will be different. Change them to fit your network. After editing the network interfaces my config looks like this after setting Debian 9 static IP.

debian 9 static ip 2

Apply the Debian 9 static IP

To apply the changes we need to restart the network service. If you are connected to the computer via SSH, you will need to reboot. You will lose connection when restarting the network service if you are on SSH. If you are local or a KVM console restart your interface like below.

To restart the network service just type into the terminal or console: service networking restart (typing /etc/init.d/networking restart will also do). If you at this point check your network settings with ifconfig or ip addr, the network will be unreachable. To fix this run: ifup ens3 (or whatever your interface is called). Now run: ip addr, to verify your new settings.

debian 9 static ip 3

Here I noticed my new static IP had become a secondary IP. I don’t want that. I only need 1 IP for this machine. At this point, I can use both 192.168.2.86 and 192.168.2.59 (which was the IP given by the DHCP server). I just rebooted to remove the DHCP assigned IP address.

debian 9 static ip 4

Another option to static IP addresses

There is another option to a static IP address. Your router, if it is not too old and simple, has an option to assign IP addresses to specific mac addresses. On my wifi router, also used as a DHCP server it looks like this.

debian 9 static ip 5

This is an inexpensive Asus RT-N66U router. But most wifi routers have this option to assign mac addresses to IP addresses. I prefer using Debian 9 static IP addresses instead of assigning them to the router.

If you are using Debian 8 (Jessie) or Debian 7(Wheezy), check out Debian Static IP how to

Check out this video to see how it is done

Or maybe looking for Debian 9 change hostname permanently

About Author

Related Posts

php8 gd

PHP8 gd Activate after installation

PHP8 GD activate after installation. GD doesn’t get activated by default. Not even a reboot after installation will activate it. So how do we do it? In…

Debian 12: linux-image-6.1.0-10amd64

Troubleshooting dependency issues in Debian 12: Resolving linux-image-6.1.0-10amd64 package dependency problems. If you installed the Debian 12 from the live image the issue is the raspi-firmware. Even…

4 Best Free Nas Software That Is Open Source

Free NAS software or operating systems that are free to use and will turn a computer into a NAS more advanced than the dedicated boxes sold. What…

Raspbian default password

Raspbian default password

Looking for the Raspbian default password? It is the most essential username and password that you will need for your raspberry. At least if you are running…

OpenMediaVault default password

OpenMediaVault default password

OpenMediaVault default password is printed in the documentation. I did not see it the first time I installed it either. So I had to do some detective…

Debian change dns

Debian change DNS settings to a new DNS

Debian change DNS settings for speed improvement or privacy. It is really easy to do. So let us see how it’s done and get to it. The…

This Post Has 2 Comments

Leave a Reply