I have a raspberry 3 connected by ethernet and wifi to my router. So I understand I should have 2 IP address referring to it.
But I wrote hostname -I and get 3 different IP addresses:
192.168.1.100, 192.168.1.33 and 192.168.1.35
Where does the third IP come from?
if I disconnect the ethernet cable from the RPI and write again hostname -I I get:
192.168.1.100 and 192.168.1.33
this does not make sense with 'ifconfig' result:
eth0 Link encap:Ethernet HWaddr b8:27:eb:d6:xx:xx
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::ba27:ebff:fed6:xxxx/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:23152 errors:0 dropped:6 overruns:0 frame:0
TX packets:51977 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:12371346 (11.7 MiB) TX bytes:58608891 (55.8 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:416 errors:0 dropped:0 overruns:0 frame:0
TX packets:416 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:47205 (46.0 KiB) TX bytes:47205 (46.0 KiB)
wlan0 Link encap:Ethernet HWaddr b8:27:eb:83:xx:xx
inet addr:192.168.1.33 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::8df4:f4d0:xxxx:115/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:28407 errors:0 dropped:23070 overruns:0 frame:0
TX packets:4040 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7492811 (7.1 MiB) TX bytes:4725779 (4.5 MiB)
update:
As Bugfinger pointed out the use of ip addr show shows which device the address is assigned to:
2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:d6:fb:5a brd ff:ff:ff:ff:ff:ff
inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.1.35/24 brd 192.168.1.255 scope global secondary eth0
valid_lft forever preferred_lft forever
inet6 fe80::ba27:ebff:fed6:fb5a/64 scope link
valid_lft forever preferred_lft forever`
I have 2 different addresses to eth0:
scope global eth0 and scope global secondary eth0
Recent Raspbian versions (since Jessie) are using DHCP Client Daemon (DHCPCD) to configure network devices. So static IP addresses are to be configured in /etc/dhcpcd.conf. If you configured them to be static manually or via /etc/network/interfaces, you end up with one static and one dynamic IP address on the same device. As far as I read about it, it's not clear yet, if that's a bug in DHCPCD or an expected behaviour after mis-configuration.
Anyway, to change that, you have to do as follows.
To see if it is running, check the output of:
sudo service dhcpcd status
If it is not running, start it with:
sudo service dhcpcd start
sudo systemctl enable dhcpcd
If you did already changed /etc/network/interfaces, you need to revert those changes. The original contents of that file (in Jessie) is:
# 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 lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Now all interfaces should be configured through DHCP again. If you now want to set a static IP address for eth0, edit /etc/dhcpcd.conf and put in:
interface eth0
static ip_address=192.168.1.100/24
static routers=192.168.1.1 # or whatever your router is
static domain_name_servers=192.168.1.1 # same as router
After saving the file and sudo reboot, your Raspi should reboot with a static eth0 and a dynamic wlan0 and without the extra IP address hanging around.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With