I'm using Raspbian Jessie.
I would like to have 2 ip addresses on my raspberry eth0 interface.
- One dynamic, dhcp assigned,
- One static, configured either in /etc/network/interfaces, either in /etc/dhcpcd.conf
I tried changing the file /etc/network/interfaces like this:
iface lo inet loopback
iface eth0 inet dhcp
iface eth0:0 inet static
iface wlan0 inet manual
iface wlan1 inet manual
It works fine, but after a while, the dynamic ip address disappears. It seems the lease isn't renewed.
I've read a lot of advises to leave /etc/network/interfaces untouched and rather use /etc/dhcpcd.conf to setup a static ip address, but is it possible to ask dhcpcd to setup both a static and a dynamic ip address at the same time?
Other solutions (systemd-networkd) are welcome too! (as long as I don't need a gui)
edit: Since a lot of people is interested in this question, I'm sharing my workaround. Maybe it will help you too. I tried a few possible solutions but none was stable enough. The reason why I would have wanted this was that I wanted 2 raspberry pi based devices to be able to talk together in a network that I was not controlling, but these would also need to have internet access, so one dhcp ip for the default routing, and one fix ip in a different range for the internal connection. That was working but eventually the dhcp was not renewing the lease. I finally managed to solve my problem using the mdns "hostname.local" address to communicate without having to know the ip of the machines. It's also a cleaner solution in my opinion.