Celeb Glow
news | March 04, 2026

Multiple static IP Debian 9 Stretch on one interface

Cannot add multiple IPs to network interface.

While trying to add an IP to the interface enp2s0 via Webmin it says:

Failed to save interface : Missing or invalid interface name

It's a known bug in Webmin, so lets skip this right now.

Modifying /etc/network/interfaces directly

auto lo
iface lo inet loopback
iface lo inet6 loopback
auto enp2s0
allow-hotplug enp2s0
iface enp2s0 inet static address XX.4.87.10 netmask 255.255.255.224 gateway XX.4.87.1 # route XX.4.87.0/27 via XX.4.87.1 up route add -net XX.4.87.0 netmask 255.255.255.224 gw XX.4.87.1 dev enp2s0
iface enp2s0 inet static address XX.4.87.47 netmask 255.255.255.224 gateway XX.4.87.33 up route add -net XX.4.87.0 netmask 255.255.255.224 gw XX.4.87.33 dev enp2s0
iface enp2s0 inet static address XX.4.87.37 netmask 255.255.255.224 gateway XX.4.87.33 up route add -net XX.4.87.0 netmask 255.255.255.224 gw XX.4.87.33 dev enp2s0
iface enp2s0 inet6 static address XXXX:4f8:140:701e::2 netmask 64 gateway fe80::1

The first (main-IP) and the second in the list are always connectable, but the third permanently not. So I'm able to switch the IPs order and can access my server after a reboot, what I'm doing wrong?

(I've also tried the legacy method of Debian Docs but this is crashing it all)

root@hdtu1 ~ # systemctl status networking.service
● networking.service - Raise network interfaces Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2018-08-01 22:40:12 CEST; 7s ago Docs: man:interfaces(5) Process: 2184 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE) Process: 2179 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --exclude Main PID: 2184 (code=exited, status=1/FAILURE)
Aug 01 22:40:12 hdtu1 systemd[1]: Starting Raise network interfaces...
Aug 01 22:40:12 hdtu1 ifup[2184]: RTNETLINK answers: File exists
Aug 01 22:40:12 hdtu1 ifup[2184]: ifup: failed to bring up enp2s0
Aug 01 22:40:12 hdtu1 systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Aug 01 22:40:12 hdtu1 systemd[1]: Failed to start Raise network interfaces.
Aug 01 22:40:12 hdtu1 systemd[1]: networking.service: Unit entered failed state.
Aug 01 22:40:12 hdtu1 systemd[1]: networking.service: Failed with result 'exit-code'.
3

2 Answers

You cannot have multiple default gateway for one interface, and in my opinion the way you are adding multiple IP to the same interface is incorrect.

Add the secondary IP with this notation :

iface enp2s0 inet static address XX.4.87.10 netmask 255.255.255.224 gateway XX.4.87.1 # route XX.4.87.0/27 via XX.4.87.1 up route add -net XX.4.87.0 netmask 255.255.255.224 gw XX.4.87.1 dev enp2s0
iface enp2s0:1 inet static address XX.4.87.47 netmask 255.255.255.224 # I removed the "gateway" instruction in this block, as it is a secondary IP up route add -net XX.4.87.0 netmask 255.255.255.224 gw XX.4.87.33 dev enp2s0
3

My Debian 9 works like that using the hint from @Marc R.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug enp0s3
#iface enp0s3 inet dhcp
iface enp0s3 inet static
address 192.168.0.203
netmask 255.255.255.0
gateway 192.168.0.1
iface enp0s3 inet static
address 192.168.0.204
netmask 255.255.255.0

Usually i ever uses eth0:1 or devicename:1 for multi ip now for my surprise at Debian 9 looks like it handles the split by itself.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy