Debian 9 Static ip (Debian Stretch)

debian 9 static ip

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 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 and (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

April 4th, 2018 by
Optimization WordPress Plugins & Solutions by W3 EDGE