debian 9 static ip
April 4th, 2018 by ronny

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

Posted in Debian, Linux Tagged with: ,

July 2nd, 2015 by ronny

Ubuntu Static IP

ubuntu static ip
Regarding Ubuntu Static IP is mostly a straight forward thing. I wouldn’t think it should be needed on a rented VPS. As they mostly get their IP addresses assigned. Anyway, here is how we do Ubuntu Static IP.

First we need to edit the network interface.
sudo vim /etc/network/interfaces

Change the line:
iface eth0 inet dhcp

iface eth0 inet static

And then add (in this example we use the ip
network # Optional
broadcast # Optional

To exit VIM, press ESC and then type wq and then press enter to save the file.

Now your network interface is configured to use a static ip.
It is still not active. To activate the static ip you will need to reboot or restart the network interface.
In Ubuntu this will have to be done like this:
sudo ifdown eth0 && sudo ifup eth0

Take notice of the both sudo. And you need to issue both commands at once if your are doing this via ssh or any other remote terminal. If not the network interface will go down, and so will your connection.

So this is how to Ubuntu Static Ip.

Happy Static!

Posted in Linux, Ubuntu, Uncategorized Tagged with: ,