Unwanted multiple IP addreses

So I wanted to try running regular Debian 10 on a new Raspberry Pi 4 I just got. Debian have official images for this.

https://raspi.debian.net/tested-images/

The issue I am having is that when booted the device grabs an address by DHCP which is fine but it is not released when I configure a static IP.

I have done this multiple times on normal x86 Debian servers but those go through the normal installer where the RPi image does not.

ip a

gives me

 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
     inet 127.0.0.1/8 scope host lo
        valid_lft forever preferred_lft forever
     inet6 ::1/128 scope host 
        valid_lft forever preferred_lft forever
 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
     link/ether dc:a6:32:b5:56:43 brd ff:ff:ff:ff:ff:ff
     inet 192.168.0.71/24 brd 192.168.0.255 scope global dynamic eth0
        valid_lft 84425sec preferred_lft 84425sec
     inet 192.168.0.4/24 brd 192.168.0.255 scope global secondary eth0
        valid_lft forever preferred_lft forever
     inet6 2001:8b0:1741:ec2e:dea6:32ff:feb5:5643/64 scope global dynamic mngtmpaddr 
        valid_lft 4294966375sec preferred_lft 4294966375sec
     inet6 fe80::dea6:32ff:feb5:5643/64 scope link 
        valid_lft forever preferred_lft forever
 3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
     link/ether dc:a6:32:b5:56:44 brd ff:ff:ff:ff:ff:ff

I cannot figure out how to get rid of

inet 192.168.0.71/24 brd 192.168.0.255 scope global dynamic eth0

and

inet6 2001:8b0:1741:ec2e:dea6:32ff:feb5:5643/64 scope global dynamic mngtmpaddr

Any advice or suggestions gratefully received.

you could try

ip addr del 192.168.0.71/32 dev eth0

but if that takes out both ip’s, then add the one back you want?

(source, answer two from here)

sudo ip addr del 192.168.0.71/32 dev eth0
RTNETLINK answers: Cannot assign requested address

sudo ip addr del 192.168.0.71/24 dev eth0
client_loop: send disconnect: Broken pipe

Had to power cycle the device manually to log back in but no changes. 192.168.0.71 is still present.

Maybe I was a little optimistic using the Debian RPi images. They are based on Sid it seems.

Okay, only difference between the .71 and .4 addresses is one says secondary, the other dynamic?
Maybe try on the .4 and see how it goes?

Oh, and maybe set the interface to not do dhcp?

This is the issue. I can’t figure out how to shut off client side DHCP in this scenario.

I can connect on the 192.168.0.4 address via SSH but I think the other address is interfering with what I want to do next.

It’s all very odd.

let’s see what Dutch has to say.

I personally would google how to activate wifi so you have an alternative connection,

and treat DHCP as a seperate issue.

[edit: not the dhcp I was thinking of]

but I don’t know if that is Client side, or server side?

What’s the contents of the file /etc/network/interfaces?

Here’s an extract from mine, yours is probably equal or very similar:

The primary network interface
auto eth0
iface eth0 inet dhcp

To change your dhcp into a static address, just change dhcp in that last line into static. Then expand with the static IP address, netmask and gateway entries. For the exact syntax, use Google :wink:

Once you’re sure you’ve got everything set up correctly, issue this two-liner:

sudo su
ifdown eth0 && ifup eth0

Enter your password on request. Your RPi will now shut down the network interface, resulting in you getting kicked out of your SSH session if you’re logged in that way, then bring it back up with just the static IP address you’ve configured. You should be able to log in again remotely, with SSH of course.

HTH!

1 Like

The culprit was the file /etc/network/interfaces.d/eth0

Change


auto eth0

iface eth0 inet dhcp

to


auto eth0

iface eth0 inet static

I also changed the fourth line in /etc/network/interfaces from

source-directory /etc/network/interfaces.d

to

source-directory /etc/network/interfaces.d/*

Now after a reboot all was well with the output from ip a

2 Likes