Double IP in Raspberry Pi network
-
Yesterday I saw something I hadn't seen before: a network card with two simultaneous IPs. It seems to be a Raspbian bug that has been observed since 2015 but that still hasn't been fixed today. I noticed it because, despite having a static IP configured, there was an IP conflict with another device on the network.
It turns out that even if you configure a static IP, once the system announces the IP via ARP, Raspbian makes a request via DHCP and assigns a second IP. After that, the Raspi responds to both addresses indiscriminately and in the router's ARP table you can see how both IPs correspond to the same MAC.
Here there have actually been two faults: the one where Raspbian asks for IP from the DHCP server when it shouldn't and mine for having overlapped the DHCP IP range with the static IPs of the network.
There are several solutions. One of the simple ones is to force the DHCP client to use a static IP by editing the /etc/dhcpcd.conf file with this:
interface eth0 static ip_address=192.168.0.20/24 static routers=192.168.0.1 static domain_name_servers=192.168.0.1The other option (the one I chose) is to disable the DHCP client with this:
sudo update-rc.d -f dhcpcd removeIf you want to reactivate the DHCP client (useful in Wifi networks for example), type this:
sudo update-rc.d dhcpcd defaultsObviously, I have also corrected the range of automatic IPs, but that has been the classic problem of what's between the seat and the keyboard.
-
Well, technically it's not an error, precisely it's something that I recently had to investigate at work and the solution was that, create a VIP (Virtual IP) to which also responds to requests.
This can be done in both windows and linux and indeed it can be useful in certain scenarios.In my case, I had a gateway problem that I solved this way, let's take the example, 3 devices, A, B and C connected like this.
A -- B -- C
A and C can't see or route each other since they have different gateways and their network configuration can't be modified, so B has 2 IP's on each of its interfaces, let's say they are X.10 and X.20. When A communicates with B through X.10, the real recipient of the packet is B. When it does so through X.20, B takes those packets, and does an IPTABLES to C, in this way A thinks it's communicating with B but in reality it's communicating with C through this second IP that B has. And the same between B and C.
I don't know if I've been understood.... it's something strange if haha.
On the other hand, if you have a windows where you're changing IP's constantly, you can go to the adapter properties and put there several IP's that you want the computer to respond to, in this way, when changing networks you don't have to go modifying the IP's at each moment.
They are rare cases but in which it can be useful.
Regards.