RDPUser
Posts: 147
Joined: Tue Jan 30, 2018 12:18 pm

Adding second static IP address

Thu Aug 01, 2019 12:29 am

How can a second static ip address be configured on buster?
I've tried

Code: Select all

sudo cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
        address 192.168.178.251
        netmask 255.255.255.0

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
But gives a failure with DHCPCD
Warning: The unit file, source configuration file or drop-ins of dhcpcd.service changed on disk. Run 'systemctl daemon-reload' to reload units.
â dhcpcd.service - dhcpcd on all interfaces
Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/dhcpcd.service.d
ââwait.conf
Active: failed (Result: exit-code) since Thu 2019-08-01 01:15:33 BST; 9min ago
Process: 403 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -w (code=exited, status=6)

Aug 01 01:15:33 raspberry systemd[1]: Starting dhcpcd on all interfaces...
Aug 01 01:15:33 raspberry dhcpcd[403]: Not running dhcpcd because /etc/network/interfaces
Aug 01 01:15:33 raspberry dhcpcd[403]: defines some interfaces that will use a
Aug 01 01:15:33 raspberry dhcpcd[403]: DHCP client or static address
Aug 01 01:15:33 raspberry systemd[1]: dhcpcd.service: Control process exited, code=exited, status=6/NOTCONFIGURED
Aug 01 01:15:33 raspberry systemd[1]: dhcpcd.service: Failed with result 'exit-code'.
Aug 01 01:15:33 raspberry systemd[1]: Failed to start dhcpcd on all interfaces.
This error is not only a cosmetic issue. If you plug in a new NIC like a WiFi Stick no new interface wlan1 shows up.
So what is the correct way to use dhcpcd and have a second static IP/interface?

RDPUser
Posts: 147
Joined: Tue Jan 30, 2018 12:18 pm

Re: Adding second static IP address

Thu Aug 01, 2019 12:38 am

Found the solution with help of this post https://www.raspberrypi.org/forums/view ... p?t=191678

Hope this answer is helpful for all others.
Just create /etc/network/interfaces.d/eth0_0 with this content and everything will work fine. Strange behaviour since /etc/network/interfaces explicitly includes that files, which is basically the same.

Code: Select all

auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
        address 192.168.178.251
        netmask 255.255.255.0

Return to “Advanced users”