DjoeC
Posts: 9
Joined: Tue Dec 23, 2014 8:47 pm

Multiple static IP addresses on eth0 Raspian Stretch using dhcpcd

Thu Nov 29, 2018 9:59 am

I am looking for a solution to use multiple static IP addresses on the eth0 interface under Raspbian Stretch by using dhcpcd as that appears to be the Raspbian networking solution going forward.
I haven't found anything other than using the /etc/network/interfaces settings:

Code: Select all

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 10.1.1.51
        gateway 10.1.1.1
        netmask 255.255.255.0

auto eth0:1
iface eth0:1 inet static
        address 10.1.1.52
        gateway 10.1.1.1
        netmask 255.255.255.0

auto eth0:2
        iface eth0:2 inet static
        address 10.1.1.53
        gateway 10.1.1.1
        netmask 255.255.255.0

allow-hotplug wlan0
iface wlan0 inet static
        address 10.1.1.50
        gateway 10.1.1.1
        netmask 255.255.255.0
   wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
which is working well, wired and wireless after

Code: Select all

sudo update-rc.d dhcpcd disable
This does not seem futureproof but as said: I cannot find a dhcpcd equivalent other than "it is not possible" which would mean that Stretch has decreased functionality. Hard to believe.

Does anyone have a (working) solution? Thanks!

<disclaimer: I am not a networking specialist - just want this to work without reverting to "the old ways">

DirkS
Posts: 9941
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Multiple static IP addresses on eth0 Raspian Stretch using dhcpcd

Thu Nov 29, 2018 11:19 am

DjoeC wrote:
Thu Nov 29, 2018 9:59 am

Code: Select all

sudo update-rc.d dhcpcd disable
This does not seem futureproof
Not future proof indeed...
You should start using 'systemctl'
https://www.digitalocean.com/community/ ... -and-units

DjoeC
Posts: 9
Joined: Tue Dec 23, 2014 8:47 pm

Re: Multiple static IP addresses on eth0 Raspian Stretch using dhcpcd

Thu Nov 29, 2018 11:45 am

DirkS wrote:
Thu Nov 29, 2018 11:19 am
DjoeC wrote:
Thu Nov 29, 2018 9:59 am

Code: Select all

sudo update-rc.d dhcpcd disable
This does not seem futureproof
Not future proof indeed...
You should start using 'systemctl'
https://www.digitalocean.com/community/ ... -and-units

Code: Select all

sudo update-rc.d dhcpcd disable
replaced in my script with the systemd version:

Code: Select all

sudo systemctl stop dhcpcd.service
sudo systemctl disable dhcpcd.service
Thanks & you are correct about systemctl for managing services, I will dive into that as well. However I am still looking for an answer to the multiple IP addresses issue, not sure systemctl will help me with that.

epoch1970
Posts: 3692
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Multiple static IP addresses on eth0 Raspian Stretch using dhcpcd

Thu Nov 29, 2018 12:13 pm

With iproute2 the notion of "interface alias" found in ifconfig is gone.

You can "ip address add 192.168.1.1/24 dev eth0" and "ip address add 192.168.1.2/24 dev eth0" and then "ip address show" will list both addresses under eth0.

Perhaps you can try adding multiple "static ip_address=..." declarations under "interface eth0" in dhcpcd.conf?
I don't have a machine to test with, sorry.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

DjoeC
Posts: 9
Joined: Tue Dec 23, 2014 8:47 pm

Re: Multiple static IP addresses on eth0 Raspian Stretch using dhcpcd

Thu Nov 29, 2018 9:13 pm

epoch1970 wrote:
Thu Nov 29, 2018 12:13 pm
With iproute2 the notion of "interface alias" found in ifconfig is gone.

You can "ip address add 192.168.1.1/24 dev eth0" and "ip address add 192.168.1.2/24 dev eth0" and then "ip address show" will list both addresses under eth0.

Perhaps you can try adding multiple "static ip_address=..." declarations under "interface eth0" in dhcpcd.conf?
I don't have a machine to test with, sorry.
command line

Code: Select all

sudo ip address add 10.1.1.54/24 dev eth0
works and becomes active immediately so thanks for that! I have tried several ways in the dhcpcd.conf but sofar no luck. So still looking for the "perfect" solution in the "right" file.

squirrelz
Posts: 1
Joined: Mon Mar 25, 2019 11:23 am

Re: Multiple static IP addresses on eth0 Raspian Stretch using dhcpcd

Mon Mar 25, 2019 11:26 am

I found this post while trying to do the same thing. Not sure if it's useful but how I've ended up doing it was from something I found here:https://wiki.archlinux.org/index.php/dhcpcd

I created /etc/dhcpcd.exit-hook and put in it:

Code: Select all

ip address add 192.168.0.99/24 dev eth0
After a reboot it's come back up with it's normal static, as well as this second IP

RICKBROIDA
Posts: 1
Joined: Thu Aug 01, 2019 9:29 pm

Re: Multiple static IP addresses on eth0 Raspian Stretch using dhcpcd

Thu Aug 01, 2019 9:43 pm

If possible, can you add a Youtube video tutorial on how to set Multiple Static Ip for better understanding, please !!


____________________________________________________________________
Connect to the Router : 192.168.1.1 Login

Return to “Networking and servers”