Last week I was deploying a Debian 9 (Stretch) based Linux OVA from the Bitnami catalog. One of the first things to do after a deployment is to replace the DHCP assigned IP address with a static one.

Deploying the VM itself is not really blog worthy. What did bother me, is that my VM ended up with 2 IP addresses on 1 ethernet interface after configuring a static IP. The interface had a DHCP and a static assigned IP.

It took me a while to understand why my VM had 2 IP addresses and what systemd had to do with that. This post answers that question and as a bonus it seems that configuring interfaces with systemd has some nice advantages. Let me tell you about it in this post.

The initial config

At first I always start to configure the hostname and DNS related information.

  • hostname in /etc/hostname
  • DNS related info in /etc/resolv.conf or /etc/network/interfaces

Now it’s time to enter the IP information in the place I was used to, so in /etc/network/interfaces

First I looked up the assigned NIC name since we’re using Predictable Network Interface Names nowadays. When using the command below the DHCP assigned IP is listed. If not use the ip link command.

bitnami@debian:~$ ip -4 a
1: lo: <skip loopback :-) >
2: ens160: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet brd scope global dynamic ens160

Now it was time to configure the interface itself by putting the proper lines in the /etc/network/interfaces

auto ens160
iface ens160 inet static

dns-search <>

The issue

After executing an ifdown / ifup command, I ended up with the original DHCP assigned address (.117) and the static configured address (.200), but expected only a single IP.

bitnami@debian:~$ ip -4 a
1: lo: <skip loopback :-) >
2: ens160: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet brd scope global ens160
valid_lft forever preferred_lft forever
inet brd scope global secondary dynamic ens160

The solution

After digging into this for a while I stumbled upon an article mentioning that IP addresses can be assigned by systemd. The Bitnami OVA configures the IP address with systemd out of the box and in addition to that I configured it manually also through the interfaces files. In hindsight it’s sounds logical that 2 IP addresses are assigned to the interface.

The solution is to remove the configuration in the interfaces files and configure the IP information only with systemd. Not only IP addresses can be configured with systemd, also other network related parameters like persistent routes, NTP, DNS, MTU size and DHCP can be configured with it.

Let me show you it works. Basically create separate config file for every NIC in your VM or host within the location /etc/systemd/network. Let’s assume a VM with 2 NIC’s. NIC 1 has the default gateway and connects to the internet and NIC 2 has a connection to a backend network.

In my case a default config file was created by Bitnami to enable DHCP for every ethernet interface.



The second file configures NIC 1, which is the internet facing NIC in this example.


NTP=<your NTP server pool>

The third files configures NIC 2, which is the backend facing NIC in this example.


DNS=<your DNS Server 1>
DNS=<your DNS Server 2>


After all modifications are performed, reload the network stack to make them active.

systemctl restart systemd-networkd

To conclude

After giving me a headache initially, from my opinion it makes sense to use systemd for configuring interfaces since pretty much all al the parameters you need can be configured with one solution.

If you have a recent Linux distro, systemd is probably already used to control service startup. So you are most likely familiar with that part already.

Thank you for reading and let me know if you have feedback.

Useful links

Bitnami WordPress OVA

ArchLinux systemd-networkd Wiki explained Predictable Network Interface Names explained


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *