Score:0

How do I stop DHCP to request address for a static interface?

cn flag

I have a Raspberry PI 4 running Ubuntu 21.10 with a static ip-address on eth0. Despite that, I keep getting a secondary 'dynamic' DHCP address on on it.

netplan

  network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 192.168.0.10/23
      routes:
        - to: default
          via: 192.168.0.1
      nameservers:
          search: [lan]
          addresses: [192.168.0.12]

ip addr show

eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether dc:a6:32:da:df:55 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.10/23 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.0.225/23 brd 192.168.1.255 scope global secondary dynamic eth0
       valid_lft 68727sec preferred_lft 68727sec
    inet6 fe80::dea6:32ff:feda:df55/64 scope link 
       valid_lft forever preferred_lft forever

Even if I delete that interface, it keeps coming back after a few minutes. I have another PI with the "same" configuration and it doesn't have this problem. I also have the /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg per instructions.

Terrance avatar
id flag
One way is to add your IP address to your DHCP server as a reserved IP so only your Raspberry Pi gets that address.
chili555 avatar
cn flag
Is the address x.10 outside the DHCP pool in the router? Is the result chnged with xxx/24 instead of xxx/23?
Kingfranz avatar
cn flag
Yes, the DHCP pool is .201 - .251. I run the /23 so I can handle devices with 192.168.1.xxx. I'll test with /24...
Kingfranz avatar
cn flag
No, changing to /24 didn't help. It's still requesting the .225 address (but now with 0.225 instead of 1.225).
Terrance avatar
id flag
You will need to set it back to /23 if you want the 192.168.0.1 - 192.168.1.254 to be all in the same network. I did notice that you are missing the `dhcp4: no` and `dhcp6: no` right below your `eth0:` above `addresses:` in your .yaml file.
chili555 avatar
cn flag
Are there actually two networks here? 0 and 1? Please explain.
Kingfranz avatar
cn flag
No, there's only the 0 network but sometimes a need to hook up a device that defaults to 192.168.1.xxx, hence the /23. But I really only need that on 1 machine so all the others are going to stay /24 for now on. I just added the dhcp?: no, lets see if that helps...
Kingfranz avatar
cn flag
no, dhcp4: no didn't help either :-(
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.